Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
GUI: the start wait follows the model's size, as `strata launch` does, and never asks an older Control for more than it takes (#3459 #4191)
Mike0e72aff563db
diff --git a/apps/host/server/native-control.mjs b/apps/host/server/native-control.mjsindex 895ec054f..5a2e46493 100644--- a/apps/host/server/native-control.mjs+++ b/apps/host/server/native-control.mjs@@ -223,6 +223,23 @@ return {summary:result.summary??'Deleted',removed:result.plan?.gb??null};}const DS_EXPERTS_MIN=[0,1,50];function dsEngineVersion(config){const m=/engine-dsv41[\\/](\d+(?:\.\d+)+)-/.exec(String(config?.exe??''))||/engine-dsv41[\\/](\d+(?:\.\d+)+)-/.exec(String((config?.lib_dirs??[])[0]??''));return m?m[1].split('.').map(Number):null;}function dsExpertsSupported(config){const v=dsEngineVersion(config);if(!v)return false;for(let i=0;i<DS_EXPERTS_MIN.length;i++){const a=v[i]??0,b=DS_EXPERTS_MIN[i];if(a!==b)return a>b;}return true;}+ /* Control's ceiling for one start wait: 600 s until Control 0.1.50, 1800 s from there (the 0.1.50 runtime takes a longer wait for a+ big model, #3949). Control rejects a wait above its own ceiling before it starts anything, so asking an older Control for 1800 s+ would stop every load: the app asks for what the Control it has accepts, and keeps today's 600 s when it cannot tell. */+ const CONTROL_LONG_START_MIN=[0,1,50],START_WAIT_CEILING=600,START_WAIT_CEILING_LONG=1800;+ function controlAllowsLongStart(){const v=String(control?.version??'').split('.').map(x=>Number.parseInt(x,10)||0);for(let i=0;i<CONTROL_LONG_START_MIN.length;i++){const a=v[i]??0,b=CONTROL_LONG_START_MIN[i];if(a!==b)return a>b;}return true;}+ function startWaitCeiling(){return controlAllowsLongStart()?START_WAIT_CEILING_LONG:START_WAIT_CEILING;}+ /* How long a start waits for this model, in the same shape as `strata launch`'s figure (#3949 #3459 #4191): ten minutes, about eight+ more seconds per GB above 40 GB, never more than this Control accepts. A model nobody can size keeps the 300 s it always had.+ The run config's engine_ready_s is the floor, not the ceiling: the server reads that number and ends the engine when it runs out,+ so the start must never give up before the server does (setup writes 3600 for DeepSeek V4.1-Flash). */+ function startWaitFor(config,entry,model){+ const ceiling=startWaitCeiling(),ready=Number(config?.engine_ready_s)||0;+ const known=Number(entry?.diskGb),fromDisk=Number.isFinite(known)&&known>0?known:0;+ const gb=fromDisk||Number((snapshot.catalog?.families??[]).flatMap(f=>f.sizes??[]).find(s=>s.id===model)?.download_gb)||0;+ const sized=gb>40?Math.max(300,600+(gb-40)*8):300;+ return Math.trunc(Math.max(300,Math.min(ceiling,Math.max(ready,sized))));+ }function buildConfig(args,config){const vision=runtimeVision(config,args.vision);const visionPreferences=args.vision!==undefined?{ui_vision_enabled:args.vision!=='no',ui_vision_device:args.vision==='no'?config.ui_vision_device??'yes':args.vision}:{};@@ -300,12 +317,18 @@ return {summary:result.summary??'Deleted',removed:result.plan?.gb??null};}/* Another model on the same graphics card: the engine takes the card's free memory, so a second one usually finds none. Loading goes on (recommend, never force); if it fails, the reason is said. */const sharedWith=instance.gpus.length?[...instances.values()].find(i=>i.id!==id&&i.status!=='error'&&i.model!==args.model&&i.gpus.some(g=>instance.gpus.includes(g))):null;const sharedSentence=sharedWith?`GPU ${instance.gpus.find(g=>sharedWith.gpus.includes(g))+1} is already used by ${sharedWith.label}, so this model did not fit there. Load it on another GPU, or unload ${sharedWith.label} first.`:null;- let proc=null,started=null,retried=null;+ let proc=null,started=null,retried=null,startWait=null;if(packaged){+ /* How long this start waits, and the server's own engine wait kept above it. The server ends the engine when its engine wait runs+ out (900 s, or the config's engine_ready_s), so a start that waits longer than that can never win: as in `strata launch`, the+ server gets a wait above the start's. It is only ever raised, never lowered, so a config that already names a longer one+ (setup's 3600 for DeepSeek V4.1-Flash) is left alone. */+ startWait=startWaitFor(config,entry,args.model);+ if(startWait+60>Math.max(900,Number(cfg.engine_ready_s)||0))cfg.engine_ready_s=startWait+60;/* 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();- 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:ownEngine(config)?Math.min(600,Math.max(300,Number(config.engine_ready_s)||300)):300}));};+ 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);});try{await started;}catch(firstError){let error=firstError;diff --git a/apps/host/tests/packaged-control.test.mjs b/apps/host/tests/packaged-control.test.mjsindex 71ce42583..f47ca64a7 100644--- a/apps/host/tests/packaged-control.test.mjs+++ b/apps/host/tests/packaged-control.test.mjs@@ -88,7 +88,7 @@ test('runCli passes the arguments untouched (no shell) and reads JSON', async ()// ---------------------------------------------------------------------------------- native-control in packaged mode-function packagedFixture({ engineUsable = true, updater = null, repair = false, ids = ['iq2_xs', 'iq3_s'] } = {}) {+function packagedFixture({ engineUsable = true, updater = null, repair = false, ids = ['iq2_xs', 'iq3_s'], controlVersion = '0.1.45', extraSizes = [] } = {}) {const root = mkdtempSync(join(tmpdir(), 'strata-packaged-test-'));const install = join(root, 'install'), data = join(root, 'data');mkdirSync(install, { recursive: true });@@ -105,7 +105,7 @@ function packagedFixture({ engineUsable = true, updater = null, repair = false,const rpc = [];let startFailure = null, startFailureLeft = Infinity;const control = {- control: { dir: join(root, 'control'), python: join(root, 'control', 'python', 'python.exe') }, version: '0.1.45',+ control: { dir: join(root, 'control'), python: join(root, 'control', 'python', 'python.exe') }, version: controlVersion,async installedModels(options) { calls.push(['installedModels', options?.installDir ?? null]); return { install_dir: install, models: configs.map(c => ({ id: c.id, name: `Qwen ${c.id}`, source_config: c.path, component_status: 'present', context_tokens: 32768, backend: 'cuda' })) }; },async engine() {calls.push(['engine']);@@ -126,7 +126,7 @@ function packagedFixture({ engineUsable = true, updater = null, repair = false,// answers like it: the catalog, the hardware with the GPUs, and an install plan or job.const catalog = { families: [{ family: 'qwen', title: 'Qwen3.8-Flash-Next', about: 'x', images: true, experimental: false, sizes: [{ id: 'q2_0', model: 'Q2_0', download_gb: 66.4, ram_needed_gb: 48, about: 'fast', on_this_pc: 'fits', installed: false, images: true, experimental: false },- { id: 'iq3_xxs', model: 'IQ3_XXS', download_gb: 75.8, ram_needed_gb: 60, about: 'balanced', on_this_pc: 'fits', installed: false, images: true, experimental: false }] }],+ { id: 'iq3_xxs', model: 'IQ3_XXS', download_gb: 75.8, ram_needed_gb: 60, about: 'balanced', on_this_pc: 'fits', installed: false, images: true, experimental: false }, ...extraSizes] }],contexts: [8192, 32768], recommendation: { family: 'qwen', model: 'IQ3_XXS', context: 32768 }, context_note: '' };const hardware = { ram_gb: 63, cpu: { name: 'cpu', cores: 12 }, gpus: [{ index: 0, name: 'NVIDIA GeForce RTX 5070', vram_gb: 11.9, usable: true }] };let installJob = null;@@ -606,3 +606,41 @@ test("onboarding 'use your own GGUF' (#3507, #3424): the models folder the persoassert.ok(sent.data_dir === undefined || sent.data_dir === join(f.root, 'Strata-data'), `data_dir was ${sent.data_dir}`);} finally { await f.native.close(); f.cleanup(); }});++/* The start wait follows the model's size, as `strata launch` does since #3949, and never asks an older Control for more than it takes.+ Reported on the app side by #3459 and #4191: a big model on a slow disk was stopped at 300 s while the engine went on reading. */+test('packaged: a big model is waited for by its size, inside the ceiling of the Control this app has (#3459 #4191)', async () => {+ const run = async (controlVersion, downloadGb) => {+ const f = packagedFixture({ ids: ['big'], controlVersion, extraSizes: [{ id: 'big', model: 'BIG', download_gb: downloadGb, ram_needed_gb: 60, about: 'x', on_this_pc: 'fits', installed: false, images: false, experimental: false }] });+ try {+ await f.native.refresh(true);+ const job = await finish(f.native, f.native.operation('load', { model: 'big' }).id);+ assert.equal(job.state, 'done', job.error);+ const start = f.calls.find(c => c[0] === 'start');+ const saved = f.saved[0];+ await f.native.close();+ return { wait: start[2], ready: saved.engine_ready_s };+ } finally { f.cleanup(); }+ };+ assert.equal((await run('0.1.45', 180)).wait, 600, 'an older Control takes 600 s at most, as today');+ const long = await run('0.1.50', 180);+ assert.equal(long.wait, 1720, '600 s + 8 s per GB above 40 GB, as in strata launch');+ assert.equal(long.ready, 1780, 'the server readies after the start gave up, never before it');+ const small = await run('0.1.50', 20);+ assert.equal(small.wait, 300, 'a model under 40 GB keeps the 300 s it always had');+ assert.equal(small.ready, undefined, 'nothing is added to a small model’s run config');+ const huge = await run('0.1.50', 400);+ assert.equal(huge.wait, 1800, 'and never more than this Control accepts');+});++test('packaged: a run config that names a longer engine wait is honoured, and never shortened by the app', async () => {+ const f = packagedFixture({ ids: ['deepseek-v4.1-flash-ist-das-2.00bpw'], controlVersion: '0.1.50' });+ try {+ writeFileSync(join(f.install, 'strata-deepseek-v4.1-flash-ist-das-2.00bpw.json'), JSON.stringify({ exe: join(f.install, 'engine-dsv41', 'strata-dsv41'), arch: 'deepseek41', tokenizer: join(f.install, 'tok'), args: ['--pack', join(f.install, 'pack')], model_name: 'deepseek-v4.1-flash', port: 8080, engine_ready_s: 3600 }));+ await f.native.refresh(true);+ const job = await finish(f.native, f.native.operation('load', { model: 'deepseek-v4.1-flash-ist-das-2.00bpw' }).id);+ assert.equal(job.state, 'done', job.error);+ assert.equal(f.calls.find(c => c[0] === 'start')[2], 1800, 'the wait of the newest Control, which is what the ceiling allows');+ assert.equal(f.saved[0].engine_ready_s, 3600, 'setup’s own longer wait stays as it is');+ } finally { await f.native.close(); f.cleanup(); }+});