Merge f-027-kvaoff (KVA is off by default: the app's and the Terminal's 'Faster long prompts' switch turns it on, shown for Qwen3.8-Flash-Next models only)
This commit is contained in:
commit
aeb70de349
15 files changed
+248
-144
No files matched your search
@@ -151,7 +151,7 @@ export function createNativeControl({directory,requests=()=>[],changed=()=>{},sp
|
||||
async function openSettingsFile(model,options={}){const info=settingsFile(model);await openTextFile(info.path,options);return info;}
|
||||
/* A mistake in the file holds the start back with the line, instead of an engine that dies on it. Warnings (an unknown key) never do. */
|
||||
function assertSettingsFile(path){const check=checkRunConfig(readFileSync(path,'utf8'));if(!check.ok)throw new Error(`The settings file for this model has a mistake, so the model was not started. ${describeIssues(check.issues,'error').join(' ')}`);}
|
||||
function settings(model){const {entry,config}=record(model);const values=Object.fromEntries(NATIVE_FIELDS.map(f=>[f.id,config[f.id]??null]));if(typeof values.aliases==='string')values.aliases=values.aliases.split(',').map(v=>v.trim()).filter(Boolean);values.sampling=config.sampling??{};values.args=config.args??[];values.env=publicNativeEnv(config.env??{});return {model,values,mcp:publicMcpServers(config.mcp_servers??config.mcpServers??{}),restartNeeded:true,capabilities:{dsExperts:ownEngine(config)&&dsExpertsSupported(config)},speedSwitches:speedSwitchRows(config.env??{},{deepseek:ownEngine(config),backend:config.backend??entry?.backend??snapshot.installed?.engine?.backend??null,gpus:snapshot.hardware?.gpus??[]})};}
|
||||
function settings(model){const {entry,config}=record(model);const values=Object.fromEntries(NATIVE_FIELDS.map(f=>[f.id,config[f.id]??null]));if(typeof values.aliases==='string')values.aliases=values.aliases.split(',').map(v=>v.trim()).filter(Boolean);values.sampling=config.sampling??{};values.args=config.args??[];values.env=publicNativeEnv(config.env??{});return {model,values,mcp:publicMcpServers(config.mcp_servers??config.mcpServers??{}),restartNeeded:true,capabilities:{dsExperts:ownEngine(config)&&dsExpertsSupported(config)},speedSwitches:speedSwitchRows(config.env??{},{deepseek:ownEngine(config),arch:config.arch??null,backend:config.backend??entry?.backend??snapshot.installed?.engine?.backend??null,gpus:snapshot.hardware?.gpus??[]})};}
|
||||
function save(model,{values,mcp}){if([...jobs.values()].some(j=>j.state==='running'))throw new Error('Finish the current operation before saving native settings.');const {path,config}=record(model);if(busy(requests().filter(r=>instances.get(r.instanceId)?.model===model)))throw new Error('Finish this model’s requests before saving its settings.');const patch=validateNativeSettings(values??{}),next={...config};if(patch.ds_experts!=null&&!dsExpertsSupported(config))throw new Error('The Speed choice needs the newer DeepSeek engine. Update the engine in Settings, then choose it.');for(const field of nativeFields())if(field.supported===false&&patch[field.id]!=null&&JSON.stringify(patch[field.id])!==JSON.stringify(config[field.id]))throw new Error(`${field.label} needs a newer native Strata installation. Update it in Settings → About.`);for(const [key,value] of Object.entries(patch)){if(key==='env')next.env=restoreNativeEnv(value,config.env??{});else if(value===null)delete next[key];else next[key]=value;}if('vram_reserve_mib' in patch){const base=captureUserArgs(next);const mine=setUserFlag(base,'--vram-reserve-mib',patch.vram_reserve_mib);if(mine.length)next[USER_KEY]=mine;else delete next[USER_KEY];next.args=mine.length&&patch.vram_reserve_mib!==null?mergeUserArgs(next.args??[],mine):setUserFlag(next.args??[],'--vram-reserve-mib',null);delete next.ui_reserve_applied;if(Array.isArray(next.args_written))next.args_written=[...next.args];}if(mcp!==undefined){next.mcp_servers=validateMcpServers(mcp,config.mcp_servers??config.mcpServers??{});delete next.mcpServers;}copyFileSync(path,path+'.bak');chmodSync(path+'.bak',0o600);const temp=path+'.ui-tmp';writeFileSync(temp,JSON.stringify(next,null,2)+'\n',{mode:0o600});renameSync(temp,path);return settings(model);}
|
||||
function previousEngine(){if(packaged)return !!snapshot.engine?.previous;try{const data=snapshot.installed?.data_dir??snapshot.installed?.data_folder;return [join(preferences.repo,'engine/.previous'),data&&join(data,'engine/.previous')].filter(Boolean).some(existsSync)&&readFileSync(join(preferences.repo,'setup.py'),'utf8').includes('--rollback-engine');}catch{return false;}}
|
||||
async function plan(args){await refresh();if(!snapshot.available)throw new Error(snapshot.error);const result=await tool('strata_install',installArgs(args,false));
|
||||
|
||||
@@ -29,40 +29,48 @@ export const NATIVE_FIELDS=[
|
||||
/** Engine environment names the app shows and edits: STRATA_* and the DeepSeek engine's DS4_*. Any other name in a model's file is kept untouched and not shown. */
|
||||
export const ENV_FLAG=/^(?:STRATA|DS4)_[A-Z0-9_]+$/;
|
||||
/**
|
||||
* The three speed features that are on by default in 0.2.7 and have an off switch in Expert settings. Each switch, when off, writes exactly the
|
||||
* environment entries below into the model's settings file ("env"); turning it on again removes them, so a default launch carries none of them.
|
||||
* The names are the engine switch contract (phaseA-tests/notes-027-plan.md); strata_control/speed_switches.py says the same for the Terminal
|
||||
* (tests/terminal/test_speed_switches.py compares the two).
|
||||
* The speed features of 0.2.7 that have a switch in Expert settings. A switch has a default ('on' or 'off'); outside it, it writes exactly the
|
||||
* environment entries `env` into the model's settings file ("env"); back in its default it removes them, so a default launch carries none of them.
|
||||
* "Faster long prompts" (Qwen KVA) is OFF by default (owner decision, 26 October): STRATA_KVA=1 turns it on, and an earlier test build's STRATA_KVA=0 reads as off.
|
||||
* The other two are on by default. The names are the engine switch contract (phaseA-tests/notes-027-plan.md); strata_control/speed_switches.py says the
|
||||
* same for the Terminal (tests/terminal/test_speed_switches.py compares the two).
|
||||
*/
|
||||
export const SPEED_SWITCHES=[
|
||||
{id:'faster_long_prompts',label:'Faster long prompts',group:'Speed',
|
||||
hint:'Reads long prompts faster by approximating part of the work. Turn off if answers about long documents look wrong.',
|
||||
off:{STRATA_KVA:'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.',
|
||||
default:'off',env:{STRATA_KVA:'1'}},
|
||||
{id:'faster_radeon_9000',label:'Faster answers on Radeon RX 9000 / AI PRO R9700',group:'Speed',
|
||||
hint:'Shares the work between the graphics card and the processor in a way that makes answers faster on these cards. Turn off to go back to the previous setting, which is slower.',
|
||||
off:{STRATA_PCIE_FRAC_DEFAULT:'old'}},
|
||||
default:'on',env:{STRATA_PCIE_FRAC_DEFAULT:'old'}},
|
||||
{id:'deepseek_speedups',label:'DeepSeek speed-ups',group:'Speed',
|
||||
hint:'Reads long prompts faster and loads the parts of the model it needs faster. Turn off if DeepSeek stops working or its answers look wrong; it then runs as in version 0.2.6.',
|
||||
off:{DS4_FAST_ATTN:'0',DS4_ATTN_SLAB:'0',DS4_COPY_PIN:'0',DS4_COPY_HUGETLB:'0',DS4_STORE_SPARE:'0',DS4_STORE_PUT:'0'}},
|
||||
default:'on',env:{DS4_FAST_ATTN:'0',DS4_ATTN_SLAB:'0',DS4_COPY_PIN:'0',DS4_COPY_HUGETLB:'0',DS4_STORE_SPARE:'0',DS4_STORE_PUT:'0'}},
|
||||
];
|
||||
const GFX12=/^gfx120[01]$/i, RADEON_9000=/\b(?:RX\s*9\d{3}|AI\s*PRO\s*R97\d{2}|R97\d{2})\b/i;
|
||||
/** Which switches make sense for this model on this PC: only those are shown. `backend` is the engine's (cuda, hip, sycl, metal, cpu). */
|
||||
export function speedSwitchApplies(id,{deepseek=false,backend=null,gpus=[]}={}){
|
||||
/**
|
||||
* Which switches make sense for this model on this PC: only those are shown. `backend` is the engine's (cuda, hip, sycl, metal, cpu). `arch` is the "arch"
|
||||
* of the model's run config: setup writes it only for the families with an engine path of their own (Qwen3.6-35B-A3B "qwen35moe", DeepSeek "deepseek41");
|
||||
* the Qwen3.8-Flash-Next files (the original, Swift, Coder, Unsloth, Gyro, NVFP4) have none. KVA was measured on the Flash-Next shape (48 layers, 512
|
||||
* experts) and the engine declines it on any other, so "Faster long prompts" is shown for a model without an "arch" only.
|
||||
*/
|
||||
export function speedSwitchApplies(id,{deepseek=false,backend=null,gpus=[],arch=null}={}){
|
||||
if(id==='deepseek_speedups')return !!deepseek;
|
||||
if(deepseek)return false; // the Qwen engine's switches
|
||||
if(id==='faster_long_prompts')return backend==='cuda'||backend==='hip';
|
||||
if(id==='faster_long_prompts')return !arch&&(backend==='cuda'||backend==='hip');
|
||||
if(id==='faster_radeon_9000')return backend==='hip'&&(gpus??[]).some(g=>(!g.vendor||g.vendor==='amd')&&(GFX12.test(String(g.arch??''))||(!g.arch&&RADEON_9000.test(String(g.name??'')))));
|
||||
return false;
|
||||
}
|
||||
/** A switch is off when every entry it writes is in the environment with its value; anything less (a hand-edited file) reads as on and is left alone. */
|
||||
export function speedSwitchIsOff(env,id){const sw=SPEED_SWITCHES.find(s=>s.id===id);return !!sw&&Object.entries(sw.off).every(([name,value])=>env?.[name]===value);}
|
||||
/** The environment with the switch turned off (its entries written) or on (its entries removed). Nothing else in it changes. */
|
||||
/** The switch is outside its default when every entry it writes is in the environment with its value; anything less or other (a hand-edited file, STRATA_KVA=0) is the default state and is left alone. */
|
||||
export function speedSwitchIsSet(env,id){const sw=SPEED_SWITCHES.find(s=>s.id===id);return !!sw&&Object.entries(sw.env).every(([name,value])=>env?.[name]===value);}
|
||||
/** Is the feature on for a launch with this environment? */
|
||||
export function speedSwitchIsOn(env,id){const sw=SPEED_SWITCHES.find(s=>s.id===id);return !!sw&&speedSwitchIsSet(env,id)!==(sw.default==='on');}
|
||||
/** The environment with the feature on or off: its default removes the switch's entries, the other state writes them. Nothing else in it changes. */
|
||||
export function setSpeedSwitch(env,id,on){
|
||||
const sw=SPEED_SWITCHES.find(s=>s.id===id);if(!sw)throw new Error(`Unknown speed switch: ${id}`);
|
||||
const next={...(env??{})};for(const [name,value] of Object.entries(sw.off)){if(on)delete next[name];else next[name]=value;}return next;
|
||||
const write=on!==(sw.default==='on'),next={...(env??{})};for(const [name,value] of Object.entries(sw.env)){if(write)next[name]=value;else delete next[name];}return next;
|
||||
}
|
||||
/** What the settings answer carries: each switch that applies, with its words, the entries it writes when off, and whether it is on. */
|
||||
export function speedSwitchRows(env,context){return SPEED_SWITCHES.filter(s=>speedSwitchApplies(s.id,context)).map(s=>({...s,on:!speedSwitchIsOff(env,s.id)}));}
|
||||
/** What the settings answer carries: each switch that applies, with its words, its default, the entries it writes outside the default, and whether the feature is on. */
|
||||
export function speedSwitchRows(env,context){return SPEED_SWITCHES.filter(s=>speedSwitchApplies(s.id,context)).map(s=>({...s,on:speedSwitchIsOn(env,s.id)}));}
|
||||
/** Settings the app itself applies when it starts a model (they are not read from the engine's source, so the engine's text never says it supports them). */
|
||||
export const APP_OWNED_FIELDS=['mtp','batchMtp','drafting','ds_experts'];
|
||||
/** The engine arguments without the draft layer: --mtp <folder or count>, --spec-min-p <p> (its confidence threshold) and --batch-mtp. --spec stays: prompt lookup still uses its windows. Same rule as strata_control/draft_layer.py. */
|
||||
|
||||
@@ -9,14 +9,16 @@ import { Btn, ErrorNotice, Select } from './ui';
|
||||
import { speedOptions } from '../lib/deepseek-speed';
|
||||
import type { RunCard } from '../lib/native-fit';
|
||||
import { NativeMcpEditor } from './NativeMcpEditor';
|
||||
/** One of the three speed features that are on by default: what it is called, what turning it off does, and the engine environment it writes when off (server/native-settings.mjs). */
|
||||
/** One of the speed features: what it is called, what it does, whether it is on by default, and the engine environment it writes outside its default (server/native-settings.mjs). */
|
||||
interface SpeedSwitch {
|
||||
id: string;
|
||||
label: string;
|
||||
hint: string;
|
||||
off: Record<string, string>;
|
||||
default: 'on' | 'off';
|
||||
env: Record<string, string>;
|
||||
}
|
||||
const switchIsOff = (sw: SpeedSwitch, env: Record<string, string> | undefined) => Object.entries(sw.off).every(([name, value]) => env?.[name] === value);
|
||||
const switchIsSet = (sw: SpeedSwitch, env: Record<string, string> | undefined) => Object.entries(sw.env).every(([name, value]) => env?.[name] === value);
|
||||
const switchIsOn = (sw: SpeedSwitch, env: Record<string, string> | undefined) => switchIsSet(sw, env) !== (sw.default === 'on');
|
||||
export function NativeSettings({ model }: {
|
||||
model: string;
|
||||
}) {
|
||||
@@ -58,8 +60,8 @@ export function NativeSettings({ model }: {
|
||||
return () => { active = false; };
|
||||
}, [model,revision]);
|
||||
const change = (id: string, value: any) => { const next = { ...values, [id]: value }; setValues(next); setText(JSON.stringify(next, null, 2)); setNotice(''); };
|
||||
/** On removes the switch's environment entries, off writes them: the model's file then carries nothing for a default launch. */
|
||||
const changeSwitch = (sw: SpeedSwitch, on: boolean) => { const env = { ...(values.env ?? {}) }; for (const [name, value] of Object.entries(sw.off)) { if (on) delete env[name]; else env[name] = value; } change('env', env); };
|
||||
/** The default removes the switch's environment entries, the other state writes them: the model's file then carries nothing for a default launch. */
|
||||
const changeSwitch = (sw: SpeedSwitch, on: boolean) => { const env = { ...(values.env ?? {}) }; const write = on !== (sw.default === 'on'); for (const [name, value] of Object.entries(sw.env)) { if (write) env[name] = value; else delete env[name]; } change('env', env); };
|
||||
async function save() {
|
||||
setPending(true);
|
||||
setError('');
|
||||
@@ -112,7 +114,7 @@ export function NativeSettings({ model }: {
|
||||
const rows = (native?.fields ?? []).filter(f => (!f.forModel || (model.toLowerCase().includes(f.forModel) && (f.id !== 'ds_experts' || dsExperts))) && `${tr(f.label)} ${f.id} ${tr(f.group)}`.toLowerCase().includes(query.toLowerCase()));
|
||||
const switchRows = switches.filter(sw => `${tr(sw.label)} ${sw.id} ${tr('Speed')}`.toLowerCase().includes(query.toLowerCase()));
|
||||
return <details className="native-settings"><summary>{tr("Native engine settings")}</summary>{tr(tuned?.changed?.length ? <div className="native-tuned"><p className="small"><strong>{tr("Your tuning '{0}' sets", [tuned.preset?.name ?? ''])}</strong></p><ul>{tuned.changed.map(c => { const d = describeChange(c); return <li key={c.flag}><span>{d.name}</span><b>{d.now || tr('off')}</b>{d.was !== null ? <small className="muted">{tr("was {0}", [d.was])}</small> : null}</li>; })}</ul></div> : null)}<p className="small muted">{tr(!original ? 'Reading saved settings… ' : '')}{tr("Settings for this model. Blank values use Strata\u2019s defaults.")}</p><div className="editor-tabs" role="tablist" aria-label={tr("Native settings editor")}>{tr(['fields', 'json', 'tools'].map(t => <button key={t} role="tab" aria-selected={tab === t} onClick={() => chooseTab(t)}>{tr(t === 'fields' ? 'Parameters' : t === 'json' ? 'JSON' : 'MCP tools')}</button>))}</div>
|
||||
{tr(tab === 'fields' ? <><input className="st-input" type="search" aria-label={tr("Search native parameters")} placeholder={tr("Search parameters…")} value={query} onChange={e => setQuery(e.target.value)}/>{tr(['Responses', 'GPU & memory', 'Serving', 'Image reading', 'Tools', 'Recovery'].map(group => rows.some(f => f.group === group) ? <section className="native-settings-group" key={group}><h3 className="h4">{tr(group)}</h3>{tr(rows.filter(f => f.group === group).map(f => <label className="native-setting-row" key={f.id}><span><strong>{tr(f.label)}</strong>{tr(f.supported === false ? <small>{tr("Requires a newer Strata installation.")}</small> : f.hint ? <small>{tr(f.hint)}</small> : null)}</span><NativeFieldInput field={f} value={values[f.id]} onChange={v => change(f.id, v)}/></label>))}</section> : null))}{tr(switchRows.length ? <section className="native-settings-group"><h3 className="h4">{tr("Speed")}</h3>{tr(switchRows.map(sw => <label className="native-setting-row" key={sw.id}><span><strong>{tr(sw.label)}</strong><small>{tr(sw.hint)}</small></span><Select ariaLabel={tr(sw.label)} value={switchIsOff(sw, values.env) ? 'off' : 'on'} options={[{ value: 'on', label: 'On (recommended)' }, { value: 'off', label: 'Off' }]} onChange={v => changeSwitch(sw, v === 'on')}/></label>))}</section> : null)}<section className="native-settings-group"><h3 className="h4">{tr("Sampling")}</h3>{tr([['temperature', 'Temperature'], ['top_p', 'Top-p'], ['top_k', 'Top-k'], ['min_p', 'Min-p'], ['repetition_penalty', 'Repetition penalty'], ['presence_penalty', 'Presence penalty'], ['frequency_penalty', 'Frequency penalty'], ['penalty_last_n', 'Penalty window'], ['seed', 'Seed']].map(([id, label]) => <label className="native-setting-row" key={id}><span><strong>{tr(label)}</strong></span><DecimalInput ariaLabel={tr("Native {0}", [label])} value={values.sampling?.[id] ?? null} onChange={n => { const sampling = { ...values.sampling }; if (n === null) delete sampling[id]; else sampling[id] = n; change('sampling', sampling); }}/></label>))}</section></> : tab === 'json' ? <><p className="small muted">{tr("Engine arguments and STRATA environment flags are editable here. Program paths and network access remain managed by the host.")}</p><textarea className="st-input native-json" aria-label={tr("Native configuration JSON")} spellCheck={false} value={text} onChange={e => { setText(e.target.value); setNotice(''); }}/></> : <><p className="small muted">{tr("Add local programs or HTTP MCP servers. Connected tools can read or change the resources you give them access to. Enable tools in chat when you want the model to use them.")}</p><NativeMcpEditor text={mcp} onChange={value => { setMcp(value); setNotice(''); }}/><details><summary className="small">{tr("Configuration example")}</summary><pre className="native-example">{'{\n "files": {\n "command": "npx",\n "args": ["-y", "@modelcontextprotocol/server-filesystem", "/your/folder"],\n "disabled": false\n }\n}'}</pre><p className="xs muted">{tr("Saved credentials are masked. Keep the mask to preserve an existing value; type a new value to replace it.")}</p></details></>)}
|
||||
{tr(tab === 'fields' ? <><input className="st-input" type="search" aria-label={tr("Search native parameters")} placeholder={tr("Search parameters…")} value={query} onChange={e => setQuery(e.target.value)}/>{tr(['Responses', 'GPU & memory', 'Serving', 'Image reading', 'Tools', 'Recovery'].map(group => rows.some(f => f.group === group) ? <section className="native-settings-group" key={group}><h3 className="h4">{tr(group)}</h3>{tr(rows.filter(f => f.group === group).map(f => <label className="native-setting-row" key={f.id}><span><strong>{tr(f.label)}</strong>{tr(f.supported === false ? <small>{tr("Requires a newer Strata installation.")}</small> : f.hint ? <small>{tr(f.hint)}</small> : null)}</span><NativeFieldInput field={f} value={values[f.id]} onChange={v => change(f.id, v)}/></label>))}</section> : null))}{tr(switchRows.length ? <section className="native-settings-group"><h3 className="h4">{tr("Speed")}</h3>{tr(switchRows.map(sw => <label className="native-setting-row" key={sw.id}><span><strong>{tr(sw.label)}</strong><small>{tr(sw.hint)}</small></span><Select ariaLabel={tr(sw.label)} value={switchIsOn(sw, values.env) ? 'on' : 'off'} options={sw.default === 'on' ? [{ value: 'on', label: 'On (recommended)' }, { value: 'off', label: 'Off' }] : [{ value: 'off', label: 'Off (recommended)' }, { value: 'on', label: 'On' }]} onChange={v => changeSwitch(sw, v === 'on')}/></label>))}</section> : null)}<section className="native-settings-group"><h3 className="h4">{tr("Sampling")}</h3>{tr([['temperature', 'Temperature'], ['top_p', 'Top-p'], ['top_k', 'Top-k'], ['min_p', 'Min-p'], ['repetition_penalty', 'Repetition penalty'], ['presence_penalty', 'Presence penalty'], ['frequency_penalty', 'Frequency penalty'], ['penalty_last_n', 'Penalty window'], ['seed', 'Seed']].map(([id, label]) => <label className="native-setting-row" key={id}><span><strong>{tr(label)}</strong></span><DecimalInput ariaLabel={tr("Native {0}", [label])} value={values.sampling?.[id] ?? null} onChange={n => { const sampling = { ...values.sampling }; if (n === null) delete sampling[id]; else sampling[id] = n; change('sampling', sampling); }}/></label>))}</section></> : tab === 'json' ? <><p className="small muted">{tr("Engine arguments and STRATA environment flags are editable here. Program paths and network access remain managed by the host.")}</p><textarea className="st-input native-json" aria-label={tr("Native configuration JSON")} spellCheck={false} value={text} onChange={e => { setText(e.target.value); setNotice(''); }}/></> : <><p className="small muted">{tr("Add local programs or HTTP MCP servers. Connected tools can read or change the resources you give them access to. Enable tools in chat when you want the model to use them.")}</p><NativeMcpEditor text={mcp} onChange={value => { setMcp(value); setNotice(''); }}/><details><summary className="small">{tr("Configuration example")}</summary><pre className="native-example">{'{\n "files": {\n "command": "npx",\n "args": ["-y", "@modelcontextprotocol/server-filesystem", "/your/folder"],\n "disabled": false\n }\n}'}</pre><p className="xs muted">{tr("Saved credentials are masked. Keep the mask to preserve an existing value; type a new value to replace it.")}</p></details></>)}
|
||||
<div className="native-settings-actions"><Btn disabled={pending || !original || !dirty} variant="primary" onClick={() => void save()}>{tr(pending ? 'Saving…' : 'Save settings')}</Btn><Btn disabled={pending} onClick={() => { const saved = JSON.parse(original || '{"values":{},"mcp":{}}'); setValues(saved.values); setText(JSON.stringify(saved.values, null, 2)); setMcp(JSON.stringify(saved.mcp, null, 2)); setError(''); }}>{tr("Restore saved")}</Btn></div>{tr(notice ? <p role="status" className="small">{tr(notice)}</p> : null)}{tr(error ? <ErrorNotice message={error} onRetry={() => setRevision(value => value + 1)}/> : null)}
|
||||
</details>;
|
||||
}
|
||||
|
||||
@@ -71,10 +71,11 @@
|
||||
"fx70": "Lange Prompts schneller lesen",
|
||||
"fx71": "Schnellere Antworten auf Radeon RX 9000 / AI PRO R9700",
|
||||
"fx72": "DeepSeek-Beschleunigungen",
|
||||
"fx73": "Liest lange Prompts schneller, indem ein Teil der Arbeit angenähert wird. Schalten Sie die Option aus, wenn Antworten zu langen Dokumenten falsch aussehen.",
|
||||
"fx73": "Liest sehr lange Prompts schneller, indem ein Teil der Arbeit angenähert wird. Standardmäßig aus: Antworten zu langen Dokumenten können Einzelheiten auslassen oder verwechseln.",
|
||||
"fx74": "Verteilt die Arbeit so zwischen Grafikkarte und Prozessor, dass Antworten auf diesen Karten schneller werden. Ausschalten stellt die vorherige, langsamere Einstellung wieder her.",
|
||||
"fx75": "Liest lange Prompts schneller und lädt die benötigten Teile des Modells schneller. Schalten Sie die Option aus, wenn DeepSeek nicht mehr funktioniert oder die Antworten falsch aussehen; dann läuft es wie in Version 0.2.6.",
|
||||
"fx76": "Ein (empfohlen)",
|
||||
"fx77": "Das ist ein sehr großes Modell. Der Download umfasst {0} GB und braucht etwa so viel freien Speicherplatz. Es läuft auf NVIDIA-RTX-Karten der Serien 30, 40 und 50, auf einer Radeon AI PRO R9700 (Linux) oder auf einem Ryzen-AI-Max-/Strix-Halo-PC (Windows); wie schnell es ist, hängt von Speicher und Grafikkarte ab (die Zeile darunter sagt, was auf diesem Computer zu erwarten ist). Was nicht in den Speicher passt, wird von deiner SSD gelesen, deshalb zählt eine NVMe-SSD.",
|
||||
"fx78": "Noch nicht getestet. Ein so langer Kontext nimmt dem Modell Grafikspeicher weg, und lange Prompts werden langsam gelesen."
|
||||
"fx78": "Noch nicht getestet. Ein so langer Kontext nimmt dem Modell Grafikspeicher weg, und lange Prompts werden langsam gelesen.",
|
||||
"fx79": "Aus (empfohlen)"
|
||||
}
|
||||
@@ -71,10 +71,11 @@
|
||||
"fx70": "Faster long prompts",
|
||||
"fx71": "Faster answers on Radeon RX 9000 / AI PRO R9700",
|
||||
"fx72": "DeepSeek speed-ups",
|
||||
"fx73": "Reads long prompts faster by approximating part of the work. Turn off if answers about long documents look wrong.",
|
||||
"fx73": "Reads very long prompts faster by approximating part of the work. Off by default: answers about long documents can miss or mix up details.",
|
||||
"fx74": "Shares the work between the graphics card and the processor in a way that makes answers faster on these cards. Turn off to go back to the previous setting, which is slower.",
|
||||
"fx75": "Reads long prompts faster and loads the parts of the model it needs faster. Turn off if DeepSeek stops working or its answers look wrong; it then runs as in version 0.2.6.",
|
||||
"fx76": "On (recommended)",
|
||||
"fx77": "This is a very large model. The download is {0} GB and it needs about as much free disk space. It runs on NVIDIA RTX 30, 40 and 50 cards, on a Radeon AI PRO R9700 (Linux) or on a Ryzen AI Max / Strix Halo PC (Windows); how fast it is depends on the memory and card (the line below says what to expect on this computer). What does not fit in memory is read from your SSD, so an NVMe drive matters.",
|
||||
"fx78": "Not tested yet. A context this long takes graphics memory from the model and reads long prompts slowly."
|
||||
"fx78": "Not tested yet. A context this long takes graphics memory from the model and reads long prompts slowly.",
|
||||
"fx79": "Off (recommended)"
|
||||
}
|
||||
@@ -71,10 +71,11 @@
|
||||
"fx70": "Prompts largos más rápidos",
|
||||
"fx71": "Respuestas más rápidas en Radeon RX 9000 / AI PRO R9700",
|
||||
"fx72": "Aceleraciones de DeepSeek",
|
||||
"fx73": "Lee los prompts largos más rápido aproximando una parte del trabajo. Desactívalo si las respuestas sobre documentos largos parecen incorrectas.",
|
||||
"fx73": "Lee prompts muy largos más rápido aproximando una parte del trabajo. Desactivado de forma predeterminada: las respuestas sobre documentos largos pueden omitir o confundir detalles.",
|
||||
"fx74": "Reparte el trabajo entre la tarjeta gráfica y el procesador de una forma que acelera las respuestas en estas tarjetas. Si lo desactivas, vuelve el ajuste anterior, que es más lento.",
|
||||
"fx75": "Lee los prompts largos más rápido y carga más rápido las partes del modelo que necesita. Desactívalo si DeepSeek deja de funcionar o sus respuestas parecen incorrectas; entonces funciona como en la versión 0.2.6.",
|
||||
"fx76": "Activado (recomendado)",
|
||||
"fx77": "Es un modelo muy grande. La descarga es de {0} GB y necesita casi el mismo espacio libre en disco. Funciona con tarjetas NVIDIA RTX de las series 30, 40 y 50, con una Radeon AI PRO R9700 (Linux) o en un PC con Ryzen AI Max / Strix Halo (Windows); su velocidad depende de la memoria y de la tarjeta (la línea de abajo indica qué esperar en este equipo). Lo que no cabe en memoria se lee de tu SSD, así que importa que sea NVMe.",
|
||||
"fx78": "Aún sin probar. Un contexto tan largo le quita memoria gráfica al modelo y lee los prompts largos con lentitud."
|
||||
"fx78": "Aún sin probar. Un contexto tan largo le quita memoria gráfica al modelo y lee los prompts largos con lentitud.",
|
||||
"fx79": "Desactivado (recomendado)"
|
||||
}
|
||||
@@ -71,10 +71,11 @@
|
||||
"fx70": "長いプロンプトを高速化",
|
||||
"fx71": "Radeon RX 9000 / AI PRO R9700 での高速な応答",
|
||||
"fx72": "DeepSeek の高速化",
|
||||
"fx73": "処理の一部を近似することで、長いプロンプトをより速く読み込みます。長い文書についての回答がおかしいと感じたらオフにしてください。",
|
||||
"fx73": "処理の一部を近似することで、とても長いプロンプトをより速く読み込みます。既定ではオフです。長い文書についての回答で、細部が抜けたり混ざったりすることがあります。",
|
||||
"fx74": "これらのグラフィックスカードで応答が速くなるよう、グラフィックスカードとプロセッサーの間で作業を分担します。オフにすると、以前の(より遅い)設定に戻ります。",
|
||||
"fx75": "長いプロンプトと、必要なモデルの部分をより速く読み込みます。DeepSeek が動かなくなったり、回答がおかしいと感じたりしたらオフにしてください。バージョン 0.2.6 と同じ動作になります。",
|
||||
"fx76": "オン(推奨)",
|
||||
"fx77": "とても大きなモデルです。ダウンロードは {0} GB で、ほぼ同じ大きさの空き容量が必要です。NVIDIA RTX 30・40・50 シリーズ、Radeon AI PRO R9700(Linux)、または Ryzen AI Max / Strix Halo の PC(Windows)で動きます。速さはメモリとカードによって変わります(この PC での目安は下の行に表示されます)。メモリに入らない分は SSD から読むため、NVMe ドライブが重要です。",
|
||||
"fx78": "まだテストされていません。これほど長いコンテキストは、モデルが使うグラフィックスメモリを消費し、長いプロンプトの読み込みも遅くなります。"
|
||||
"fx78": "まだテストされていません。これほど長いコンテキストは、モデルが使うグラフィックスメモリを消費し、長いプロンプトの読み込みも遅くなります。",
|
||||
"fx79": "オフ(推奨)"
|
||||
}
|
||||
@@ -71,10 +71,11 @@
|
||||
"fx70": "긴 프롬프트 더 빠르게 읽기",
|
||||
"fx71": "Radeon RX 9000 / AI PRO R9700에서 더 빠른 응답",
|
||||
"fx72": "DeepSeek 속도 향상",
|
||||
"fx73": "작업의 일부를 근사 처리하여 긴 프롬프트를 더 빠르게 읽습니다. 긴 문서에 대한 답변이 이상해 보이면 끄세요.",
|
||||
"fx73": "작업의 일부를 근사 처리하여 매우 긴 프롬프트를 더 빠르게 읽습니다. 기본값은 꺼짐입니다. 긴 문서에 대한 답변에서 세부 내용이 빠지거나 뒤섞일 수 있습니다.",
|
||||
"fx74": "이 그래픽 카드에서 응답이 빨라지도록 그래픽 카드와 프로세서가 작업을 나눕니다. 끄면 이전의 더 느린 설정으로 돌아갑니다.",
|
||||
"fx75": "긴 프롬프트와 필요한 모델 부분을 더 빠르게 읽고 불러옵니다. DeepSeek가 멈추거나 답변이 이상해 보이면 끄세요. 그러면 0.2.6 버전처럼 동작합니다.",
|
||||
"fx76": "켬(권장)",
|
||||
"fx77": "매우 큰 모델입니다. 다운로드는 {0}GB이고, 거의 같은 크기의 여유 디스크 공간이 필요합니다. NVIDIA RTX 30·40·50 시리즈 카드, Radeon AI PRO R9700(Linux), 또는 Ryzen AI Max / Strix Halo PC(Windows)에서 실행됩니다. 속도는 메모리와 카드에 따라 달라집니다(아래 줄에 이 컴퓨터에서 기대할 수 있는 속도가 표시됩니다). 메모리에 들어가지 않는 부분은 SSD에서 읽으므로 NVMe 드라이브가 중요합니다.",
|
||||
"fx78": "아직 테스트하지 않았습니다. 이렇게 긴 컨텍스트는 모델이 쓸 그래픽 메모리를 차지하고, 긴 프롬프트를 느리게 읽습니다."
|
||||
"fx78": "아직 테스트하지 않았습니다. 이렇게 긴 컨텍스트는 모델이 쓸 그래픽 메모리를 차지하고, 긴 프롬프트를 느리게 읽습니다.",
|
||||
"fx79": "끔(권장)"
|
||||
}
|
||||
@@ -71,10 +71,11 @@
|
||||
"fx70": "Prompts longos mais rápidos",
|
||||
"fx71": "Respostas mais rápidas em Radeon RX 9000 / AI PRO R9700",
|
||||
"fx72": "Acelerações do DeepSeek",
|
||||
"fx73": "Lê prompts longos mais rápido aproximando parte do trabalho. Desative se as respostas sobre documentos longos parecerem erradas.",
|
||||
"fx73": "Lê prompts muito longos mais rápido aproximando parte do trabalho. Desativado por padrão: as respostas sobre documentos longos podem omitir ou misturar detalhes.",
|
||||
"fx74": "Divide o trabalho entre a placa de vídeo e o processador de um jeito que deixa as respostas mais rápidas nessas placas. Ao desativar, volta a configuração anterior, que é mais lenta.",
|
||||
"fx75": "Lê prompts longos mais rápido e carrega mais rápido as partes do modelo de que precisa. Desative se o DeepSeek parar de funcionar ou as respostas parecerem erradas; ele passa a funcionar como na versão 0.2.6.",
|
||||
"fx76": "Ativado (recomendado)",
|
||||
"fx77": "Este é um modelo muito grande. O download tem {0} GB e precisa de quase o mesmo espaço livre em disco. Ele roda em placas NVIDIA RTX das séries 30, 40 e 50, em uma Radeon AI PRO R9700 (Linux) ou em um PC com Ryzen AI Max / Strix Halo (Windows); a velocidade depende da memória e da placa (a linha abaixo diz o que esperar neste computador). O que não cabe na memória é lido do seu SSD, então um NVMe faz diferença.",
|
||||
"fx78": "Ainda não testado. Um contexto tão longo tira memória gráfica do modelo e lê prompts longos devagar."
|
||||
"fx78": "Ainda não testado. Um contexto tão longo tira memória gráfica do modelo e lê prompts longos devagar.",
|
||||
"fx79": "Desativado (recomendado)"
|
||||
}
|
||||
@@ -71,10 +71,11 @@
|
||||
"fx70": "Более быстрое чтение длинных запросов",
|
||||
"fx71": "Более быстрые ответы на Radeon RX 9000 / AI PRO R9700",
|
||||
"fx72": "Ускорения DeepSeek",
|
||||
"fx73": "Читает длинные запросы быстрее, приближённо выполняя часть работы. Отключите, если ответы по длинным документам выглядят неверными.",
|
||||
"fx73": "Читает очень длинные запросы быстрее, приближённо выполняя часть работы. По умолчанию выключено: в ответах по длинным документам могут пропадать или путаться детали.",
|
||||
"fx74": "Распределяет работу между видеокартой и процессором так, что ответы на этих видеокартах получаются быстрее. Если отключить, вернётся прежняя, более медленная настройка.",
|
||||
"fx75": "Быстрее читает длинные запросы и быстрее загружает нужные части модели. Отключите, если DeepSeek перестаёт работать или его ответы выглядят неверными; тогда он работает как в версии 0.2.6.",
|
||||
"fx76": "Вкл. (рекомендуется)",
|
||||
"fx77": "Это очень большая модель. Загрузка — {0} ГБ, и нужно почти столько же свободного места на диске. Она работает на видеокартах NVIDIA RTX серий 30, 40 и 50, на Radeon AI PRO R9700 (Linux) или на ПК с Ryzen AI Max / Strix Halo (Windows); скорость зависит от памяти и видеокарты (строка ниже подскажет, чего ждать на этом компьютере). То, что не помещается в память, читается с вашего SSD, поэтому важен накопитель NVMe.",
|
||||
"fx78": "Ещё не проверено. Такой длинный контекст отнимает у модели видеопамять, а длинные запросы читаются медленно."
|
||||
"fx78": "Ещё не проверено. Такой длинный контекст отнимает у модели видеопамять, а длинные запросы читаются медленно.",
|
||||
"fx79": "Выкл. (рекомендуется)"
|
||||
}
|
||||
@@ -71,10 +71,11 @@
|
||||
"fx70": "更快读取长提示词",
|
||||
"fx71": "Radeon RX 9000 / AI PRO R9700 上更快的回答",
|
||||
"fx72": "DeepSeek 加速",
|
||||
"fx73": "通过近似处理部分计算,更快读取长提示词。如果关于长文档的回答看起来不对,请关闭。",
|
||||
"fx73": "通过近似处理部分计算,更快读取很长的提示词。默认关闭:关于长文档的回答可能遗漏或混淆细节。",
|
||||
"fx74": "以更适合这些显卡的方式在显卡和处理器之间分配工作,使回答更快。关闭后恢复到之前较慢的设置。",
|
||||
"fx75": "更快读取长提示词,并更快加载所需的模型部分。如果 DeepSeek 无法运行或回答看起来不对,请关闭;关闭后它将像 0.2.6 版本那样运行。",
|
||||
"fx76": "开启(推荐)",
|
||||
"fx77": "这是一个非常大的模型。下载大小为 {0} GB,需要差不多同样大小的可用磁盘空间。它可在 NVIDIA RTX 30、40 和 50 系列显卡、Radeon AI PRO R9700(Linux)或 Ryzen AI Max / Strix Halo 电脑(Windows)上运行;速度取决于内存和显卡(下面一行会说明在这台电脑上的预期)。内存放不下的部分会从你的 SSD 读取,所以 NVMe 硬盘很重要。",
|
||||
"fx78": "尚未测试。这么长的上下文会占用本该给模型使用的显存,读取长提示词也会很慢。"
|
||||
"fx78": "尚未测试。这么长的上下文会占用本该给模型使用的显存,读取长提示词也会很慢。",
|
||||
"fx79": "关闭(推荐)"
|
||||
}
|
||||
@@ -1,57 +1,75 @@
|
||||
// The three 0.2.7 speed features are on by default and each has an off switch in Expert settings (the model's "Native engine settings").
|
||||
// Off writes exactly the engine environment of the switch contract (phaseA-tests/notes-027-plan.md) into the model's settings file; on removes it,
|
||||
// so a default launch carries none of it. strata_control/speed_switches.py says the same for the Terminal (tests/terminal/test_speed_switches.py).
|
||||
// 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
|
||||
// decision, 26 October) and STRATA_KVA=1 turns it on; the Radeon RX 9000 and DeepSeek ones are on by default and turning them off writes their entries.
|
||||
// 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
|
||||
// Terminal (tests/terminal/test_speed_switches.py).
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync, writeFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { SPEED_SWITCHES, speedSwitchApplies, speedSwitchIsOff, speedSwitchRows, setSpeedSwitch, validateNativeSettings, publicNativeEnv, restoreNativeEnv } from '../server/native-settings.mjs';
|
||||
import { SPEED_SWITCHES, speedSwitchApplies, speedSwitchIsSet, speedSwitchIsOn, speedSwitchRows, setSpeedSwitch, validateNativeSettings, publicNativeEnv, restoreNativeEnv } from '../server/native-settings.mjs';
|
||||
import { nativeFixture } from './helpers/native-fixture.mjs';
|
||||
|
||||
const read = rel => readFileSync(fileURLToPath(new URL(rel, import.meta.url)), 'utf8').replace(/\r\n/g, '\n');
|
||||
const OFF = {
|
||||
faster_long_prompts: { STRATA_KVA: '0' },
|
||||
const ENV = { // what each switch writes outside its default
|
||||
faster_long_prompts: { STRATA_KVA: '1' },
|
||||
faster_radeon_9000: { STRATA_PCIE_FRAC_DEFAULT: 'old' },
|
||||
deepseek_speedups: { DS4_FAST_ATTN: '0', DS4_ATTN_SLAB: '0', DS4_COPY_PIN: '0', DS4_COPY_HUGETLB: '0', DS4_STORE_SPARE: '0', DS4_STORE_PUT: '0' },
|
||||
};
|
||||
const DEFAULT = { faster_long_prompts: 'off', faster_radeon_9000: 'on', deepseek_speedups: 'on' };
|
||||
const R9700 = { index: 0, name: 'AMD Radeon AI PRO R9700', vendor: 'amd', arch: 'gfx1201', vram_gb: 32 };
|
||||
const RX7900 = { index: 0, name: 'AMD Radeon RX 7900 XTX', vendor: 'amd', arch: 'gfx1100', vram_gb: 24 };
|
||||
const RTX = { index: 0, name: 'NVIDIA GeForce RTX 4090', vendor: 'nvidia', arch: '89', vram_gb: 24 };
|
||||
const STRIX = { index: 0, name: 'AMD Radeon 8060S', vendor: 'amd', arch: 'gfx1151', vram_gb: 96, uma: true };
|
||||
|
||||
test('there are exactly three switches and each writes the engine names of the contract', () => {
|
||||
assert.deepEqual(SPEED_SWITCHES.map(s => s.id), Object.keys(OFF));
|
||||
for (const sw of SPEED_SWITCHES) assert.deepEqual(sw.off, OFF[sw.id], sw.id);
|
||||
test('there are exactly three switches; each writes the engine names of the contract and has its default (KVA off, the others on)', () => {
|
||||
assert.deepEqual(SPEED_SWITCHES.map(s => s.id), Object.keys(ENV));
|
||||
for (const sw of SPEED_SWITCHES) {
|
||||
assert.deepEqual(sw.env, ENV[sw.id], sw.id);
|
||||
assert.equal(sw.default, DEFAULT[sw.id], sw.id);
|
||||
}
|
||||
});
|
||||
|
||||
test('a default launch has none of the new environment entries: every switch reads as on and an empty environment stays empty', () => {
|
||||
for (const sw of SPEED_SWITCHES) assert.equal(speedSwitchIsOff({}, sw.id), false);
|
||||
test('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', () => {
|
||||
for (const sw of SPEED_SWITCHES) assert.equal(speedSwitchIsSet({}, sw.id), false);
|
||||
const env = { PATH: '/native/bin', STRATA_PREFILL: '2' };
|
||||
for (const sw of SPEED_SWITCHES) assert.deepEqual(setSpeedSwitch(env, sw.id, true), env, 'on removes nothing that is not the switch\'s');
|
||||
for (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');
|
||||
const rows = speedSwitchRows({}, { backend: 'hip', gpus: [R9700] });
|
||||
assert.ok(rows.every(r => r.on === true));
|
||||
assert.deepEqual(rows.map(r => [r.id, r.on]), [['faster_long_prompts', false], ['faster_radeon_9000', true]]);
|
||||
assert.deepEqual(rows.map(r => r.default), ['off', 'on']);
|
||||
});
|
||||
|
||||
test('each switch off yields exactly its entries and nothing else; on again gives back the same environment', () => {
|
||||
test('Faster long prompts: On writes STRATA_KVA=1, Off removes it, and an earlier test build\'s STRATA_KVA=0 shows as Off', () => {
|
||||
const env = { PATH: '/native/bin' };
|
||||
assert.deepEqual(setSpeedSwitch(env, 'faster_long_prompts', true), { PATH: '/native/bin', STRATA_KVA: '1' });
|
||||
assert.deepEqual(setSpeedSwitch({ ...env, STRATA_KVA: '1' }, 'faster_long_prompts', false), env);
|
||||
assert.equal(speedSwitchIsOn({ STRATA_KVA: '1' }, 'faster_long_prompts'), true);
|
||||
assert.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');
|
||||
assert.equal(speedSwitchIsOn({}, 'faster_long_prompts'), false);
|
||||
assert.deepEqual(setSpeedSwitch({ ...env, STRATA_KVA: '0' }, 'faster_long_prompts', false), env, 'choosing Off again cleans it up');
|
||||
assert.deepEqual(speedSwitchRows({ STRATA_KVA: '0' }, { backend: 'cuda', gpus: [RTX] }).map(r => [r.id, r.on]), [['faster_long_prompts', false]]);
|
||||
});
|
||||
|
||||
test('each switch outside its default yields exactly its entries and nothing else; back in the default gives back the same environment', () => {
|
||||
const env = { PATH: '/native/bin', STRATA_PREFILL: '2', DS4_ASYNC_T: '4' };
|
||||
for (const sw of SPEED_SWITCHES) {
|
||||
const off = setSpeedSwitch(env, sw.id, false);
|
||||
assert.deepEqual(off, { ...env, ...OFF[sw.id] }, sw.id);
|
||||
assert.equal(speedSwitchIsOff(off, sw.id), true);
|
||||
for (const other of SPEED_SWITCHES) if (other.id !== sw.id) assert.equal(speedSwitchIsOff(off, other.id), false, `${sw.id} does not turn ${other.id} off`);
|
||||
const back = setSpeedSwitch(off, sw.id, true);
|
||||
const other = setSpeedSwitch(env, sw.id, sw.default !== 'on'); // the non-default state: KVA on, the others off
|
||||
assert.deepEqual(other, { ...env, ...ENV[sw.id] }, sw.id);
|
||||
assert.equal(speedSwitchIsSet(other, sw.id), true);
|
||||
assert.equal(speedSwitchIsOn(other, sw.id), sw.default !== 'on');
|
||||
for (const another of SPEED_SWITCHES) if (another.id !== sw.id) assert.equal(speedSwitchIsSet(other, another.id), false, `${sw.id} does not touch ${another.id}`);
|
||||
const back = setSpeedSwitch(other, sw.id, sw.default === 'on');
|
||||
assert.deepEqual(back, env, sw.id);
|
||||
assert.equal(JSON.stringify(back), JSON.stringify(env), 'byte for byte, key order included');
|
||||
}
|
||||
assert.throws(() => setSpeedSwitch({}, 'nothing', false), /Unknown speed switch/);
|
||||
});
|
||||
|
||||
test('a hand-edited file with only some of a switch\'s entries reads as on and is left alone by an unchanged save', () => {
|
||||
test('a hand-edited file with only some of a switch\'s entries reads as its default and is left alone by an unchanged save', () => {
|
||||
const partial = { DS4_FAST_ATTN: '0' };
|
||||
assert.equal(speedSwitchIsOff(partial, 'deepseek_speedups'), false);
|
||||
assert.deepEqual(setSpeedSwitch(partial, 'faster_long_prompts', true), partial);
|
||||
assert.equal(speedSwitchIsOff({ STRATA_KVA: '1' }, 'faster_long_prompts'), false, 'only the off value counts');
|
||||
assert.equal(speedSwitchIsOn(partial, 'deepseek_speedups'), true);
|
||||
assert.deepEqual(setSpeedSwitch(partial, 'faster_long_prompts', false), partial);
|
||||
assert.equal(speedSwitchIsOn({ STRATA_KVA: 'yes' }, 'faster_long_prompts'), false, 'only 1 turns it on');
|
||||
});
|
||||
|
||||
test('a switch shows only where it applies: Qwen on CUDA or HIP, Qwen on a Radeon RX 9000 / R9700, DeepSeek', () => {
|
||||
@@ -70,14 +88,23 @@ test('a switch shows only where it applies: Qwen on CUDA or HIP, Qwen on a Radeo
|
||||
assert.deepEqual(ids({}), [], 'nothing is known: nothing is offered');
|
||||
});
|
||||
|
||||
test('Faster long prompts is for Qwen3.8-Flash-Next only: no row for Qwen3.6-35B-A3B (a run config with an arch) or DeepSeek', () => {
|
||||
const ids = context => speedSwitchRows({}, context).map(r => r.id);
|
||||
assert.deepEqual(ids({ backend: 'cuda', gpus: [RTX], arch: null }), ['faster_long_prompts'], 'Flash-Next files have no arch');
|
||||
assert.deepEqual(ids({ backend: 'cuda', gpus: [RTX], arch: 'qwen35moe' }), [], 'Qwen3.6-35B-A3B on CUDA');
|
||||
assert.deepEqual(ids({ backend: 'hip', gpus: [RX7900], arch: 'qwen35moe' }), [], 'and on HIP');
|
||||
assert.deepEqual(ids({ backend: 'hip', gpus: [R9700], arch: 'qwen35moe' }), ['faster_radeon_9000'], 'the Radeon switch is not tied to the model\'s shape');
|
||||
assert.equal(speedSwitchApplies('faster_long_prompts', { backend: 'cuda', gpus: [RTX], arch: 'qwen35moe' }), false);
|
||||
});
|
||||
|
||||
test('the environment names round-trip through the validator, the public view and the restore, and other names stay untouched', () => {
|
||||
const all = Object.assign({}, ...Object.values(OFF));
|
||||
const all = Object.assign({}, ...Object.values(ENV));
|
||||
assert.deepEqual(validateNativeSettings({ env: all }), { env: all });
|
||||
assert.throws(() => validateNativeSettings({ env: { HOME: '/tmp' } }));
|
||||
assert.throws(() => validateNativeSettings({ env: { DS4_fast: '0' } }));
|
||||
const previous = { PATH: '/native/bin', HIP_VISIBLE_DEVICES: '0', ...all };
|
||||
assert.deepEqual(publicNativeEnv(previous), all);
|
||||
assert.deepEqual(restoreNativeEnv({}, previous), { PATH: '/native/bin', HIP_VISIBLE_DEVICES: '0' }, 'turning every switch on removes only theirs');
|
||||
assert.deepEqual(restoreNativeEnv({}, previous), { PATH: '/native/bin', HIP_VISIBLE_DEVICES: '0' }, 'every switch back in its default removes only theirs');
|
||||
assert.deepEqual(restoreNativeEnv(all, { PATH: '/native/bin' }), { PATH: '/native/bin', ...all });
|
||||
});
|
||||
|
||||
@@ -87,7 +114,7 @@ function setConfig(f, model, patch) {
|
||||
return path;
|
||||
}
|
||||
|
||||
test('through the host: the settings answer lists the switches that apply, and off then on gives back the same file', async () => {
|
||||
test('through the host: the settings answer lists the switches that apply, and KVA on then off gives back the same file', async () => {
|
||||
const f = nativeFixture();
|
||||
try {
|
||||
f.setHardware({ ram_gb: 64, gpus: [R9700] });
|
||||
@@ -95,24 +122,24 @@ test('through the host: the settings answer lists the switches that apply, and o
|
||||
await f.control.refresh();
|
||||
const before = readFileSync(path, 'utf8');
|
||||
const first = f.control.settings('iq2_xs');
|
||||
assert.deepEqual(first.speedSwitches.map(s => [s.id, s.on]), [['faster_long_prompts', true], ['faster_radeon_9000', true]]);
|
||||
assert.deepEqual(first.speedSwitches.map(s => s.off), [OFF.faster_long_prompts, OFF.faster_radeon_9000], 'the client writes what the host says');
|
||||
assert.deepEqual(first.speedSwitches.map(s => [s.id, s.on]), [['faster_long_prompts', false], ['faster_radeon_9000', true]]);
|
||||
assert.deepEqual(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');
|
||||
assert.equal('STRATA_KVA' in first.values.env, false, 'default: nothing in the environment');
|
||||
|
||||
// the client turns "Faster long prompts" off: it sends the environment with the entry added
|
||||
const off = f.control.save('iq2_xs', { values: { env: { ...first.values.env, ...OFF.faster_long_prompts } } });
|
||||
// the client turns "Faster long prompts" on: it sends the environment with the entry added
|
||||
const off = f.control.save('iq2_xs', { values: { env: { ...first.values.env, ...ENV.faster_long_prompts } } });
|
||||
const file = JSON.parse(readFileSync(path, 'utf8'));
|
||||
assert.equal(file.env.STRATA_KVA, '0');
|
||||
assert.equal(file.env.STRATA_KVA, '1');
|
||||
assert.equal(file.env.PATH, '/native/bin');
|
||||
assert.equal(file.env.STRATA_TOKEN, 'private', 'a credential is kept, not lost behind its mask');
|
||||
assert.equal('STRATA_PCIE_FRAC_DEFAULT' in file.env, false);
|
||||
assert.deepEqual(off.speedSwitches.map(s => [s.id, s.on]), [['faster_long_prompts', false], ['faster_radeon_9000', true]]);
|
||||
assert.deepEqual(off.speedSwitches.map(s => [s.id, s.on]), [['faster_long_prompts', true], ['faster_radeon_9000', true]]);
|
||||
|
||||
// and on again: the entry is gone and the file is as it was
|
||||
// and Off again: the entry is gone and the file is as it was
|
||||
const env = { ...off.values.env };
|
||||
delete env.STRATA_KVA;
|
||||
const on = f.control.save('iq2_xs', { values: { env } });
|
||||
assert.deepEqual(on.speedSwitches.map(s => s.on), [true, true]);
|
||||
assert.deepEqual(on.speedSwitches.map(s => s.on), [false, true]);
|
||||
const after = JSON.parse(readFileSync(path, 'utf8'));
|
||||
assert.deepEqual(after, JSON.parse(before));
|
||||
assert.equal(JSON.stringify(after.env), JSON.stringify(JSON.parse(before).env), 'the same environment, same order');
|
||||
@@ -128,15 +155,27 @@ test('through the host: a DeepSeek model gets its own switch only, and the Strix
|
||||
const first = f.control.settings('iq2_xs');
|
||||
assert.deepEqual(first.speedSwitches.map(s => [s.id, s.on]), [['deepseek_speedups', true]]);
|
||||
assert.equal(first.values.env.DS4_ASYNC_T, '4', 'setup\'s own entry is visible and kept');
|
||||
const off = f.control.save('iq2_xs', { values: { env: { ...first.values.env, ...OFF.deepseek_speedups } } });
|
||||
assert.deepEqual(JSON.parse(readFileSync(path, 'utf8')).env, { DS4_ASYNC_T: '4', ...OFF.deepseek_speedups });
|
||||
const off = f.control.save('iq2_xs', { values: { env: { ...first.values.env, ...ENV.deepseek_speedups } } });
|
||||
assert.deepEqual(JSON.parse(readFileSync(path, 'utf8')).env, { DS4_ASYNC_T: '4', ...ENV.deepseek_speedups });
|
||||
assert.equal(off.speedSwitches[0].on, false);
|
||||
const env = Object.fromEntries(Object.entries(off.values.env).filter(([name]) => !(name in OFF.deepseek_speedups)));
|
||||
const env = Object.fromEntries(Object.entries(off.values.env).filter(([name]) => !(name in ENV.deepseek_speedups)));
|
||||
f.control.save('iq2_xs', { values: { env } });
|
||||
assert.deepEqual(JSON.parse(readFileSync(path, 'utf8')).env, { DS4_ASYNC_T: '4' });
|
||||
} finally { await f.cleanup(); }
|
||||
});
|
||||
|
||||
test('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 () => {
|
||||
const f = nativeFixture();
|
||||
try {
|
||||
f.setHardware({ ram_gb: 64, gpus: [RTX] });
|
||||
setConfig(f, 'iq2_xs', { backend: 'cuda' });
|
||||
setConfig(f, 'iq3_s', { backend: 'cuda', arch: 'qwen35moe', model_name: 'qwen3.6-35b-a3b-ud-q4_k_xl' });
|
||||
await f.control.refresh();
|
||||
assert.deepEqual(f.control.settings('iq2_xs').speedSwitches.map(s => s.id), ['faster_long_prompts']);
|
||||
assert.deepEqual(f.control.settings('iq3_s').speedSwitches, []);
|
||||
} finally { await f.cleanup(); }
|
||||
});
|
||||
|
||||
test('through the host: a Qwen model on a PC the engine cannot speed up offers no switch (SYCL, a Mac, no card)', async () => {
|
||||
const f = nativeFixture();
|
||||
try {
|
||||
@@ -147,15 +186,15 @@ test('through the host: a Qwen model on a PC the engine cannot speed up offers n
|
||||
} finally { await f.cleanup(); }
|
||||
});
|
||||
|
||||
test('the Expert settings show the rows in the existing row layout with an On / Off choice, and the words are in all eight languages', () => {
|
||||
test('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 eight languages', () => {
|
||||
const screen = read('../src/components/NativeSettings.tsx');
|
||||
assert.match(screen, /<h3 className="h4">\{tr\("Speed"\)\}<\/h3>/);
|
||||
assert.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');
|
||||
assert.match(screen, /label: 'On \(recommended\)' \}, \{ value: 'off', label: 'Off' \}/);
|
||||
assert.match(screen, /if \(on\) delete env\[name\]; else env\[name\] = value;/, 'on removes the entries');
|
||||
assert.match(screen, /\[\{ value: 'on', label: 'On \(recommended\)' \}, \{ value: 'off', label: 'Off' \}\] : \[\{ value: 'off', label: 'Off \(recommended\)' \}, \{ value: 'on', label: 'On' \}\]/);
|
||||
assert.match(screen, /if \(write\) env\[name\] = value; else delete env\[name\];/, 'the default removes the entries');
|
||||
const languages = ['en', 'zh', 'ja', 'de', 'es', 'ru', 'pt', 'ko'];
|
||||
const catalog = lang => JSON.parse(read(`../src/locales/fix-${lang}.json`));
|
||||
const words = [...SPEED_SWITCHES.flatMap(s => [s.label, s.hint]), 'On (recommended)'];
|
||||
const words = [...SPEED_SWITCHES.flatMap(s => [s.label, s.hint]), 'On (recommended)', 'Off (recommended)'];
|
||||
const english = Object.values(catalog('en'));
|
||||
for (const word of words) assert.ok(english.includes(word), `English catalog: ${word}`);
|
||||
for (const lang of languages.slice(1)) {
|
||||
@@ -170,11 +209,11 @@ test('the Expert settings show the rows in the existing row layout with an On /
|
||||
for (const lang of ['zh', 'ja', 'ko']) assert.ok(Object.values(catalog(lang)).some(v => v.includes('0.2.6')), 'the version number is kept in the DeepSeek text');
|
||||
});
|
||||
|
||||
test('the effect texts say what turning the feature off does, in plain words', () => {
|
||||
test('the effect texts say what the feature does and what the other choice costs, in plain words', () => {
|
||||
for (const sw of SPEED_SWITCHES) {
|
||||
assert.match(sw.hint, /[Tt]urn off/, sw.id);
|
||||
assert.ok(sw.default === 'off' ? /Off by default/.test(sw.hint) : /[Tt]urn off/.test(sw.hint), sw.id);
|
||||
assert.ok(sw.hint.length < 260, sw.id);
|
||||
assert.ok(!/STRATA_|DS4_|env|--/.test(sw.hint), 'no flags or variable names for a non-technical reader');
|
||||
}
|
||||
assert.equal(SPEED_SWITCHES[0].hint, 'Reads long prompts faster by approximating part of the work. Turn off if answers about long documents look wrong.');
|
||||
assert.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.');
|
||||
});
|
||||
@@ -127,11 +127,11 @@ def env_params() -> list[Param]:
|
||||
|
||||
|
||||
def switch_params(applicable: list[Any]) -> list[Param]:
|
||||
"""The rows of the speed switches that apply to this launch (strata_control/speed_switches.py): the environment each one writes when it is off,
|
||||
shown as "on" until the person types the off value. The same three features as the app's Expert settings."""
|
||||
"""The rows of the speed switches that apply to this launch (strata_control/speed_switches.py): the environment each one writes outside its default,
|
||||
shown as the default ("off" for Faster long prompts, "on" for the others) until the person types the value. The same features as the app's Expert settings."""
|
||||
from strata_control import speed_switches as sw
|
||||
return [Param(name=name, kind="env", description=sw.env_words(name), help_default="on", full=sw.env_words(name))
|
||||
for switch in applicable for name, _ in switch.off]
|
||||
return [Param(name=name, kind="env", description=sw.env_words(name), help_default=switch.default, full=sw.env_words(name))
|
||||
for switch in applicable for name, _ in switch.env]
|
||||
|
||||
|
||||
def argv_to_dict(argv: list[Any]) -> dict[str, str]:
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
"""The three speed features that are on by default in 0.2.7, and the off switch each one has.
|
||||
"""The speed features of 0.2.7 that have a switch in the app's Expert settings and in the Terminal's Advanced table.
|
||||
|
||||
Each switch, when off, writes exactly the engine environment below into the model's run config ("env"); turning it on again removes those entries,
|
||||
so a default launch carries none of them and is byte for byte what 0.2.6 started. The names are the engine switch contract
|
||||
(phaseA-tests/notes-027-plan.md). The app does the same in apps/host/server/native-settings.mjs (SPEED_SWITCHES); tests/terminal/test_speed_switches.py
|
||||
A switch has a default (``on`` or ``off``). In its other state it writes exactly the engine environment below into the model's run config ("env"); back in
|
||||
its default it removes those entries, so a default launch carries none of them and is byte for byte what 0.2.6 started. The names are the engine switch
|
||||
contract (phaseA-tests/notes-027-plan.md). The app does the same in apps/host/server/native-settings.mjs (SPEED_SWITCHES); tests/terminal/test_speed_switches.py
|
||||
reads that file and fails when the two disagree, so the Terminal and the app cannot drift apart.
|
||||
|
||||
The Terminal shows the switches as rows of its Advanced table (strata_cli/launch/params.py), only where they apply: ``strata launch --set STRATA_KVA=0``
|
||||
turns "Faster long prompts" off, ``--set STRATA_KVA=off`` puts the default back (the same as removing the row).
|
||||
- "Faster long prompts" (Qwen KVA) is OFF by default (owner decision, 26 October): ``STRATA_KVA=1`` turns it on. A file that holds ``STRATA_KVA=0`` (the
|
||||
off switch of an earlier 0.2.7 test build) reads as off, which is what it is now.
|
||||
- "Faster answers on Radeon RX 9000 / AI PRO R9700" and "DeepSeek speed-ups" are ON by default; turning them off writes their entries.
|
||||
|
||||
The Terminal shows the switches as rows of its Advanced table (strata_cli/launch/params.py), only where they apply: ``strata launch --set STRATA_KVA=1``
|
||||
turns "Faster long prompts" on, ``--set STRATA_KVA=off`` puts the default back (the same as removing the row).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -20,15 +24,16 @@ from typing import Any, Iterable, Mapping
|
||||
class Switch:
|
||||
id: str
|
||||
label: str # the words the app shows
|
||||
effect: str # one plain sentence: what it does and what turning it off does
|
||||
off: tuple[tuple[str, str], ...] # the environment entries written when it is off
|
||||
effect: str # one plain sentence: what it does and what the other choice does
|
||||
env: tuple[tuple[str, str], ...] # the environment entries written when the switch is NOT in its default state
|
||||
only: str # "qwen-gpu" | "qwen-radeon-9000" | "deepseek": where it applies
|
||||
default: str = "on" # "on" | "off": what a launch without the entries does
|
||||
|
||||
|
||||
SWITCHES: tuple[Switch, ...] = (
|
||||
Switch("faster_long_prompts", "Faster long prompts",
|
||||
"Reads long prompts faster by approximating part of the work. Turn off if answers about long documents look wrong.",
|
||||
(("STRATA_KVA", "0"),), "qwen-gpu"),
|
||||
"Reads very long prompts faster by approximating part of the work. Off by default: answers about long documents can miss or mix up details.",
|
||||
(("STRATA_KVA", "1"),), "qwen-gpu", default="off"),
|
||||
Switch("faster_radeon_9000", "Faster answers on Radeon RX 9000 / AI PRO R9700",
|
||||
"Shares the work between the graphics card and the processor in a way that makes answers faster on these cards. "
|
||||
"Turn off to go back to the previous setting, which is slower.",
|
||||
@@ -62,7 +67,8 @@ def _radeon_9000(gpus: Iterable[Mapping[str, Any]] | None) -> bool:
|
||||
|
||||
|
||||
def applies(switch: Switch | str, cfg: Mapping[str, Any] | None, gpus: Iterable[Mapping[str, Any]] | None, backend: str | None = None) -> bool:
|
||||
"""Does the switch make sense for this model on this PC? ``backend`` is the engine's (cuda, hip, sycl, metal, cpu); the run config's own wins."""
|
||||
"""Does the switch make sense for this model on this PC? ``backend`` is the engine's (cuda, hip, sycl, metal, cpu); the run config's own wins.
|
||||
"Faster long prompts" is for Qwen3.8-Flash-Next models only (a config without an "arch")."""
|
||||
sw = BY_ID[switch] if isinstance(switch, str) else switch
|
||||
if sw.only == "deepseek":
|
||||
return is_deepseek(cfg)
|
||||
@@ -70,7 +76,9 @@ def applies(switch: Switch | str, cfg: Mapping[str, Any] | None, gpus: Iterable[
|
||||
return False
|
||||
backend = (cfg or {}).get("backend") or backend
|
||||
if sw.only == "qwen-gpu":
|
||||
return backend in ("cuda", "hip")
|
||||
# KVA was measured on the Qwen3.8-Flash-Next shape (48 layers, 512 experts); the engine declines any other. Setup writes "arch" only for the
|
||||
# families with an engine path of their own (Qwen3.6-35B-A3B: qwen35moe), so a Flash-Next config (the original, Swift, Coder, Unsloth, Gyro, NVFP4) has none.
|
||||
return not (cfg or {}).get("arch") and backend in ("cuda", "hip")
|
||||
if sw.only == "qwen-radeon-9000":
|
||||
return backend == "hip" and _radeon_9000(gpus)
|
||||
return False
|
||||
@@ -81,32 +89,42 @@ def applicable(cfg: Mapping[str, Any] | None, gpus: Iterable[Mapping[str, Any]]
|
||||
return [s for s in SWITCHES if applies(s, cfg, gpus, backend)]
|
||||
|
||||
|
||||
def is_off(env: Mapping[str, Any] | None, switch: Switch | str) -> bool:
|
||||
"""Off only when every entry the switch writes is there with its value; a file with only some of them reads as on and is left alone."""
|
||||
def is_set(env: Mapping[str, Any] | None, switch: Switch | str) -> bool:
|
||||
"""Every entry the switch writes is there with its value (the switch is out of its default). A file with only some of them, or other values
|
||||
(``STRATA_KVA=0``), is in the default state and is left alone."""
|
||||
sw = BY_ID[switch] if isinstance(switch, str) else switch
|
||||
return all((env or {}).get(name) == value for name, value in sw.off)
|
||||
return all((env or {}).get(name) == value for name, value in sw.env)
|
||||
|
||||
|
||||
def is_on(env: Mapping[str, Any] | None, switch: Switch | str) -> bool:
|
||||
"""Is the feature on for a launch with this environment?"""
|
||||
sw = BY_ID[switch] if isinstance(switch, str) else switch
|
||||
return is_set(env, sw) != (sw.default == "on")
|
||||
|
||||
|
||||
def set_switch(env: Mapping[str, Any] | None, switch: Switch | str, on: bool) -> dict[str, Any]:
|
||||
"""The environment with the switch on (its entries removed) or off (its entries written). Nothing else in it changes."""
|
||||
"""The environment with the feature on or off: the default state removes the switch's entries, the other one writes them. Nothing else changes."""
|
||||
sw = BY_ID[switch] if isinstance(switch, str) else switch
|
||||
out = dict(env or {})
|
||||
for name, value in sw.off:
|
||||
if on:
|
||||
out.pop(name, None)
|
||||
else:
|
||||
write = on != (sw.default == "on")
|
||||
for name, value in sw.env:
|
||||
if write:
|
||||
out[name] = value
|
||||
else:
|
||||
out.pop(name, None)
|
||||
return out
|
||||
|
||||
|
||||
def env_names() -> dict[str, Switch]:
|
||||
"""Every environment name a switch writes -> its switch."""
|
||||
return {name: sw for sw in SWITCHES for name, _ in sw.off}
|
||||
return {name: sw for sw in SWITCHES for name, _ in sw.env}
|
||||
|
||||
|
||||
def env_words(name: str) -> str:
|
||||
"""The plain sentence of one environment row of the Terminal's Advanced table."""
|
||||
sw = env_names()[name]
|
||||
value = dict(sw.off)[name]
|
||||
together = f"; all {len(sw.off)} speed-up rows go together" if len(sw.off) > 1 else ""
|
||||
value = dict(sw.env)[name]
|
||||
together = f"; all {len(sw.env)} speed-up rows go together" if len(sw.env) > 1 else ""
|
||||
if sw.default == "off":
|
||||
return f"{sw.label} (off by default; set {value} to turn on{together}). {sw.effect}"
|
||||
return f"{sw.label} (on by default; set {value} to turn off{together}). {sw.effect}"
|
||||
@@ -1,8 +1,8 @@
|
||||
"""The three 0.2.7 speed features are on by default and have an off switch: the contract names, where each applies, and how the Terminal carries them.
|
||||
"""The 0.2.7 speed features and their switches: the contract names, the defaults (Faster long prompts OFF, the other two ON), where each applies, and how the Terminal carries them.
|
||||
|
||||
The app (apps/host/server/native-settings.mjs SPEED_SWITCHES) and Control (strata_control/speed_switches.py) say the same thing; the last test reads the
|
||||
app's table with node and fails when the two differ. `strata launch` shows the environment entries as rows of its Advanced table and writes them into
|
||||
the run config's "env" (`--set STRATA_KVA=0`); a default launch has none of them.
|
||||
the run config's "env" (`--set STRATA_KVA=1` turns Faster long prompts on); a default launch has none of them.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -19,17 +19,20 @@ from strata_control import speed_switches as W
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
|
||||
OFF = {
|
||||
"faster_long_prompts": {"STRATA_KVA": "0"},
|
||||
ENV = { # what each switch writes outside its default
|
||||
"faster_long_prompts": {"STRATA_KVA": "1"},
|
||||
"faster_radeon_9000": {"STRATA_PCIE_FRAC_DEFAULT": "old"},
|
||||
"deepseek_speedups": {"DS4_FAST_ATTN": "0", "DS4_ATTN_SLAB": "0", "DS4_COPY_PIN": "0", "DS4_COPY_HUGETLB": "0",
|
||||
"DS4_STORE_SPARE": "0", "DS4_STORE_PUT": "0"},
|
||||
}
|
||||
DEFAULT = {"faster_long_prompts": "off", "faster_radeon_9000": "on", "deepseek_speedups": "on"}
|
||||
R9700 = {"name": "AMD Radeon AI PRO R9700", "vendor": "amd", "arch": "gfx1201"}
|
||||
RX7900 = {"name": "AMD Radeon RX 7900 XTX", "vendor": "amd", "arch": "gfx1100"}
|
||||
STRIX = {"name": "AMD Radeon 8060S", "vendor": "amd", "arch": "gfx1151", "uma": True}
|
||||
RTX = {"name": "NVIDIA GeForce RTX 4090", "vendor": "nvidia", "arch": "89"}
|
||||
QWEN = {"arch": "qwen35moe", "backend": "cuda", "args": ["--native", "m.gguf"], "env": {"PATH": "/bin"}}
|
||||
# A Qwen3.8-Flash-Next run config (the original, Swift, Coder, Unsloth, Gyro, NVFP4): setup writes no "arch" for it. Qwen3.6-35B-A3B has an engine path of its own: "arch".
|
||||
QWEN = {"model_name": "qwen3.8-flash-next-iq3_s", "backend": "cuda", "args": ["--native", "m.gguf"], "env": {"PATH": "/bin"}}
|
||||
QWEN36 = {"arch": "qwen35moe", "model_name": "qwen3.6-35b-a3b-ud-q4_k_xl", "backend": "cuda", "args": ["--native", "m.gguf"], "env": {"PATH": "/bin"}}
|
||||
DEEPSEEK = {"arch": "deepseek41", "exe": "C:/s/engine-dsv41/0.1.52-win/strata-dsv41.exe", "args": ["--pack", "p"], "env": {"DS4_ASYNC_T": "4"}}
|
||||
|
||||
|
||||
@@ -38,23 +41,24 @@ def ids(cfg, gpus, backend=None):
|
||||
|
||||
|
||||
class Contract(unittest.TestCase):
|
||||
def test_three_switches_with_the_contract_names(self):
|
||||
self.assertEqual([s.id for s in W.SWITCHES], list(OFF))
|
||||
def test_three_switches_with_the_contract_names_and_their_defaults(self):
|
||||
self.assertEqual([s.id for s in W.SWITCHES], list(ENV))
|
||||
for s in W.SWITCHES:
|
||||
self.assertEqual(dict(s.off), OFF[s.id], s.id)
|
||||
self.assertEqual(dict(s.env), ENV[s.id], s.id)
|
||||
self.assertEqual(s.default, DEFAULT[s.id], s.id)
|
||||
|
||||
def test_an_effect_text_says_what_turning_it_off_does_in_plain_words(self):
|
||||
def test_an_effect_text_says_what_the_feature_does_in_plain_words(self):
|
||||
for s in W.SWITCHES:
|
||||
self.assertRegex(s.effect, r"[Tt]urn off", s.id)
|
||||
self.assertRegex(s.effect, r"Off by default" if s.default == "off" else r"[Tt]urn off", s.id)
|
||||
self.assertNotRegex(s.effect, r"STRATA_|DS4_|--|env", s.id)
|
||||
self.assertEqual(W.SWITCHES[0].effect, "Reads long prompts faster by approximating part of the work. Turn off if answers about long documents look wrong.")
|
||||
self.assertEqual(W.SWITCHES[0].effect, "Reads very long prompts faster by approximating part of the work. Off by default: answers about long documents can miss or mix up details.")
|
||||
|
||||
def test_where_each_switch_applies(self):
|
||||
self.assertEqual(ids(QWEN, [RTX]), ["faster_long_prompts"])
|
||||
self.assertEqual(ids({**QWEN, "backend": "hip"}, [RX7900]), ["faster_long_prompts"])
|
||||
self.assertEqual(ids({**QWEN, "backend": "hip"}, [STRIX]), ["faster_long_prompts"], "Strix Halo is gfx1151, not gfx12")
|
||||
self.assertEqual(ids({**QWEN, "backend": "hip"}, [R9700]), ["faster_long_prompts", "faster_radeon_9000"])
|
||||
self.assertEqual(ids({"arch": "qwen35moe"}, [R9700], "hip"), ["faster_long_prompts", "faster_radeon_9000"], "the installed engine's backend when the config has none")
|
||||
self.assertEqual(ids({"model_name": "qwen3.8-flash-next-iq3_s"}, [R9700], "hip"), ["faster_long_prompts", "faster_radeon_9000"], "the installed engine's backend when the config has none")
|
||||
self.assertEqual(ids({**QWEN, "backend": "hip"}, [{"name": "AMD Radeon RX 9070 XT", "vendor": "amd"}]), ["faster_long_prompts", "faster_radeon_9000"])
|
||||
self.assertEqual(ids({**QWEN, "backend": "cuda"}, [RTX, R9700]), ["faster_long_prompts"], "the Radeon switch needs the HIP engine")
|
||||
for backend in ("sycl", "metal", "cpu", None):
|
||||
@@ -63,16 +67,34 @@ class Contract(unittest.TestCase):
|
||||
self.assertEqual(ids({**DEEPSEEK, "backend": "cuda"}, [RTX]), ["deepseek_speedups"])
|
||||
self.assertEqual(ids({"exe": "C:/x/strata-dsv41.exe"}, [RTX]), ["deepseek_speedups"], "found by the engine's name too")
|
||||
|
||||
def test_off_and_on_again_is_the_identical_environment(self):
|
||||
def test_faster_long_prompts_is_for_qwen38_flash_next_only(self):
|
||||
"""KVA was measured on the 48-layer / 512-expert Flash-Next shape and the engine declines other shapes: no row for Qwen3.6-35B-A3B (arch qwen35moe) or DeepSeek."""
|
||||
self.assertEqual(ids(QWEN36, [RTX]), [], "Qwen3.6-35B-A3B on CUDA: no KVA row")
|
||||
self.assertEqual(ids({**QWEN36, "backend": "hip"}, [RX7900]), [], "on HIP too")
|
||||
self.assertEqual(ids({**QWEN36, "backend": "hip"}, [R9700]), ["faster_radeon_9000"], "the Radeon switch is not tied to the model's shape")
|
||||
for family in ("qwen3.8-flash-next-iq3_s", "swift-1.5-iq3_s", "qwen3.8-flash-next-coder-iq3_s", "qwen3.8-flash-next-unsloth-ud-q4_k_xl",
|
||||
"qwen3.8-flash-next-gyro-gyro-s", "qwen3.8-flash-next-nvfp4-nvfp4"):
|
||||
self.assertEqual(ids({**QWEN, "model_name": family}, [RTX]), ["faster_long_prompts"], family)
|
||||
self.assertEqual(ids(DEEPSEEK, [RTX]), ["deepseek_speedups"])
|
||||
|
||||
def test_outside_the_default_and_back_is_the_identical_environment(self):
|
||||
env = {"PATH": "/bin", "STRATA_PREFILL": "2", "DS4_ASYNC_T": "4"}
|
||||
for s in W.SWITCHES:
|
||||
off = W.set_switch(env, s, False)
|
||||
self.assertEqual(off, {**env, **OFF[s.id]})
|
||||
self.assertTrue(W.is_off(off, s))
|
||||
back = W.set_switch(off, s, True)
|
||||
other = W.set_switch(env, s, s.default != "on") # KVA on, the other two off
|
||||
self.assertEqual(other, {**env, **ENV[s.id]})
|
||||
self.assertTrue(W.is_set(other, s))
|
||||
self.assertEqual(W.is_on(other, s), s.default != "on")
|
||||
back = W.set_switch(other, s, s.default == "on")
|
||||
self.assertEqual(json.dumps(back), json.dumps(env), s.id)
|
||||
self.assertFalse(W.is_off({"DS4_FAST_ATTN": "0"}, "deepseek_speedups"), "only some of the entries reads as on")
|
||||
self.assertFalse(W.is_off({"STRATA_KVA": "1"}, "faster_long_prompts"))
|
||||
|
||||
def test_kva_is_off_by_default_and_an_earlier_builds_zero_shows_as_off(self):
|
||||
self.assertFalse(W.is_on({}, "faster_long_prompts"))
|
||||
self.assertTrue(W.is_on({"STRATA_KVA": "1"}, "faster_long_prompts"))
|
||||
self.assertFalse(W.is_on({"STRATA_KVA": "0"}, "faster_long_prompts"), "stored by the old off switch: harmless, and Off is what it is now")
|
||||
self.assertFalse(W.is_on({"STRATA_KVA": "yes"}, "faster_long_prompts"), "only 1 turns it on")
|
||||
self.assertEqual(W.set_switch({"PATH": "/bin", "STRATA_KVA": "0"}, "faster_long_prompts", False), {"PATH": "/bin"}, "choosing Off cleans it up")
|
||||
self.assertTrue(W.is_on({}, "deepseek_speedups"))
|
||||
self.assertTrue(W.is_on({"DS4_FAST_ATTN": "0"}, "deepseek_speedups"), "only some of the entries reads as the default (on)")
|
||||
|
||||
|
||||
class Terminal(unittest.TestCase):
|
||||
@@ -89,8 +111,8 @@ class Terminal(unittest.TestCase):
|
||||
self.assertEqual(env, base["env"], "the environment is exactly the installed one")
|
||||
self.assertEqual(json.dumps(self.config(base), sort_keys=True), json.dumps(self.config(base, {}), sort_keys=True))
|
||||
|
||||
def test_each_switch_off_by_set_gives_exactly_its_entries(self):
|
||||
for sid, entries in OFF.items():
|
||||
def test_each_switch_outside_its_default_by_set_gives_exactly_its_entries(self):
|
||||
for sid, entries in ENV.items(): # --set STRATA_KVA=1 turns KVA on; the other two are turned off by their entries
|
||||
base = DEEPSEEK if sid == "deepseek_speedups" else QWEN
|
||||
cfg = self.config(base, S.settings_from_pairs([f"{k}={v}" for k, v in entries.items()]))
|
||||
self.assertEqual(cfg["env"], {**base["env"], **entries}, sid)
|
||||
@@ -99,8 +121,10 @@ class Terminal(unittest.TestCase):
|
||||
def test_off_again_puts_the_default_back(self):
|
||||
cfg = self.config(QWEN, S.settings_from_pairs(["STRATA_KVA=off"]))
|
||||
self.assertEqual(cfg["env"], QWEN["env"])
|
||||
already = {**QWEN, "env": {**QWEN["env"], "STRATA_KVA": "0"}}
|
||||
self.assertEqual(self.config(already, S.settings_from_pairs(["STRATA_KVA=off"]))["env"], QWEN["env"])
|
||||
turned_on = {**QWEN, "env": {**QWEN["env"], "STRATA_KVA": "1"}}
|
||||
self.assertEqual(self.config(turned_on, S.settings_from_pairs(["STRATA_KVA=off"]))["env"], QWEN["env"])
|
||||
old = {**QWEN, "env": {**QWEN["env"], "STRATA_KVA": "0"}}
|
||||
self.assertEqual(self.config(old, S.settings_from_pairs(["STRATA_KVA=off"]))["env"], QWEN["env"])
|
||||
|
||||
def test_the_advanced_table_lists_only_the_switches_that_apply(self):
|
||||
def names(cfg, gpus, extra=None):
|
||||
@@ -108,37 +132,42 @@ class Terminal(unittest.TestCase):
|
||||
return [r.name for r in rows if r.name in W.env_names()]
|
||||
self.assertEqual(names(QWEN, [RTX]), ["STRATA_KVA"])
|
||||
self.assertEqual(names({**QWEN, "backend": "hip"}, [R9700]), ["STRATA_KVA", "STRATA_PCIE_FRAC_DEFAULT"])
|
||||
self.assertEqual(names(DEEPSEEK, [R9700]), list(OFF["deepseek_speedups"]), "the six, in the contract order")
|
||||
self.assertEqual(names(DEEPSEEK, [R9700]), list(ENV["deepseek_speedups"]), "the six, in the contract order")
|
||||
self.assertEqual(names({**QWEN, "backend": "sycl"}, [R9700]), [])
|
||||
|
||||
def test_a_row_says_on_until_it_is_turned_off_and_explains_itself(self):
|
||||
def test_a_row_shows_its_default_until_it_is_changed_and_explains_itself(self):
|
||||
rows = P.build_rows(None, QWEN["args"], None, QWEN["env"], None, {}, P.switch_params(W.applicable(QWEN, [RTX])))
|
||||
row = next(r for r in rows if r.name == "STRATA_KVA")
|
||||
self.assertEqual((row.name, row.default, row.tuned, row.yours, row.known), ("STRATA_KVA", "on", "on", "", True))
|
||||
self.assertEqual((row.name, row.default, row.tuned, row.yours, row.known), ("STRATA_KVA", "off", "off", "", True))
|
||||
self.assertIn("Faster long prompts", row.description)
|
||||
self.assertIn("set 0 to turn off", row.description)
|
||||
self.assertIn("Turn off if answers about long documents look wrong", row.description)
|
||||
off = P.build_rows(None, QWEN["args"], None, QWEN["env"], None, {"STRATA_KVA": "0"}, P.switch_params(W.applicable(QWEN, [RTX])))
|
||||
self.assertEqual(next(r for r in off if r.name == "STRATA_KVA").yours, "0")
|
||||
self.assertIn("off by default; set 1 to turn on", row.description)
|
||||
self.assertIn("answers about long documents can miss or mix up details", row.description)
|
||||
on = P.build_rows(None, QWEN["args"], None, QWEN["env"], None, {"STRATA_KVA": "1"}, P.switch_params(W.applicable(QWEN, [RTX])))
|
||||
self.assertEqual(next(r for r in on if r.name == "STRATA_KVA").yours, "1")
|
||||
hip = {**QWEN, "backend": "hip"}
|
||||
radeon = next(r for r in P.build_rows(None, hip["args"], None, hip["env"], None, {}, P.switch_params(W.applicable(hip, [R9700]))) if r.name == "STRATA_PCIE_FRAC_DEFAULT")
|
||||
self.assertEqual(radeon.default, "on")
|
||||
self.assertIn("on by default; set old to turn off", radeon.description)
|
||||
|
||||
def test_the_six_deepseek_rows_say_they_go_together(self):
|
||||
text = W.env_words("DS4_COPY_PIN")
|
||||
self.assertIn("all 6 speed-up rows go together", text)
|
||||
self.assertEqual({W.env_names()[n].id for n in OFF["deepseek_speedups"]}, {"deepseek_speedups"})
|
||||
self.assertEqual({W.env_names()[n].id for n in ENV["deepseek_speedups"]}, {"deepseek_speedups"})
|
||||
|
||||
|
||||
class SameAsTheApp(unittest.TestCase):
|
||||
@unittest.skipUnless(shutil.which("node"), "node is not installed")
|
||||
def test_the_apps_table_has_the_same_names_and_words(self):
|
||||
script = ("import {SPEED_SWITCHES} from './apps/host/server/native-settings.mjs';"
|
||||
"console.log(JSON.stringify(SPEED_SWITCHES.map(s=>({id:s.id,label:s.label,hint:s.hint,off:s.off}))))")
|
||||
"console.log(JSON.stringify(SPEED_SWITCHES.map(s=>({id:s.id,label:s.label,hint:s.hint,default:s.default,env:s.env}))))")
|
||||
out = subprocess.run(["node", "--input-type=module", "-e", script], cwd=ROOT, capture_output=True, text=True, timeout=60, check=True).stdout
|
||||
app = json.loads(out)
|
||||
self.assertEqual([a["id"] for a in app], [s.id for s in W.SWITCHES])
|
||||
for a, s in zip(app, W.SWITCHES):
|
||||
self.assertEqual(a["label"], s.label)
|
||||
self.assertEqual(a["hint"], s.effect, s.id)
|
||||
self.assertEqual(a["off"], dict(s.off), s.id)
|
||||
self.assertEqual(a["env"], dict(s.env), s.id)
|
||||
self.assertEqual(a["default"], s.default, s.id)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user