App host: DeepSeek launch arguments are built from what strata-dsv41 takes (#4358 #4359 #4505 #4507 #4504)
The Qwen engine's --vision stands alone, the DeepSeek engine's is a pair (--vision on|off). Taking out only the name left the value behind (--eos 1 off --dspark auto: unknown option off, exit 2). A DeepSeek model keeps its pair whole now. The Settings field 'GPU memory for other apps' wrote --vram-reserve-mib and the resource preference wrote --pool-workers into a DeepSeek model's arguments; strata-dsv41 takes --reserve-mib and has no --pool-workers. Before a load, the arguments and the person's saved options of a DeepSeek model are built from the engine's option list (src/dsv41/ds4_main.cpp, checked by a test): the reserve is renamed, anything else is left out with its value and said in the load's log. The tune operation no longer writes the resource preference into a DeepSeek file.
This commit is contained in:
1 parent
3e1141edf0
commit
5ef90cb96b
3 files changed
+281
-8
No files matched your search
@@ -13,6 +13,7 @@ import { USER_KEY, capture as captureUserArgs, merge as mergeUserArgs, setFlag a
|
||||
import { resolvePython, venvPython } from './python-resolver.mjs';
|
||||
import os from 'node:os';
|
||||
import { runtimeVision } from './native-vision.mjs';
|
||||
import { dsEngineArgs, dsUserArgs, dsArgsNote, withoutVisionFlag } from './native-ds-args.mjs';
|
||||
import { componentsDirectory, installerEnvironment, controlEnvironment, sourceServerEnvironment } from './control-runtime.mjs';
|
||||
import { createEngineStep } from './engine-step.mjs';
|
||||
import { dataFolderFromPick, isDriveRoot, makeFolder, rememberDataFolder, syncDataFolder, terminalSettingsFile } from './model-folder.mjs';
|
||||
@@ -286,18 +287,22 @@ return {summary:result.summary??'Deleted',removed:result.plan?.gb??null};}
|
||||
if(cfg.vision){if(cfg.vision_tokens!=null)cfg.vision={...cfg.vision,max_tokens:cfg.vision_tokens};if(cfg.vision_min_tokens!=null)cfg.vision={...cfg.vision,min_tokens:cfg.vision_min_tokens};}cfg.mcp={...(cfg.mcp??{}),...(cfg.mcp_timeout_s!=null?{timeout_s:cfg.mcp_timeout_s}:{}),...(cfg.mcp_max_rounds!=null?{max_rounds:cfg.mcp_max_rounds}:{}),...(cfg.mcp_max_result_chars!=null?{max_result_chars:cfg.mcp_max_result_chars}:{})};
|
||||
/* The model's own choices win over what setup wrote into the arguments: "Draft layer (MTP)" off leaves --mtp out of every start, and a picture reading that is off leaves --vision out (setup writes both again whenever it runs; the saved settings are applied here, on every load). */
|
||||
if((cfg.mtp===false||cfg.drafting==='off')&&Array.isArray(cfg.args))cfg.args=withoutDraftLayer(cfg.args);
|
||||
if(!cfg.vision&&Array.isArray(cfg.args))cfg.args=cfg.args.filter(a=>a!=='--vision');
|
||||
/* The Qwen engine's --vision stands alone, so it goes (with a picture word after it, if an older file has one). The DeepSeek engine's is a pair, `--vision on|off`, that setup wrote and the engine reads: it stays whole (taking out only the name left `off` behind: `--eos 1 off`, "unknown option off", #4358 #4359 #4505 #4507). */
|
||||
if(!cfg.vision&&!ownEngine(config)&&Array.isArray(cfg.args))cfg.args=withoutVisionFlag(cfg.args);
|
||||
for(const arg of cfg.args??[])if(arg.endsWith('.gguf')&&!existsSync(resolve(repo(),arg)))throw new Error('An engine argument names a missing GGUF. Restore the saved arguments or repair the files.');
|
||||
/* The app's own choice of request slots (4, fewer where the card has no room) is part of the configuration, so a tune measures the engine a load will start: slots take VRAM from the expert cache. */
|
||||
const parallelChoice=packaged&&!ownEngine(config)?chooseParallel({config:cfg,values:args.values??{},hardware:snapshot.hardware?.gpus?.length?snapshot.hardware:{gpus:hardwareProbe()??[]}}):null;
|
||||
let parallelNote=null;
|
||||
let parallelNote=null,dsNote='';
|
||||
/* The agent asks for long answers (a thinking model can use most of the window): let the engine clamp the output to what is left of the context instead of refusing the request. */
|
||||
if(packaged&&!ownEngine(config)&&cfg.fit_max_tokens===undefined)cfg.fit_max_tokens=true;
|
||||
if(parallelChoice){const applied=applyParallel(cfg,parallelChoice);for(const k of Object.keys(cfg))if(!(k in applied.cfg))delete cfg[k];Object.assign(cfg,applied.cfg);parallelNote=applied.note;}
|
||||
/* DeepSeek's Speed choice: the engine decides by itself (--experts auto: 5 when the cards total 16 GB or less, else 6), so nothing is passed unless the person chose 5 or 6. */
|
||||
if(ownEngine(config)){const list=[];const old=Array.isArray(cfg.args)?cfg.args:[];for(let i=0;i<old.length;i++){if(old[i]==='--experts'){i++;continue;}list.push(old[i]);}if(dsExpertsSupported(config)&&(cfg.ds_experts==='5'||cfg.ds_experts==='6'))list.push('--experts',cfg.ds_experts);else if(!dsExpertsSupported(config)&&old.includes('--experts'))list.splice(0,list.length,...old);cfg.args=list;delete cfg.ds_experts;}
|
||||
if(ownEngine(config)){const list=[];const old=Array.isArray(cfg.args)?cfg.args:[];for(let i=0;i<old.length;i++){if(old[i]==='--experts'){i++;continue;}list.push(old[i]);}if(dsExpertsSupported(config)&&(cfg.ds_experts==='5'||cfg.ds_experts==='6'))list.push('--experts',cfg.ds_experts);else if(!dsExpertsSupported(config)&&old.includes('--experts'))list.splice(0,list.length,...old);cfg.args=list;delete cfg.ds_experts;
|
||||
/* Only the options strata-dsv41 takes go to it (#4504): --vram-reserve-mib is its --reserve-mib, and --pool-workers and the other Qwen-engine names are left out, in the arguments and in the person's saved options. */
|
||||
const built=dsEngineArgs(cfg.args);cfg.args=built.args;dsNote=dsArgsNote(built);
|
||||
if(Array.isArray(cfg[USER_KEY])){const kept=dsUserArgs(cfg[USER_KEY]);if(kept.length)cfg[USER_KEY]=kept;else delete cfg[USER_KEY];}}
|
||||
else delete cfg.ds_experts;
|
||||
return {cfg,resources,visionPreferences,parallelChoice,parallelNote};
|
||||
return {cfg,resources,visionPreferences,parallelChoice,parallelNote,dsNote};
|
||||
}
|
||||
/* The DFlash2 drafter, before a load that uses it: Control says whether the choice needs it (and the file is not here), downloads it pinned and checked, and packs it, with plain progress in the job.
|
||||
Never stops the load: a drafter that cannot be had leaves the MTP running, and the job says so. The choice itself is remembered in the model's settings file. */
|
||||
@@ -322,7 +327,7 @@ return {summary:result.summary??'Deleted',removed:result.plan?.gb??null};}
|
||||
await refresh(true);if(job.state!=='running')return;const {entry,path:configFile}=recordFile(args.model);const config=checkedSettingsConfig(readFileSync(configFile,'utf8'));if(packaged){const engine=await control.engine();if(!engine.usable)throw new Error(ENGINE_NOT_RECOGNISED+(engine.notice?` ${engine.notice}`:''));}if(!entry.ready){const error=missingFilesError(args.model,entry.missing);append(args.model,error.details[0]);throw error;}
|
||||
if(externalRunning().length)throw new Error('A Strata server is already running outside this UI. Stop it before loading here, or connect its API in Settings → Models.');
|
||||
if(args.multiple&&instances.size>=8)throw new Error('Unload an instance before adding another. Up to eight native instances can run here.');
|
||||
const {cfg,resources,visionPreferences,parallelChoice,parallelNote:chosenNote}=buildConfig(args,config);
|
||||
const {cfg,resources,visionPreferences,parallelChoice,parallelNote:chosenNote,dsNote}=buildConfig(args,config);
|
||||
let parallelNote=chosenNote;
|
||||
await prepareDrafter(job,args,cfg,configFile);if(job.state!=='running')return;
|
||||
const fingerprint=createHash('sha256').update(JSON.stringify({...cfg,api_key:undefined,port:undefined})).digest('hex');
|
||||
@@ -354,6 +359,7 @@ return {summary:result.summary??'Deleted',removed:result.plan?.gb??null};}
|
||||
/* The engine starts under Control's owner runtime, not as our child: a saved profile per slot, then `runtime start`. */
|
||||
const used=new Set([...instances.values()].map(i=>i.profile));let slot=1;while(used.has('app-'+slot))slot++;instance.profile='app-'+slot;
|
||||
instances.set(id,instance);if(!defaultId||!args.multiple||wasDefault)defaultId=id;emit();
|
||||
if(dsNote)append(id,dsNote);
|
||||
const startWith=value=>{writeFileSync(configPath,JSON.stringify(value,null,2),{mode:0o600});return control.stop(instance.profile).catch(()=>{}).then(()=>control.saveProfile(instance.profile,configPath)).then(()=>control.start(instance.profile,{waitSeconds:startWait}));};
|
||||
started=startWith(cfg);
|
||||
started.then(()=>append(id,'Strata Control reports the engine is ready.'),error=>{append(id,error.message);});
|
||||
@@ -446,16 +452,19 @@ return {summary:result.summary??'Deleted',removed:result.plan?.gb??null};}
|
||||
function writeModelConfig(path,next){const mine=mergeUserArgs(captureUserArgs(readJson(path)),next[USER_KEY]??[]);next=stampedUserArgs(next,mine);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);}
|
||||
async function tune(job,args){
|
||||
await refresh(true);if(job.state!=='running')return;
|
||||
const chosen=record(args.model);resourceSettings(chosen.config,snapshot.hardware,args.profile,modelArena(args.model));
|
||||
const chosen=record(args.model);
|
||||
/* The resource preference writes the Qwen engine's options (--pool-workers, --vram-reserve-mib); the DeepSeek engine takes neither (#4504), so its settings file is left as it is. */
|
||||
const resourceFor=config=>ownEngine(config)?{}:resourceSettings(config,snapshot.hardware,args.profile,modelArena(args.model));
|
||||
resourceFor(chosen.config);
|
||||
if(!chosen.entry.ready)throw new Error('Prepare the model before tuning.');
|
||||
if(externalRunning().length)throw new Error('Stop the native server outside this UI before tuning.');
|
||||
if(busy(requests().filter(r=>instances.has(r.instanceId))))throw new Error('Finish requests before tuning.');
|
||||
for(const id of [...instances.keys()])await unload(id);
|
||||
if(job.state!=='running')return;
|
||||
const initialValues=resourceSettings(chosen.config,snapshot.hardware,args.profile,modelArena(args.model));writeModelConfig(chosen.path,{...chosen.config,...initialValues,ui_resource_profile:args.profile});
|
||||
const initialValues=resourceFor(chosen.config);writeModelConfig(chosen.path,{...chosen.config,...initialValues,ui_resource_profile:args.profile});
|
||||
if(args.calibrate!==false&&state().capabilities.calibration){job.summary='Measuring the best engine settings for this computer…';emit();await program(job,args);}
|
||||
if(job.state!=='running')return;
|
||||
const current=record(args.model),values=resourceSettings(current.config,snapshot.hardware,args.profile,modelArena(args.model));
|
||||
const current=record(args.model),values=resourceFor(current.config);
|
||||
const next={...current.config,...values,ui_resource_profile:args.profile};
|
||||
writeModelConfig(current.path,next);
|
||||
job.summary='Applying your resource preference and loading the model…';emit();
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/** The engine options of the DeepSeek-V4.1 engine (strata-dsv41), and the two ways the app used to hand it options it does not take.
|
||||
*
|
||||
* strata-dsv41 is its own program (src/dsv41/ds4_main.cpp) with its own short option list, and it exits with "unknown option X" (code 2)
|
||||
* on anything else. The Qwen engine takes other names (--vram-reserve-mib, --pool-workers, --resident-budget-gib, ...), and the app's
|
||||
* settings, resource profile and tune presets write those into a model's "args" and "user_args". Before the load starts, the arguments
|
||||
* of a DeepSeek model are built from what the engine takes (#4504): a name it spells differently is renamed, anything else is left out
|
||||
* with its value and said in the job's log. test/native-ds-args.test.mjs reads ds4_main.cpp and fails when this list and the engine drift.
|
||||
*/
|
||||
|
||||
/** Options that take one value. */
|
||||
export const DS_VALUE_FLAGS = new Set([
|
||||
'--pack', '--gpus', '--max-context', '--reserve-mib', '--vram-experts', '--cpu-threads', '--expert-profile', '--ssd-cache', '--ssd-policy',
|
||||
'--eos', '--dspark', '--dspark-conf', '--dspark-block', '--dspark-depth', '--experts', '--tp', '--prefill-chunk', '--threads', '--vision',
|
||||
'--mmap-experts', '--layer-split',
|
||||
]);
|
||||
/** Options that stand alone. */
|
||||
export const DS_SWITCH_FLAGS = new Set(['--no-expert-cache', '--profile-readonly', '--verbose', '-v']);
|
||||
/** The Qwen engine's names for settings the DeepSeek engine has under another name (same meaning). */
|
||||
export const DS_RENAMED = { '--vram-reserve-mib': '--reserve-mib' };
|
||||
|
||||
const isFlag = text => typeof text === 'string' && text.startsWith('-') && text.length > 1 && /^-{1,2}[A-Za-z]/.test(text);
|
||||
/** The words that follow `flag` at `at` up to the next option: its value (one word, or none for a switch at the end of the list). */
|
||||
function valueSpan(list, at) {
|
||||
return at + 1 < list.length && !isFlag(list[at + 1]) ? 1 : 0;
|
||||
}
|
||||
|
||||
/** `args` for strata-dsv41: accepted options kept (a renamed one under the engine's name, unless the list already has that name),
|
||||
* everything else left out together with its value. Returns {args, dropped: [{flag, value}], renamed: [{from, to}]}. */
|
||||
export function dsEngineArgs(args) {
|
||||
const list = (Array.isArray(args) ? args : []).map(String);
|
||||
const out = [], dropped = [], renamed = [];
|
||||
const has = new Set(list.filter(isFlag));
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const item = list[i];
|
||||
if (!isFlag(item)) { out.push(item); continue; } // a stray word: kept as it was (the engine says what it is)
|
||||
const own = DS_RENAMED[item];
|
||||
if (own) {
|
||||
const n = valueSpan(list, i), value = n ? list[i + 1] : null;
|
||||
i += n;
|
||||
if (has.has(own)) { dropped.push({ flag: item, value, because: `${own} is set` }); continue; }
|
||||
out.push(own, ...(value === null ? [] : [value]));
|
||||
renamed.push({ from: item, to: own });
|
||||
continue;
|
||||
}
|
||||
const takes = DS_VALUE_FLAGS.has(item), alone = DS_SWITCH_FLAGS.has(item);
|
||||
if (takes || alone) {
|
||||
out.push(item);
|
||||
if (takes && i + 1 < list.length && !isFlag(list[i + 1])) out.push(list[++i]);
|
||||
continue;
|
||||
}
|
||||
const n = valueSpan(list, i);
|
||||
dropped.push({ flag: item, value: n ? list[i + 1] : null });
|
||||
i += n;
|
||||
}
|
||||
return { args: out, dropped, renamed };
|
||||
}
|
||||
|
||||
/** The person's own options of a DeepSeek model: unaccepted ones leave the list (so the settings file heals itself); the app's
|
||||
* --vram-reserve-mib stays, because the Settings field writes it under that name and it is renamed at every load. */
|
||||
export function dsUserArgs(user) {
|
||||
const list = (Array.isArray(user) ? user : []).map(String);
|
||||
const out = [];
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const item = list[i];
|
||||
if (!isFlag(item)) { out.push(item); continue; }
|
||||
const n = valueSpan(list, i);
|
||||
const keep = DS_VALUE_FLAGS.has(item) || DS_SWITCH_FLAGS.has(item) || item in DS_RENAMED;
|
||||
if (keep) out.push(item, ...list.slice(i + 1, i + 1 + n));
|
||||
i += n;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** One line for the job's log about what was changed, or '' when nothing was. */
|
||||
export function dsArgsNote({ dropped = [], renamed = [] }) {
|
||||
const parts = [];
|
||||
if (renamed.length) parts.push(`${renamed.map(r => `${r.from} is passed as ${r.to}`).join(', ')}`);
|
||||
if (dropped.length) parts.push(`left out because the DeepSeek engine does not take them: ${dropped.map(d => [d.flag, d.value].filter(v => v !== null && v !== undefined).join(' ')).join(', ')}`);
|
||||
return parts.length ? `DeepSeek engine options: ${parts.join('; ')}.` : '';
|
||||
}
|
||||
|
||||
/** `args` without `flag` and the picture word that follows it (the Qwen engine's --vision stands alone; an older config may carry a value). */
|
||||
const PICTURE_WORDS = new Set(['on', 'off', 'yes', 'no', 'gpu', 'cpu', 'none']);
|
||||
export function withoutVisionFlag(args) {
|
||||
const list = (Array.isArray(args) ? args : []).map(String), out = [];
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
if (list[i] === '--vision') { if (i + 1 < list.length && PICTURE_WORDS.has(list[i + 1].toLowerCase())) i++; continue; }
|
||||
out.push(list[i]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
/**
|
||||
* The options the app hands to the DeepSeek engine (strata-dsv41), which exits with "unknown option X" on a name it does not take:
|
||||
* - #4358 #4359 #4505 #4507: a model with pictures off had its `--vision off` pair cut in half (`--eos 1 off --dspark auto`);
|
||||
* - #4504: the Settings field "GPU memory for other apps" wrote --vram-reserve-mib, the resource preference wrote --pool-workers.
|
||||
* Nothing here starts an engine: Control is a fake that records the run config the host saved for the start (a scratch profile,
|
||||
* never the real one).
|
||||
*/
|
||||
import './helpers/isolate-profile.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { createNativeControl } from '../server/native-control.mjs';
|
||||
import { DS_VALUE_FLAGS, DS_SWITCH_FLAGS, DS_RENAMED, dsEngineArgs, dsUserArgs, dsArgsNote, withoutVisionFlag } from '../server/native-ds-args.mjs';
|
||||
|
||||
const DS_ARGS = ['--pack', '/p/ds', '--max-context', '32768', '--eos', '1', '--vision', 'off', '--dspark', 'auto', '--dspark-conf', '0.65', '--prefill-chunk', '1024'];
|
||||
|
||||
function fixture(config = {}, id = 'deepseek-v4.1-flash-ist-das-2.25bpw') {
|
||||
const root = mkdtempSync(join(tmpdir(), 'strata-ds-args-'));
|
||||
const install = join(root, 'install'), data = join(root, 'data');
|
||||
mkdirSync(install, { recursive: true });
|
||||
process.env.STRATA_INSTALL_DIR = install;
|
||||
const path = join(install, `strata-${id}.json`);
|
||||
writeFileSync(path, JSON.stringify({
|
||||
exe: 'C:\\Users\\x\\AppData\\Local\\Strata\\engine-dsv41\\0.1.52-windows-x86_64-cuda-cuda13\\strata-dsv41.exe', arch: 'deepseek41',
|
||||
tokenizer: join(install, 'tok'), args: DS_ARGS, model_name: 'DeepSeek V4.1', port: 8080, ...config }));
|
||||
const saved = [];
|
||||
const control = {
|
||||
control: { dir: join(root, 'control') }, version: '0.2.7',
|
||||
async installedModels() { return { install_dir: install, models: [{ id, name: 'DeepSeek V4.1', source_config: path, component_status: 'present', context_tokens: 32768 }] }; },
|
||||
async engine() { return { usable: true, backend: 'cuda', components_dir: 'E:\\c', engine: { version: '0.1.52', platform: 'windows-x86_64', backend: 'cuda', exe: 'E:\\e\\strata.exe', root: 'E:\\e' } }; },
|
||||
async saveProfile(name, file) { saved.push(JSON.parse(readFileSync(file, 'utf8'))); return {}; },
|
||||
async start() { return { ok: true, state: 'ready' }; },
|
||||
async stop() { return { ok: true }; },
|
||||
};
|
||||
const native = createNativeControl({ control, hardwareProbe: () => [{ index: 0, vram_gb: 24 }], directory: data, spawnProcess: () => { throw new Error('no process'); }, fetcher: async () => Response.json({ status: 'ok' }), requests: () => [] });
|
||||
return { native, saved, id, path, cleanup: () => rmSync(root, { recursive: true, force: true }) };
|
||||
}
|
||||
const finish = async (native, id) => { for (let i = 0; i < 500; i++) { const job = native.state().jobs.find(j => j.id === id); if (job.state !== 'running') return job; await new Promise(r => setTimeout(r, 10)); } throw new Error('job did not finish'); };
|
||||
/** Every word of the argument list that is not an option name or the value right after one: a stray word means a flag lost its name. */
|
||||
function strayWords(args, valued) {
|
||||
const stray = [];
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
if (args[i].startsWith('-')) { if (valued.has(args[i]) && i + 1 < args.length && !args[i + 1].startsWith('--')) i++; continue; }
|
||||
stray.push(args[i]);
|
||||
}
|
||||
return stray;
|
||||
}
|
||||
|
||||
test('the DeepSeek option list is a subset of what ds4_main.cpp parses (it cannot drift ahead of the engine)', () => {
|
||||
const source = fileURLToPath(new URL('../../../src/dsv41/ds4_main.cpp', import.meta.url));
|
||||
if (!existsSync(source)) return; // a package without the engine source
|
||||
const parsed = new Set([...readFileSync(source, 'utf8').matchAll(/a == "(-{1,2}[a-z][a-z0-9-]*)"/g)].map(m => m[1]));
|
||||
assert.ok(parsed.has('--eos') && parsed.has('--reserve-mib'), 'the pattern found the engine option parser');
|
||||
for (const flag of [...DS_VALUE_FLAGS, ...DS_SWITCH_FLAGS, ...Object.values(DS_RENAMED)]) assert.ok(parsed.has(flag), `${flag} is not an option of strata-dsv41`);
|
||||
for (const flag of Object.keys(DS_RENAMED)) assert.ok(!parsed.has(flag), `${flag} is the Qwen engine's name, strata-dsv41 rejects it`);
|
||||
assert.ok(!parsed.has('--pool-workers'), '--pool-workers is rejected by strata-dsv41');
|
||||
});
|
||||
|
||||
test('dsEngineArgs renames --vram-reserve-mib, leaves out --pool-workers with its value and keeps the --vision pair', () => {
|
||||
const r = dsEngineArgs([...DS_ARGS, '--vram-reserve-mib', '512', '--pool-workers', '20', '--resident-budget-gib', '40']);
|
||||
assert.deepEqual(r.args, [...DS_ARGS, '--reserve-mib', '512']);
|
||||
assert.deepEqual(r.renamed, [{ from: '--vram-reserve-mib', to: '--reserve-mib' }]);
|
||||
assert.deepEqual(r.dropped.map(d => [d.flag, d.value]), [['--pool-workers', '20'], ['--resident-budget-gib', '40']]);
|
||||
assert.match(dsArgsNote(r), /--vram-reserve-mib is passed as --reserve-mib/);
|
||||
assert.match(dsArgsNote(r), /--pool-workers 20, --resident-budget-gib 40/);
|
||||
assert.equal(dsArgsNote(dsEngineArgs(DS_ARGS)), '', 'nothing changed, nothing said');
|
||||
});
|
||||
|
||||
test('dsEngineArgs: a reserve under both names keeps the engine\'s own, a switch at the end and values that look like numbers survive', () => {
|
||||
assert.deepEqual(dsEngineArgs(['--reserve-mib', '300', '--vram-reserve-mib', '512']).args, ['--reserve-mib', '300']);
|
||||
assert.deepEqual(dsEngineArgs(['--pack', '/p', '--no-expert-cache']).args, ['--pack', '/p', '--no-expert-cache']);
|
||||
assert.deepEqual(dsEngineArgs(['--pool-workers']).args, [], 'a flag with no value');
|
||||
assert.deepEqual(dsEngineArgs(['--spec', '4', '--tp', '2', '--kv', 'int8', '--experts', 'auto']).args, ['--tp', '2', '--experts', 'auto']);
|
||||
assert.deepEqual(dsEngineArgs(undefined).args, []);
|
||||
});
|
||||
|
||||
test('dsUserArgs drops what the engine rejects and keeps the options it takes and the app\'s reserve', () => {
|
||||
assert.deepEqual(dsUserArgs(['--pool-workers', '20', '--vram-reserve-mib', '512', '--cpu-threads', '8']), ['--vram-reserve-mib', '512', '--cpu-threads', '8']);
|
||||
assert.deepEqual(dsUserArgs(['--pool-workers', '20']), []);
|
||||
});
|
||||
|
||||
test('withoutVisionFlag takes the Qwen engine\'s stand-alone --vision out, and a picture word an old file left after it', () => {
|
||||
assert.deepEqual(withoutVisionFlag(['--max-context', '4096', '--vision', '--kv', 'int8']), ['--max-context', '4096', '--kv', 'int8']);
|
||||
assert.deepEqual(withoutVisionFlag(['--a', '1', '--vision']), ['--a', '1']);
|
||||
assert.deepEqual(withoutVisionFlag(['--vision', 'off', '--eos', '1']), ['--eos', '1']);
|
||||
assert.deepEqual(withoutVisionFlag(['--vision', 'gpu', '--x']), ['--x']);
|
||||
});
|
||||
|
||||
test('#4358 #4359 #4505 #4507: a DeepSeek load with pictures off leaves the --vision pair whole and no stray word', async () => {
|
||||
const f = fixture();
|
||||
try {
|
||||
await f.native.refresh(true);
|
||||
// what the Models screen sends for a model it does not list pictures for: vision "no"
|
||||
const job = await finish(f.native, f.native.operation('load', { model: f.id, vision: 'no' }).id);
|
||||
assert.equal(job.state, 'done', job.error);
|
||||
const args = f.saved[0].args;
|
||||
assert.equal(args[args.indexOf('--vision') + 1], 'off', args.join(' '));
|
||||
assert.equal(args[args.indexOf('--eos') + 1], '1', 'the word after --eos is its value, not a left-over of --vision');
|
||||
assert.equal(args[args.indexOf('--eos') + 2], '--vision');
|
||||
assert.deepEqual(strayWords(args, new Set(['--pack', '--max-context', '--eos', '--vision', '--dspark', '--dspark-conf', '--prefill-chunk'])), []);
|
||||
assert.deepEqual(args, DS_ARGS, 'nothing was added or removed');
|
||||
} finally { await f.native.close(); f.cleanup(); }
|
||||
});
|
||||
|
||||
test('a DeepSeek model with pictures on keeps `--vision on` too', async () => {
|
||||
const f = fixture({ args: DS_ARGS.map(a => (a === 'off' ? 'on' : a)) });
|
||||
try {
|
||||
await f.native.refresh(true);
|
||||
const job = await finish(f.native, f.native.operation('load', { model: f.id, vision: 'no' }).id);
|
||||
assert.equal(job.state, 'done', job.error);
|
||||
const args = f.saved[0].args;
|
||||
assert.equal(args[args.indexOf('--vision') + 1], 'on');
|
||||
assert.equal(args[args.indexOf('--eos') + 1], '1');
|
||||
} finally { await f.native.close(); f.cleanup(); }
|
||||
});
|
||||
|
||||
test('#4504: the reserve field and the resource preference reach strata-dsv41 as --reserve-mib, with no --pool-workers', async () => {
|
||||
const f = fixture({ vram_reserve_mib: 512, ui_resource_profile: 'work', args: [...DS_ARGS, '--pool-workers', '20', '--vram-reserve-mib', '512'], args_written: [...DS_ARGS, '--pool-workers', '20', '--vram-reserve-mib', '512'], user_args: ['--pool-workers', '20'] });
|
||||
try {
|
||||
await f.native.refresh(true);
|
||||
const job = await finish(f.native, f.native.operation('load', { model: f.id, vision: 'no', resourceProfile: 'work' }).id);
|
||||
assert.equal(job.state, 'done', job.error);
|
||||
const saved = f.saved[0], args = saved.args;
|
||||
assert.ok(!args.includes('--pool-workers') && !args.includes('20'), args.join(' '));
|
||||
assert.ok(!args.includes('--vram-reserve-mib'), args.join(' '));
|
||||
assert.equal(args[args.indexOf('--reserve-mib') + 1], '512', args.join(' '));
|
||||
assert.equal(args.filter(a => a === '--reserve-mib').length, 1);
|
||||
assert.ok(!(saved.user_args ?? []).includes('--pool-workers'), 'the person\'s saved options lose it too');
|
||||
for (const flag of args.filter(a => a.startsWith('--'))) assert.ok(DS_VALUE_FLAGS.has(flag) || DS_SWITCH_FLAGS.has(flag), `${flag} is an option of strata-dsv41`);
|
||||
} finally { await f.native.close(); f.cleanup(); }
|
||||
});
|
||||
|
||||
test('the resource preference no longer writes Qwen-engine options into a DeepSeek model\'s file when it is tuned', async () => {
|
||||
const f = fixture({ args: DS_ARGS });
|
||||
try {
|
||||
await f.native.refresh(true);
|
||||
const before = JSON.parse(readFileSync(f.path, 'utf8'));
|
||||
const job = await finish(f.native, f.native.operation('tune', { model: f.id, profile: 'work', calibrate: false }).id);
|
||||
void job; // the load and benchmark after it need a real engine; the file is what matters
|
||||
const after = JSON.parse(readFileSync(f.path, 'utf8'));
|
||||
assert.ok(!(after.args ?? []).includes('--pool-workers'), (after.args ?? []).join(' '));
|
||||
assert.ok(!(after.args ?? []).includes('--vram-reserve-mib'), (after.args ?? []).join(' '));
|
||||
assert.deepEqual(after.args.slice(0, before.args.length), before.args);
|
||||
} finally { await f.native.close(); f.cleanup(); }
|
||||
});
|
||||
|
||||
test('a Qwen model with pictures off still loses its stand-alone --vision (nothing else changed)', async () => {
|
||||
const root = mkdtempSync(join(tmpdir(), 'strata-ds-args-q-'));
|
||||
const install = join(root, 'install');
|
||||
mkdirSync(install, { recursive: true });
|
||||
process.env.STRATA_INSTALL_DIR = install;
|
||||
const path = join(install, 'strata-q2_0.json');
|
||||
writeFileSync(path, JSON.stringify({ exe: 'component:strata-engine', tokenizer: join(install, 'tok'), args: ['--pack', '/p', '--max-context', '4096', '--vision', '--kv', 'int8'], model_name: 'Qwen', port: 8080 }));
|
||||
const saved = [];
|
||||
const control = {
|
||||
control: { dir: join(root, 'control') }, version: '0.2.7',
|
||||
async installedModels() { return { install_dir: install, models: [{ id: 'q2_0', name: 'Qwen', source_config: path, component_status: 'present', context_tokens: 4096 }] }; },
|
||||
async engine() { return { usable: true, backend: 'cuda', components_dir: 'E:\\c', engine: { version: '0.2.0', platform: 'windows-x86_64', backend: 'cuda', exe: 'E:\\e\\strata.exe', root: 'E:\\e' } }; },
|
||||
async saveProfile(name, file) { saved.push(JSON.parse(readFileSync(file, 'utf8'))); return {}; },
|
||||
async start() { return { ok: true, state: 'ready' }; },
|
||||
async stop() { return { ok: true }; },
|
||||
};
|
||||
const native = createNativeControl({ control, hardwareProbe: () => [{ index: 0, vram_gb: 12 }], directory: join(root, 'data'), spawnProcess: () => { throw new Error('no process'); }, fetcher: async () => Response.json({ status: 'ok' }), requests: () => [] });
|
||||
try {
|
||||
await native.refresh(true);
|
||||
const job = await finish(native, native.operation('load', { model: 'q2_0', vision: 'no' }).id);
|
||||
assert.equal(job.state, 'done', job.error);
|
||||
assert.deepEqual(saved[0].args, ['--pack', '/p', '--max-context', '4096', '--kv', 'int8']);
|
||||
} finally { await native.close(); rmSync(root, { recursive: true, force: true }); }
|
||||
});
|
||||
Reference in new issue
Block a user