Drafting Off in the app: a model saved with Off loads after a restart, and the Models screen shows the saved choice (0.2.15 release test)

0.2.15 release test T6-app (p1004, the C3 app, IQ3_XXS, a home that never had an MTP layer): Drafting set to Off, Load 1 ran with no
drafter and the run config kept "drafting": "off" (15c14f6c4). After an app restart:
- Control reported the model not ready: strata_control/doctor.py counted the run config's `--mtp <folder>` as a required file unless
  the drafter is DFlash2, so with Off the never-made folder `mtp/rt` was "missing". The Models screen's button then ran "Prepare and
  load", which failed in 20 s with "Some model files are missing: the engine program, rt. Use Download / repair to restore them."
- The Models screen showed "Auto (recommended)": its effect sets the Drafting row from the saved value but did not run again when only
  that value arrived, so the next Load would have sent Auto over the saved Off.

- doctor.py: _drafter_needs_mtp(cfg): the --mtp folder is required only when a start will load the MTP layer, i.e. not with a saved
  Drafting Off and not when the choice means DFlash2 (Auto included), as before. A config that switched the layer off by hand
  ("mtp": false) is unchanged.
- NativeModels.tsx: installed?.drafting is in the effect's dependencies.
No new text.

Tests: tests/terminal/test_issues_022.py (1 new: Off needs no MTP folder on cuda sm_120 / sm_60, hip gfx1201 and cpu; MTP chosen still
needs it), apps/host/tests/drafting-kept.test.mjs (1 new: the page follows the saved drafting value). Both fail on 15c14f6c4.
This commit is contained in:
Niko1221 committed 2026-11-16 07:15:22 +01:00
1 parent 15c14f6c4e
commit c775728069
4 files changed
+36 -4

No files matched your search

+1 -1
View File
@@ -192,7 +192,7 @@ export function NativeModels({ onOtherModels, onReady, onImport, onConnectEngine
if (!contextPicked) // a context the person picked stays; otherwise 128K
setContext(defaultContext(contextList));
}
}, [selectedSize?.id, installed?.model, installed?.ready, installed?.context, installed?.contextChosen, installed?.kv, installed?.lowRamMode, installed?.resourceProfile]);
}, [selectedSize?.id, installed?.model, installed?.ready, installed?.context, installed?.contextChosen, installed?.kv, installed?.lowRamMode, installed?.drafting, installed?.resourceProfile]); // drafting too: the saved choice that arrives after the page opened (an app restart) is the one shown, not Auto (0.2.15 release test)
const pickVision = (next: string) => { if (selectedSize) visionPicks.current.set(selectedSize.id, next); setVision(next); };
useEffect(() => { if (jobId && job?.state === 'done' && job.id !== toastedJob && (job.kind === 'load' || job.kind === 'install')) {
setToastedJob(job.id);
+8
View File
@@ -26,3 +26,11 @@ test('the run-config write at ready starts from the file as it is now, so the sa
assert.match(helper, /checkedSettingsConfig\(readFileSync\(path,'utf8'\)\)/);
assert.match(helper, /catch\{return fallback;\}/);
});
test('after an app restart the Models screen shows the saved Drafting choice: the page follows the saved value when it arrives', () => {
const screen = readFileSync(fileURLToPath(new URL('../src/components/NativeModels.tsx', import.meta.url)), 'utf8').replace(/\r\n/g, '\n');
const at = screen.indexOf("setDrafting(installed.drafting ?? 'auto');");
assert.ok(at > 0, 'the page opens a model with its saved choice');
const deps = screen.slice(screen.indexOf('}, [', at), screen.indexOf(']);', at));
assert.match(deps, /installed\?\.drafting/, 'a saved choice that arrives after the page opened is shown (otherwise the next Load sends Auto)');
});
+17 -3
View File
@@ -53,6 +53,20 @@ def _drafter_is_dflash2(cfg: dict) -> bool:
return False
def _drafter_needs_mtp(cfg: dict) -> bool:
"""Will a start of this run config load the MTP layer? Not when the saved Drafting choice is Off, and not when the choice means DFlash2 (Auto
included). Only then is the --mtp folder a required file (0.2.15 release test: an app model saved with Off and no MTP folder was reported as missing
"rt" after a restart and could not load). A config that switched the layer off by hand ("mtp": false) is unchanged. Never raises; unknown keeps it
required."""
try:
from strata_control import drafting
if drafting.normalize(cfg.get("drafting")) == "off":
return False
except Exception: # noqa: BLE001 - unknown: decided below
pass
return not _drafter_is_dflash2(cfg)
def _item(name: str, path: Path, kind: str, *, required: bool = True) -> dict:
try:
if kind == "file":
@@ -216,9 +230,9 @@ def inspect(config_path: Path | None, *, profile_id: str | None = None, live: bo
except ValueError:
pass
kind = "file"
# The MTP layer is one of two drafters, never both: a model whose drafter is DFlash2 has no layer on disk, and the run config keeps `--mtp <folder>` for a
# later switch to the MTP. Its absence then does not make the model unusable (strata_control/drafting.py loads the drafter that is there).
components.append(_item(arg.lstrip("-"), _location(raw, cfg, config_path), kind, required=not (arg == "--mtp" and _drafter_is_dflash2(cfg))))
# The MTP layer is one of two drafters, never both: a model whose drafter is DFlash2, or Off, has no layer on disk, and the run config keeps `--mtp <folder>`
# for a later switch to the MTP. Its absence then does not make the model unusable (strata_control/drafting.py loads the drafter that is there).
components.append(_item(arg.lstrip("-"), _location(raw, cfg, config_path), kind, required=not (arg == "--mtp" and not _drafter_needs_mtp(cfg))))
vision = cfg.get("vision")
if isinstance(vision, dict):
+10
View File
@@ -493,3 +493,13 @@ class DoctorAndTheDrafter(unittest.TestCase):
self.assertEqual(self.report()["status"], "optional_missing", "Intel is DFlash2 too")
with mock.patch.object(drafting, "detect_hardware", return_value=("cpu", [])):
self.assertEqual(self.report()["status"], "missing", "an engine without the code stays on the MTP")
def test_a_model_saved_with_off_needs_no_mtp_folder(self):
"""0.2.15 release test (the app, after a restart): a model saved with Drafting Off and no MTP folder was "missing rt" and could not load."""
from unittest import mock
from strata_control import drafting
for hardware in (("cuda", ["sm_120"]), ("cuda", ["sm_60"]), ("hip", ["gfx1201"]), ("cpu", [])):
with mock.patch.object(drafting, "detect_hardware", return_value=hardware):
self.assertEqual(self.report(drafting="off")["status"], "optional_missing", hardware)
self.assertEqual(self.report(drafting="OFF")["status"], "optional_missing", hardware)
self.assertEqual(self.report(drafting="mtp")["status"], "missing", "the MTP chosen still needs its layer")