okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
aff3a132f
main
1// The 0.2.7 speed features have a switch in Expert settings (the model's "Native engine settings"). "Faster long prompts" (Qwen KVA) is OFF by default (owner 2// decision, 26 October) and STRATA_KVA=1 turns it on; the Radeon RX 9000 one is on by default and turning it off writes its entry. 3// Back in its default a switch removes its entries, so a default launch carries none of them. strata_control/speed_switches.py says the same for the 4// Terminal (tests/terminal/test_speed_switches.py). 5import test from 'node:test' ; 6import assert from 'node:assert/strict' ; 7import { readFileSync , writeFileSync } from 'node:fs' ; 8import { join } from 'node:path' ; 9import { fileURLToPath } from 'node:url' ; 10import { SPEED_SWITCHES , speedSwitchApplies , speedSwitchIsSet , speedSwitchIsOn , speedSwitchRows , setSpeedSwitch , validateNativeSettings , publicNativeEnv , restoreNativeEnv } from '../server/native-settings.mjs' ; 11import { nativeFixture } from './helpers/native-fixture.mjs' ; 12 13const read = rel => readFileSync ( fileURLToPath ( new URL ( rel , import . meta. url )), 'utf8' ). replace ( / \r\n / g , '\n' ); 14const ENV = { // what each switch writes outside its default 15faster_long_prompts :{ STRATA_KVA :'1' }, 16faster_12gb_nvidia :{ STRATA_ROUTE_PRIOR :'1.5' }, 17faster_radeon_9000 :{ STRATA_PCIE_FRAC_DEFAULT :'old' }, 18picture_reader :{ STRATA_VISION_TOWER :'mtmd' }, 19}; 20/* The fixture's run configs read pictures ("vision"), so a Qwen model also gets the picture reader row (Image reading); the Speed tests below leave it out. */ 21const speed = rows => rows . filter ( s => s . id !== 'picture_reader' ); 22const DEFAULT = { faster_long_prompts :'off' , faster_12gb_nvidia :'off' , faster_radeon_9000 :'on' , picture_reader :'on' }; 23const RTX3060 = { index :0 , name :'NVIDIA GeForce RTX 3060' , vendor :'nvidia' , arch :'86' , vram_gb :12 }; 24const R9700 = { index :0 , name :'AMD Radeon AI PRO R9700' , vendor :'amd' , arch :'gfx1201' , vram_gb :32 }; 25const RX7900 = { index :0 , name :'AMD Radeon RX 7900 XTX' , vendor :'amd' , arch :'gfx1100' , vram_gb :24 }; 26const RTX = { index :0 , name :'NVIDIA GeForce RTX 4090' , vendor :'nvidia' , arch :'89' , vram_gb :24 }; 27const STRIX = { index :0 , name :'AMD Radeon 8060S' , vendor :'amd' , arch :'gfx1151' , vram_gb :96 , uma :true }; 28 29test ( 'there are exactly five switches in the app, the picture reader among them (the Terminal has one more); each writes the engine names of the contract and has its default (KVA and the 12 GB routing off, the other two on)' , () => { 30assert . deepEqual ( SPEED_SWITCHES . map ( s => s . id ), Object . keys ( ENV )); 31for ( const sw of SPEED_SWITCHES ) { 32assert . deepEqual ( sw . env , ENV [ sw . id ], sw . id ); 33assert . equal ( sw . default , DEFAULT [ sw . id ], sw . id ); 34} 35}); 36 37test ( 'the Terminal\'s Qwen "0.2.6 behaviour" switch is not in the app' , () => { 38assert . ok ( ! SPEED_SWITCHES . some ( s => s . env . STRATA_DEFAULTS || / 0\.2\.6 behaviour / . test ( s . label ))); 39assert . ok ( ! Object . values ( SPEED_SWITCHES . flatMap ( s => Object . keys ( s . env ))). includes ( 'STRATA_DEFAULTS' )); 40}); 41 42test ( 'Faster answers on 12 GB NVIDIA cards: only for Qwen on a discrete CUDA card of 13 GiB or less; off by default since 0.2.8 (#4402), On writes STRATA_ROUTE_PRIOR=1.5' , () => { 43const ids = context => speedSwitchRows ({}, context ). map ( r => r . id ); 44assert . deepEqual ( ids ({ backend :'cuda' , gpus :[ RTX3060 ] }), [ 'faster_long_prompts' , 'faster_12gb_nvidia' ]); 45assert . deepEqual ( ids ({ backend :'cuda' , gpus :[{ ...RTX3060 , vram_gb :13 }] }), [ 'faster_long_prompts' , 'faster_12gb_nvidia' ], '13 GiB counts' ); 46assert . deepEqual ( ids ({ backend :'cuda' , gpus :[{ ...RTX3060 , vram_gb :13.5 }] }), [ 'faster_long_prompts' ]); 47assert . deepEqual ( ids ({ backend :'cuda' , gpus :[{ ...RTX3060 , vram_gb :16 }] }), [ 'faster_long_prompts' ], 'a 16 GB card is not a 12 GB card' ); 48assert . deepEqual ( ids ({ backend :'cuda' , gpus :[ RTX ] }), [ 'faster_long_prompts' ]); 49assert . deepEqual ( ids ({ backend :'cuda' , gpus :[ RTX , RTX3060 ] }), [ 'faster_long_prompts' , 'faster_12gb_nvidia' ], 'one small card among others' ); 50assert . deepEqual ( ids ({ backend :'cuda' , gpus :[{ ...RTX3060 , uma :true }] }), [ 'faster_long_prompts' ], 'not a chip that shares system memory' ); 51assert . deepEqual ( ids ({ backend :'cuda' , gpus :[{ ...RTX3060 , integrated :true }] }), [ 'faster_long_prompts' ]); 52assert . deepEqual ( ids ({ backend :'cuda' , gpus :[{ ...RTX3060 , usable :false }] }), [ 'faster_long_prompts' ]); 53assert . deepEqual ( ids ({ backend :'cuda' , gpus :[{ name :'GeForce RTX 3060' , vram_gb :12 }] }), [ 'faster_long_prompts' , 'faster_12gb_nvidia' ], 'no vendor reported: the name decides' ); 54assert . deepEqual ( ids ({ backend :'cuda' , gpus :[{ name :'Mystery card' , vram_gb :12 }] }), [ 'faster_long_prompts' ]); 55assert . deepEqual ( ids ({ backend :'hip' , gpus :[{ name :'AMD Radeon RX 7700 XT' , vendor :'amd' , arch :'gfx1101' , vram_gb :12 }] }), [ 'faster_long_prompts' ], 'not a Radeon' ); 56assert . deepEqual ( ids ({ backend :'sycl' , gpus :[ RTX3060 ] }), [], 'not a CUDA build' ); 57assert . deepEqual ( ids ({ backend :'cuda' , gpus :[ RTX3060 ], arch :'qwen35moe' }), [], 'Qwen3.6-35B-A3B: the routing needs 512 experts' ); 58assert . deepEqual ( ids ({ deepseek :true , backend :'cuda' , gpus :[ RTX3060 ] }), [], 'a DeepSeek settings file (no longer run): no switch' ); 59// a default launch carries nothing: the engine then runs as 0.2.6 did (STRATA_ROUTE_PRIOR unset = 0) 60assert . equal ( speedSwitchIsOn ({}, 'faster_12gb_nvidia' ), false ); 61assert . equal ( speedSwitchRows ({}, { backend :'cuda' , gpus :[ RTX3060 ] }). find ( r => r . id === 'faster_12gb_nvidia' ). on , false ); 62assert . deepEqual ( setSpeedSwitch ({ PATH :'/bin' }, 'faster_12gb_nvidia' , false ), { PATH :'/bin' }, 'Off is the default: it writes nothing' ); 63// the explicit opt-in the row writes 64const on = setSpeedSwitch ({ PATH :'/bin' }, 'faster_12gb_nvidia' , true ); 65assert . deepEqual ( on , { PATH :'/bin' , STRATA_ROUTE_PRIOR :'1.5' }); 66assert . equal ( speedSwitchIsOn ( on , 'faster_12gb_nvidia' ), true ); 67assert . deepEqual ( setSpeedSwitch ( on , 'faster_12gb_nvidia' , false ), { PATH :'/bin' }, 'back to Off removes the entry' ); 68// the 0.2.7 "Off" wrote STRATA_ROUTE_PRIOR=0: that file is in the default state now, and On replaces it with 1.5 69assert . equal ( speedSwitchIsOn ({ STRATA_ROUTE_PRIOR :'0' }, 'faster_12gb_nvidia' ), false ); 70assert . deepEqual ( setSpeedSwitch ({ STRATA_ROUTE_PRIOR :'0' }, 'faster_12gb_nvidia' , true ), { STRATA_ROUTE_PRIOR :'1.5' }); 71assert . deepEqual ( setSpeedSwitch ({ STRATA_ROUTE_PRIOR :'0' }, 'faster_12gb_nvidia' , false ), {}, 'and Off clears it' ); 72// the words say both sides 73const hint = SPEED_SWITCHES . find ( s => s . id === 'faster_12gb_nvidia' ). hint ; 74assert . match ( hint , / faster on 12 GB cards / ); 75assert . match ( hint , / Off by default / ); 76assert . match ( hint , / long agent sessions it can repeat itself / ); 77}); 78 79test ( 'a default launch has none of the new environment entries: KVA reads as off, the others as on, and an environment in its default stays as it is' , () => { 80for ( const sw of SPEED_SWITCHES ) assert . equal ( speedSwitchIsSet ({}, sw . id ), false ); 81const env = { PATH :'/native/bin' , STRATA_PREFILL :'2' }; 82for ( const sw of SPEED_SWITCHES ) assert . deepEqual ( setSpeedSwitch ( env , sw . id , sw . default === 'on' ), env , 'the default state removes nothing that is not the switch\'s' ); 83const rows = speedSwitchRows ({}, { backend :'hip' , gpus :[ R9700 ] }); 84assert . deepEqual ( rows . map ( r => [ r . id , r . on ]), [[ 'faster_long_prompts' , false ], [ 'faster_radeon_9000' , true ]]); 85assert . deepEqual ( rows . map ( r => r . default ), [ 'off' , 'on' ]); 86}); 87 88test ( 'Faster long prompts: On writes STRATA_KVA=1, Off removes it, and an earlier test build\'s STRATA_KVA=0 shows as Off' , () => { 89const env = { PATH :'/native/bin' }; 90assert . deepEqual ( setSpeedSwitch ( env , 'faster_long_prompts' , true ), { PATH :'/native/bin' , STRATA_KVA :'1' }); 91assert . deepEqual ( setSpeedSwitch ({ ...env , STRATA_KVA :'1' }, 'faster_long_prompts' , false ), env ); 92assert . equal ( speedSwitchIsOn ({ STRATA_KVA :'1' }, 'faster_long_prompts' ), true ); 93assert . equal ( speedSwitchIsOn ({ STRATA_KVA :'0' }, 'faster_long_prompts' ), false , 'stored by the off switch of an earlier build: harmless, and Off is what it is now' ); 94assert . equal ( speedSwitchIsOn ({}, 'faster_long_prompts' ), false ); 95assert . deepEqual ( setSpeedSwitch ({ ...env , STRATA_KVA :'0' }, 'faster_long_prompts' , false ), env , 'choosing Off again cleans it up' ); 96assert . deepEqual ( speedSwitchRows ({ STRATA_KVA :'0' }, { backend :'cuda' , gpus :[ RTX ] }). map ( r => [ r . id , r . on ]), [[ 'faster_long_prompts' , false ]]); 97}); 98 99test ( 'each switch outside its default yields exactly its entries and nothing else; back in the default gives back the same environment' , () => { 100const env = { PATH :'/native/bin' , STRATA_PREFILL :'2' }; 101for ( const sw of SPEED_SWITCHES ) { 102const other = setSpeedSwitch ( env , sw . id , sw . default !== 'on' ); // the non-default state: KVA on, the others off 103assert . deepEqual ( other , { ...env , ...ENV [ sw . id ] }, sw . id ); 104assert . equal ( speedSwitchIsSet ( other , sw . id ), true ); 105assert . equal ( speedSwitchIsOn ( other , sw . id ), sw . default !== 'on' ); 106for ( const another of SPEED_SWITCHES ) if ( another . id !== sw . id ) assert . equal ( speedSwitchIsSet ( other , another . id ), false , ` ${ sw . id } does not touch ${ another . id } ` ); 107const back = setSpeedSwitch ( other , sw . id , sw . default === 'on' ); 108assert . deepEqual ( back , env , sw . id ); 109assert . equal ( JSON . stringify ( back ), JSON . stringify ( env ), 'byte for byte, key order included' ); 110} 111assert . throws (() => setSpeedSwitch ({}, 'nothing' , false ), / Unknown speed switch / ); 112}); 113 114test ( 'a hand-edited file with only some of a switch\'s entries reads as its default and is left alone by an unchanged save' , () => { 115const partial = { STRATA_VISION_TOWER :'other' }; 116assert . equal ( speedSwitchIsOn ( partial , 'picture_reader' ), true ); 117assert . deepEqual ( setSpeedSwitch ( partial , 'faster_long_prompts' , false ), partial ); 118assert . equal ( speedSwitchIsOn ({ STRATA_KVA :'yes' }, 'faster_long_prompts' ), false , 'only 1 turns it on' ); 119}); 120 121test ( 'a switch shows only where it applies: Qwen on CUDA or HIP, Qwen on a Radeon RX 9000 / R9700; none for a DeepSeek settings file' , () => { 122const ids = context => speedSwitchRows ({}, context ). map ( r => r . id ); 123assert . deepEqual ( ids ({ backend :'cuda' , gpus :[ RTX ] }), [ 'faster_long_prompts' ]); 124assert . deepEqual ( ids ({ backend :'hip' , gpus :[ RX7900 ] }), [ 'faster_long_prompts' ]); 125assert . deepEqual ( ids ({ backend :'hip' , gpus :[ STRIX ] }), [ 'faster_long_prompts' ], 'Strix Halo (gfx1151) is not gfx12' ); 126assert . deepEqual ( ids ({ backend :'hip' , gpus :[ R9700 ] }), [ 'faster_long_prompts' , 'faster_radeon_9000' ]); 127assert . deepEqual ( ids ({ backend :'hip' , gpus :[{ name :'AMD Radeon RX 9070 XT' , vendor :'amd' }] }), [ 'faster_long_prompts' , 'faster_radeon_9000' ], 'no arch reported: the card name decides' ); 128assert . deepEqual ( ids ({ backend :'hip' , gpus :[{ name :'AMD Radeon RX 7900 XT' , vendor :'amd' }] }), [ 'faster_long_prompts' ]); 129assert . deepEqual ( ids ({ backend :'cuda' , gpus :[ RTX , R9700 ] }), [ 'faster_long_prompts' ], 'the Radeon switch needs the HIP engine' ); 130for ( const backend of [ 'sycl' , 'metal' , 'cpu' , null ]) assert . deepEqual ( ids ({ backend, gpus :[ R9700 ] }), [], `Qwen on ${ backend } ` ); 131assert . deepEqual ( ids ({ deepseek :true , backend :'hip' , gpus :[ R9700 ] }), [], 'a DeepSeek settings file (no longer run): no switch' ); 132assert . deepEqual ( ids ({ deepseek :true , backend :'cuda' , gpus :[ RTX ] }), []); 133assert . deepEqual ( ids ({}), [], 'nothing is known: nothing is offered' ); 134}); 135 136test ( 'Faster long prompts is for Qwen3.8-Flash-Next only: no row for Qwen3.6-35B-A3B (a run config with an arch)' , () => { 137const ids = context => speedSwitchRows ({}, context ). map ( r => r . id ); 138assert . deepEqual ( ids ({ backend :'cuda' , gpus :[ RTX ], arch :null }), [ 'faster_long_prompts' ], 'Flash-Next files have no arch' ); 139assert . deepEqual ( ids ({ backend :'cuda' , gpus :[ RTX ], arch :'qwen35moe' }), [], 'Qwen3.6-35B-A3B on CUDA' ); 140assert . deepEqual ( ids ({ backend :'hip' , gpus :[ RX7900 ], arch :'qwen35moe' }), [], 'and on HIP' ); 141assert . deepEqual ( ids ({ backend :'hip' , gpus :[ R9700 ], arch :'qwen35moe' }), [ 'faster_radeon_9000' ], 'the Radeon switch is not tied to the model\'s shape' ); 142assert . equal ( speedSwitchApplies ( 'faster_long_prompts' , { backend :'cuda' , gpus :[ RTX ], arch :'qwen35moe' }), false ); 143}); 144 145test ( 'the picture reader: offered for a Qwen model that reads pictures, in the Image reading group, with Strata\'s own and llama.cpp\'s as the two options' , () => { 146const ids = context => speedSwitchRows ({}, context ). map ( r => r . id ); 147for ( const backend of [ 'cuda' , 'hip' , 'sycl' , 'metal' , 'cpu' , null ]) assert . ok ( ids ({ backend, gpus :[ R9700 ], vision :true }). includes ( 'picture_reader' ), ` ${ backend } ` ); 148assert . ok ( ! ids ({ backend :'cuda' , gpus :[ RTX ] }). includes ( 'picture_reader' ), 'pictures off' ); 149assert . ok ( ! ids ({ deepseek :true , backend :'cuda' , gpus :[ RTX ], vision :true }). includes ( 'picture_reader' ), 'a DeepSeek settings file: no switch' ); 150const sw = SPEED_SWITCHES . find ( s => s . id === 'picture_reader' ); 151assert . deepEqual ([ sw . group , sw . default , sw . words ], [ 'Image reading' , 'on' , { on :'Strata\'s own (recommended)' , off :'llama.cpp\'s' }]); 152assert . deepEqual ( setSpeedSwitch ({ PATH :'/bin' }, 'picture_reader' , false ), { PATH :'/bin' , STRATA_VISION_TOWER :'mtmd' }); 153assert . deepEqual ( setSpeedSwitch ({ PATH :'/bin' , STRATA_VISION_TOWER :'mtmd' }, 'picture_reader' , true ), { PATH :'/bin' }); 154const screen = read ( '../src/components/NativeSettings.tsx' ); 155assert . match ( screen , / options=\{sw\.words \? \[\{ value: sw\.default, label: sw\.words\[sw\.default\] \} / , 'the two option names, the default first' ); 156assert . match ( screen , / \{tr\(switchRows\.filter\(sw => switchGroup\(sw\) === group\)\.map\(switchRow\)\)\}<\/section> / , 'a switch of a field group is shown in that group' ); 157}); 158 159test ( 'the environment names round-trip through the validator, the public view and the restore, and other names stay untouched' , () => { 160const all = Object . assign ({}, ...Object . values ( ENV )); 161assert . deepEqual ( validateNativeSettings ({ env :all }), { env :all }); 162assert . throws (() => validateNativeSettings ({ env :{ HOME :'/tmp' } })); 163assert . throws (() => validateNativeSettings ({ env :{ DS4_FAST_ATTN :'0' } }), undefined , 'the DeepSeek engine\'s names are no longer shown or edited' ); 164const previous = { PATH :'/native/bin' , HIP_VISIBLE_DEVICES :'0' , ...all }; 165assert . deepEqual ( publicNativeEnv ( previous ), all ); 166assert . deepEqual ( restoreNativeEnv ({}, previous ), { PATH :'/native/bin' , HIP_VISIBLE_DEVICES :'0' }, 'every switch back in its default removes only theirs' ); 167assert . deepEqual ( restoreNativeEnv ( all , { PATH :'/native/bin' }), { PATH :'/native/bin' , ...all }); 168}); 169 170function setConfig ( f , model , patch ) { 171const path = join ( f . repo , `strata- ${ model } .json` ); 172writeFileSync ( path , JSON . stringify ({ ...JSON . parse ( readFileSync ( path , 'utf8' )), ...patch })); 173return path ; 174} 175 176test ( 'through the host: the settings answer lists the switches that apply, and KVA on then off gives back the same file' , async () => { 177const f = nativeFixture (); 178try { 179f . setHardware ({ ram_gb :64 , gpus :[ R9700 ] }); 180const path = setConfig ( f , 'iq2_xs' , { backend :'hip' }); 181await f . control . refresh (); 182const before = readFileSync ( path , 'utf8' ); 183const first = f . control . settings ( 'iq2_xs' ); 184assert . deepEqual ( speed ( first . speedSwitches ). map ( s => [ s . id , s . on ]), [[ 'faster_long_prompts' , false ], [ 'faster_radeon_9000' , true ]]); 185assert . deepEqual ( speed ( first . speedSwitches ). map ( s => [ s . default , s . env ]), [[ 'off' , ENV . faster_long_prompts ], [ 'on' , ENV . faster_radeon_9000 ]], 'the client writes what the host says' ); 186assert . equal ( 'STRATA_KVA' in first . values . env , false , 'default: nothing in the environment' ); 187 188// the client turns "Faster long prompts" on: it sends the environment with the entry added 189const off = f . control . save ( 'iq2_xs' , { values :{ env :{ ...first . values . env , ...ENV . faster_long_prompts } } }); 190const file = JSON . parse ( readFileSync ( path , 'utf8' )); 191assert . equal ( file . env . STRATA_KVA , '1' ); 192assert . equal ( file . env . PATH , '/native/bin' ); 193assert . equal ( file . env . STRATA_TOKEN , 'private' , 'a credential is kept, not lost behind its mask' ); 194assert . equal ( 'STRATA_PCIE_FRAC_DEFAULT' in file . env , false ); 195assert . deepEqual ( speed ( off . speedSwitches ). map ( s => [ s . id , s . on ]), [[ 'faster_long_prompts' , true ], [ 'faster_radeon_9000' , true ]]); 196 197// and Off again: the entry is gone and the file is as it was 198const env = { ...off . values . env }; 199delete env . STRATA_KVA ; 200const on = f . control . save ( 'iq2_xs' , { values :{ env} }); 201assert . deepEqual ( speed ( on . speedSwitches ). map ( s => s . on ), [ false , true ]); 202const after = JSON . parse ( readFileSync ( path , 'utf8' )); 203assert . deepEqual ( after , JSON . parse ( before )); 204assert . equal ( JSON . stringify ( after . env ), JSON . stringify ( JSON . parse ( before ). env ), 'the same environment, same order' ); 205} finally { await f . cleanup (); } 206}); 207 208test ( 'through the host: Qwen3.6-35B-A3B (its run config has an arch) gets no Faster long prompts row, a Flash-Next model does' , async () => { 209const f = nativeFixture (); 210try { 211f . setHardware ({ ram_gb :64 , gpus :[ RTX ] }); 212setConfig ( f , 'iq2_xs' , { backend :'cuda' }); 213setConfig ( f , 'iq3_s' , { backend :'cuda' , arch :'qwen35moe' , model_name :'qwen3.6-35b-a3b-ud-q4_k_xl' }); 214await f . control . refresh (); 215assert . deepEqual ( f . control . settings ( 'iq2_xs' ). speedSwitches . map ( s => s . id ), [ 'faster_long_prompts' , 'picture_reader' ]); 216assert . deepEqual ( f . control . settings ( 'iq3_s' ). speedSwitches . map ( s => s . id ), [ 'picture_reader' ], 'Qwen3.6 reads pictures with the same reader' ); 217} finally { await f . cleanup (); } 218}); 219 220test ( 'through the host: choosing llama.cpp\'s picture reader writes STRATA_VISION_TOWER=mtmd into the model\'s file, and Strata\'s own again gives back the same file' , async () => { 221const f = nativeFixture (); 222try { 223f . setHardware ({ ram_gb :64 , gpus :[ RTX ] }); 224const path = setConfig ( f , 'iq2_xs' , { backend :'cuda' }); 225await f . control . refresh (); 226const before = readFileSync ( path , 'utf8' ); 227const first = f . control . settings ( 'iq2_xs' ); 228const row = first . speedSwitches . find ( s => s . id === 'picture_reader' ); 229assert . deepEqual ([ row . on , row . group , row . words . on , row . words . off ], [ true , 'Image reading' , 'Strata\'s own (recommended)' , 'llama.cpp\'s' ]); 230const picked = f . control . save ( 'iq2_xs' , { values :{ env :{ ...first . values . env , ...ENV . picture_reader } } }); 231assert . equal ( JSON . parse ( readFileSync ( path , 'utf8' )). env . STRATA_VISION_TOWER , 'mtmd' ); 232assert . equal ( picked . speedSwitches . find ( s => s . id === 'picture_reader' ). on , false ); 233const env = { ...picked . values . env }; 234delete env . STRATA_VISION_TOWER ; 235f . control . save ( 'iq2_xs' , { values :{ env} }); 236assert . deepEqual ( JSON . parse ( readFileSync ( path , 'utf8' )), JSON . parse ( before )); 237} finally { await f . cleanup (); } 238}); 239 240test ( 'through the host: a Qwen model on a PC the engine cannot speed up offers no switch (SYCL, a Mac, no card)' , async () => { 241const f = nativeFixture (); 242try { 243f . setHardware ({ ram_gb :32 , gpus :[{ index :0 , name :'Intel Arc A750' , vendor :'intel' , vram_gb :8 }] }); 244setConfig ( f , 'iq2_xs' , { backend :'sycl' }); 245await f . control . refresh (); 246assert . deepEqual ( f . control . settings ( 'iq2_xs' ). speedSwitches . map ( s => s . id ), [ 'picture_reader' ], 'no speed switch; the picture reader row is there for a model that reads pictures' ); 247} finally { await f . cleanup (); } 248}); 249 250test ( 'the Expert settings show the rows in the existing row layout with an On / Off choice (Off recommended for KVA), and the words are in all nine languages' , () => { 251const screen = read ( '../src/components/NativeSettings.tsx' ); 252assert . match ( screen , / <h3 className="h4">\{tr\("Speed"\)\}<\/h3> / ); 253assert . match ( screen , / <label className="native-setting-row" key=\{sw\.id\}><span><strong>\{tr\(sw\.label\)\}<\/strong><small>\{tr\(sw\.hint\)\}<\/small><\/span><Select / , 'the same row, the same Select' ); 254assert . match ( screen , / \[\{ value: 'on', label: 'On \(recommended\)' \}, \{ value: 'off', label: 'Off' \}\] : \[\{ value: 'off', label: 'Off \(recommended\)' \}, \{ value: 'on', label: 'On' \}\] / ); 255assert . match ( screen , / if \(write\) env\[name\] = value; else delete env\[name\]; / , 'the default removes the entries' ); 256const languages = [ 'en' , 'zh' , 'ja' , 'de' , 'es' , 'ru' , 'pt' , 'ko' , 'fr' ]; 257const catalog = lang => JSON . parse ( read ( `../src/locales/fix- ${ lang } .json` )); 258const words = [ ...SPEED_SWITCHES . flatMap ( s => [ s . label , s . hint , ...Object . values ( s . words ?? {})]), 'On (recommended)' , 'Off (recommended)' ]; 259const english = Object . values ( catalog ( 'en' )); 260for ( const word of words ) assert . ok ( english . includes ( word ), `English catalog: ${ word } ` ); 261for ( const lang of languages . slice ( 1 )) { 262const translated = Object . values ( catalog ( lang )); 263const en = catalog ( 'en' ); 264for ( const [ id , text ] of Object . entries ( en )) if ( words . includes ( text )) { 265assert . ok ( catalog ( lang )[ id ] && catalog ( lang )[ id ] !== text , ` ${ lang } ${ id } is translated` ); 266assert . ok ( translated . includes ( catalog ( lang )[ id ])); 267assert . ok ( ! /\{\d + \} / . test ( catalog ( lang )[ id ])); 268} 269} 270}); 271 272test ( 'the effect texts say what the feature does and what the other choice costs, in plain words' , () => { 273for ( const sw of SPEED_SWITCHES ) { 274assert . ok ( sw . words ?sw . hint . includes ( `Choose ${ sw . words . off } ` ) :sw . default === 'off' ?/ Off by default / . test ( sw . hint ) :/ [ Tt ] urn off / . test ( sw . hint ), sw . id ); 275assert . ok ( sw . hint . length < ( sw . id === 'picture_reader' ?300 :260 ), sw . id ); // the picture reader: the owner's approved help line (11-11), 275 characters 276assert . ok ( ! /STRATA_ | DS4_ | env | -- / . test ( sw . hint ), 'no flags or variable names for a non-technical reader' ); 277} 278assert . equal ( SPEED_SWITCHES [ 0 ]. hint , 'Reads very long prompts faster by approximating part of the work. Off by default: answers about long documents can miss or mix up details.' ); 279});