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: ask the installed Control for the start wait it actually takes, and let the CLI take the runtime's ceiling (#3459 #4191)
Mike5af539691dce
diff --git a/apps/host/server/native-control.mjs b/apps/host/server/native-control.mjsindex 5a2e46493..ea528954b 100644--- a/apps/host/server/native-control.mjs+++ b/apps/host/server/native-control.mjs@@ -223,12 +223,29 @@ 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;}+ /* Control's ceiling for one start wait, read from the Control this app actually found rather than guessed from its version: the owner+ runtime takes MAX_START_WAIT (#3949), but `strata runtime start --wait` - the command the app starts a model with - validates the+ wait itself, and that validator was left at 600 s by the same change (the app says `start wait must be finite seconds in 0..600`).+ A wait above what that file accepts is refused before anything loads, so the app asks for the ceiling of the Control it has and+ keeps today's 600 s whenever it cannot read one. Reading the installed Control to learn what it supports is what the field list+ and the /v1/responses capability already do; here it reads Control's own validator instead of the server. */+ const START_WAIT_CEILING=600;+ let ceilingCache={dir:'',time:0,value:START_WAIT_CEILING};+ function startWaitCeiling(){+ const dir=control?.control?.dir??'';if(!dir)return START_WAIT_CEILING;+ let time=0;const file=join(dir,'strata_control','management.py');+ try{time=statSync(file).mtimeMs;}catch{return START_WAIT_CEILING;}+ if(ceilingCache.dir===dir&&ceilingCache.time===time)return ceilingCache.value;+ let value=START_WAIT_CEILING;+ try{+ const line=(readFileSync(file,'utf8').split(/\r?\n/).find(l=>l.includes('"start wait"'))??'');+ if(/runtime\.MAX_START_WAIT/.test(line)){ // a Control whose CLI takes the runtime's own ceiling, whatever it is+ const declared=Number(readFileSync(join(dir,'strata_control','runtime.py'),'utf8').match(/^MAX_START_WAIT\s*=\s*(\d+)/m)?.[1]);+ if(Number.isFinite(declared)&&declared>value)value=declared;+ }+ }catch{value=START_WAIT_CEILING;}+ ceilingCache={dir,time,value};return value;+ }/* How long a start waits for this model, in the same shape as `strata launch`'s figure (#3949 #3459 #4191): ten minutes, about eightmore 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,diff --git a/apps/host/tests/packaged-control.test.mjs b/apps/host/tests/packaged-control.test.mjsindex f47ca64a7..4b04d5354 100644--- a/apps/host/tests/packaged-control.test.mjs+++ b/apps/host/tests/packaged-control.test.mjs@@ -88,10 +88,20 @@ 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'], controlVersion = '0.1.45', extraSizes = [] } = {}) {+function packagedFixture({ engineUsable = true, updater = null, repair = false, ids = ['iq2_xs', 'iq3_s'], controlVersion = '0.1.45', extraSizes = [], cliStartWait = 'old' } = {}) {const root = mkdtempSync(join(tmpdir(), 'strata-packaged-test-'));const install = join(root, 'install'), data = join(root, 'data');mkdirSync(install, { recursive: true });+ /* The Control this app found, as it is on disk: the app reads the start-wait ceiling out of these two files instead of+ trusting the version, because the released Control validates the wait twice and the two numbers can disagree.+ 'old': no runtime ceiling at all, CLI takes 600. 'split': the runtime takes 1800 but the CLI still stops at 600+ (what every Control up to 0.1.52 ships). 'runtime': the CLI follows the runtime's own ceiling. */+ const controlSource = join(root, 'control', 'strata_control');+ mkdirSync(controlSource, { recursive: true });+ writeFileSync(join(controlSource, 'runtime.py'), cliStartWait === 'old' ? '' : 'MAX_START_WAIT = 1800\n');+ writeFileSync(join(controlSource, 'management.py'), cliStartWait === 'runtime'+ ? ' wait = _seconds(wait, 0, runtime.MAX_START_WAIT, "start wait")\n'+ : ' wait = _seconds(wait, 0, 600, "start wait")\n');const earlierInstallEnv = process.env.STRATA_INSTALL_DIR;process.env.STRATA_INSTALL_DIR = install; // the app's own install folder (the host always tells Control which one; it never falls back to an older CLI folder)const configs = ids.map(id => {@@ -610,8 +620,8 @@ test("onboarding 'use your own GGUF' (#3507, #3424): the models folder the perso/* 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 }] });+ const run = async (cliStartWait, downloadGb) => {+ const f = packagedFixture({ ids: ['big'], cliStartWait, 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);@@ -622,19 +632,20 @@ test('packaged: a big model is waited for by its size, inside the ceiling of thereturn { 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((await run('old', 180)).wait, 600, 'a Control whose CLI takes 600 s at most is asked for 600 s, as today');+ assert.equal((await run('split', 180)).wait, 600, 'a Control whose runtime takes 1800 s but whose CLI still stops at 600 is asked for 600 s: the CLI would refuse the start outright (#3949)');+ const long = await run('runtime', 180);+ assert.equal(long.wait, 1720, '600 s + 8 s per GB above 40 GB, as in strata launch, once the CLI really takes it');assert.equal(long.ready, 1780, 'the server readies after the start gave up, never before it');- const small = await run('0.1.50', 20);+ const small = await run('runtime', 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);+ const huge = await run('runtime', 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' });+ const f = packagedFixture({ ids: ['deepseek-v4.1-flash-ist-das-2.00bpw'], cliStartWait: 'runtime' });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);diff --git a/strata_control/management.py b/strata_control/management.pyindex c1af62523..5bfdc1503 100644--- a/strata_control/management.py+++ b/strata_control/management.py@@ -200,7 +200,10 @@ def runtime_action(action: str, profile: str, *, plan: bool = False,if type(plan) is not bool:raise ProfileError("plan must be true or false")if action == "start":- wait = _seconds(wait, 0, 600, "start wait")+ # The same ceiling the owner runtime itself enforces, read from it rather than repeated here: a start+ # may wait for a big model longer than ten minutes (#3949). The CLI used to stop at 600 s while+ # runtime.start took 1800 s, so a caller that asked what the runtime allows was refused here first.+ wait = _seconds(wait, 0, runtime.MAX_START_WAIT, "start wait")shutdown_timeout = _seconds(shutdown_timeout, 0, 300, "shutdown timeout")if_profile_revision = _profile_revision(if_profile_revision)if_source_sha256 = _optional_revision(if_source_sha256, "if_source_sha256")@@ -303,7 +306,8 @@ def runtime_action(action: str, profile: str, *, plan: bool = False,return runtime.plan_restart(profile, allow_source_switch=allow_source_switch,allow_source_migration=allow_source_migration)wait = _seconds(wait, 1, 1800, "restart wait")- startup_wait = _seconds(startup_wait, 1, 600, "startup wait")+ # Same ceiling as the restart itself takes below (#3949): a restart waits out the same big-model load a start does.+ startup_wait = _seconds(startup_wait, 1, runtime.MAX_START_WAIT, "startup wait")if (if_owner_id is None) != (if_instance_id is None):raise ProfileError("restart requires both reviewed owner and instance IDs")if (allow_source_switch or allow_source_migration) and not if_source_sha256:diff --git a/tests/terminal/test_runtime.py b/tests/terminal/test_runtime.pyindex 04dd6953f..b73c100a9 100644--- a/tests/terminal/test_runtime.py+++ b/tests/terminal/test_runtime.py@@ -1318,6 +1318,23 @@ class StartWaitLimit(unittest.TestCase):with self.assertRaisesRegex(pr.ProfileError, "reached"):rt.start("x", wait=1800)+ def test_the_cli_start_wait_takes_the_same_ceiling_as_the_runtime(self): # #3459 #4191+ # The desktop app starts models through `strata runtime start --wait`, which management validates on its way to+ # runtime.start. When only the runtime's ceiling was raised, every long start was refused here with+ # "start wait must be finite seconds in 0..600" before the engine was even reached.+ from strata_control import management as mg, profiles as pr, runtime as rt+ for wait in (601, rt.MAX_START_WAIT):+ with self.subTest(wait=wait), mock.patch.object(rt, "_name", side_effect=pr.ProfileError("reached")):+ with self.assertRaisesRegex(pr.ProfileError, "reached"):+ mg.runtime_action("start", "x", wait=wait)+ passthrough = mock.patch.object(rt, "_name", side_effect=lambda name: name)+ with passthrough:+ with self.assertRaisesRegex(pr.ProfileError, f"start wait must be finite seconds in 0..{rt.MAX_START_WAIT}"):+ mg.runtime_action("start", "x", wait=rt.MAX_START_WAIT + 1)+ with passthrough:+ with self.assertRaisesRegex(pr.ProfileError, f"startup wait must be finite seconds in 1..{rt.MAX_START_WAIT}"):+ mg.runtime_action("restart", "x", startup_wait=rt.MAX_START_WAIT + 1)+if __name__ == "__main__":unittest.main()