okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge commit 'b8d604d28' into f-clean-1ab0fc432ed

main
24.6 KiB453 linesraw
1"""`strata tune auto` (the real tuner) and `strata presets` (the saved results), for the Terminal and, through JSON output
2and a status file, for the desktop app. The same code and the same store serve both."""
3
4from __future__ import annotations
5
6import argparse
7import atexit
8import json
9import os
10import shutil
11import sys
12import tempfile
13import threading
14from strata_control import atomic as _atomic_mod
15from pathlib import Path
16from typing import Any
17
18
19# --------------------------------------------------------------------------- parsers
20
21def add_tune_auto(tune_sp: argparse._SubParsersAction) -> None:
22    p = tune_sp.add_parser(
23        "auto", help="find the fastest settings for this PC and save them as a preset (quick: about 20 minutes)",
24        description="Measures your configuration, tries single-knob changes in interleaved rounds against it, keeps only gains "
25                    "above the noise, and saves the result as a named preset that is applied at every start. "
26                    "Nothing changes if the current settings are already the fastest.")
27    p.add_argument("target", help="a saved profile name or a run configuration (JSON) to tune")
28    p.add_argument("--mode", choices=("quick", "thorough"), default="quick",
29                   help="quick: about 20 minutes. thorough: up to 2 hours, 5-pair confirmation (default quick)")
30    p.add_argument("--goal", default="speed", help="speed (full performance), room (leave memory free), or room:MiB "
31                                                   "(leave that much graphics memory free)")
32    p.add_argument("--leave-ram", type=int, default=0, metavar="PERCENT", help="leave this share of system memory free (0-50)")
33    p.add_argument("--use", choices=("chat", "coding"), default="chat", help="coding judges long-prompt speed as well")
34    p.add_argument("--allow-small-differences", action="store_true",
35                   help="also try settings that can change answers slightly (expert cache split, speculative window)")
36    p.add_argument("--allow-not-repeatable", action="store_true", help="also try settings whose answers are not repeatable")
37    p.add_argument("--name", default=None, help="the preset's name (default: model, context and your wish)")
38    p.add_argument("--time", dest="minutes", type=float, default=None, help="time to spend, in minutes")
39    p.add_argument("--no-save", action="store_true", help="measure and report, but do not save a preset")
40    p.add_argument("--gpu-lock", default=os.environ.get("STRATA_TUNE_GPU_LOCK"),
41                   help="a lock file held around every engine run (shared boxes)")
42    p.add_argument("--no-quiet-check", action="store_true", help="do not wait for other engines or a busy CPU")
43    p.add_argument("--serve-dir", default=None, help="the folder that holds serve/ (default: this installation)")
44    p.add_argument("--work-dir", default=None, help="where the run's configs and logs go (default: a temp folder)")
45    p.add_argument("--status-file", default=None, help="progress as JSON, rewritten at every step (for the desktop app)")
46    p.add_argument("--boot-timeout", type=float, default=900.0)
47    p.add_argument("--output", choices=("human", "json"), default="human")
48
49
50def add_presets(sp: argparse._SubParsersAction) -> None:
51    pr = sp.add_parser("presets", help="saved tuning presets: list, apply, rename, delete, undo, re-check")
52    psp = pr.add_subparsers(dest="presets_command", required=True)
53
54    def common(x: argparse.ArgumentParser) -> argparse.ArgumentParser:
55        x.add_argument("--output", choices=("human", "json"), default="human")
56        return x
57
58    l = common(psp.add_parser("list", help="every saved preset (or those for one model/configuration)"))
59    l.add_argument("--model", default=None, help="only presets whose model or quant contains this text")
60    s = common(psp.add_parser("status", help="which preset a configuration would start with, and whether it is still valid"))
61    s.add_argument("target", help="a saved profile name or a run configuration (JSON)")
62    sh = common(psp.add_parser("show", help="one preset in full"))
63    sh.add_argument("preset")
64    ap = common(psp.add_parser("apply", help="make a preset the active one for its choices (the previous one is kept for undo)"))
65    ap.add_argument("preset")
66    rn = common(psp.add_parser("rename", help="give a preset another name"))
67    rn.add_argument("preset")
68    rn.add_argument("name")
69    de = common(psp.add_parser("delete", help="delete a preset"))
70    de.add_argument("preset")
71    un = common(psp.add_parser("undo", help="go back to the preset that was active before (or the standard settings)"))
72    un.add_argument("preset", help="a preset, or a configuration target with --config")
73    un.add_argument("--config", default=None, help="a profile name or run configuration whose slot to undo")
74    ex = common(psp.add_parser("export", help="write a preset to a file (or print it)"))
75    ex.add_argument("preset")
76    ex.add_argument("--file", default=None)
77    im = common(psp.add_parser("import", help="read a preset from a file"))
78    im.add_argument("file")
79    ef = common(psp.add_parser("effective", help="what a start with these choices will actually run: the saved tuning's values on top of the configuration"))
80    ef.add_argument("target", help="a saved profile name or a run configuration (JSON)")
81    of = common(psp.add_parser("off", help="switch the saved tuning off for these choices (back to the standard settings; it is kept and can be switched on again)"))
82    of.add_argument("target", help="a saved profile name or a run configuration (JSON)")
83    rc = common(psp.add_parser("recheck", help="a short check (about 2 minutes) that a preset is still as fast"))
84    rc.add_argument("preset")
85    rc.add_argument("target", help="the profile name or run configuration the preset belongs to")
86    rc.add_argument("--gpu-lock", default=os.environ.get("STRATA_TUNE_GPU_LOCK"))
87    rc.add_argument("--serve-dir", default=None)
88    rc.add_argument("--work-dir", default=None)
89    rc.add_argument("--status-file", default=None)
90    rc.add_argument("--boot-timeout", type=float, default=900.0)
91    rc.add_argument("--no-quiet-check", action="store_true")
92
93
94# --------------------------------------------------------------------------- helpers
95
96def _print(payload: dict[str, Any], machine: bool, human: str) -> int:
97    if machine:
98        print(json.dumps({"schema_version": 1, "ok": True, **payload}, ensure_ascii=False, default=str))
99    else:
100        print(human)
101    return 0
102
103
104def _fail(message: str, code: int, machine: bool) -> int:
105    if machine:
106        print(json.dumps({"schema_version": 1, "ok": False, "error": {"code": code, "message": message}}))
107    else:
108        print(f"strata: {message}", file=sys.stderr)
109    return code
110
111
112def _load_target(target: str) -> tuple[Path, dict[str, Any]]:
113    from strata_control import profiles
114    path, _profile, _rev = profiles.resolve(target)
115    return path, profiles.read_run_config(path)
116
117
118def _engine_exe(cfg: dict[str, Any]) -> str:
119    from strata_control import engine_component
120    ref = cfg.get("exe")
121    if engine_component.is_reference(ref):
122        return engine_component.expand(ref, cfg, full=False)
123    p = Path(ref)
124    return str(p if p.is_absolute() else Path(cfg.get("cwd") or ".") / p)
125
126
127def _serve_dir(a: argparse.Namespace) -> Path:
128    if getattr(a, "serve_dir", None):
129        return Path(a.serve_dir)
130    return Path(__file__).resolve().parent.parent
131
132
133def _lock_factory(a: argparse.Namespace, log):
134    if not getattr(a, "gpu_lock", None):
135        return None
136    from strata_control.tune_session import FileLock
137    return lambda: FileLock(a.gpu_lock, log=log)
138
139
140def _parse_goal(text: str) -> tuple[str, int]:
141    if text in ("speed", "full"):
142        return "speed", 0
143    if text == "room":
144        return "room", 0
145    if text.startswith("room:"):
146        return "room", max(0, int(text[5:]))
147    raise ValueError("goal is speed, room or room:MiB")
148
149
150def _write_status(path: str | None, payload: dict[str, Any]) -> None:
151    if not path:
152        return
153    try:
154        tmp = path + ".tmp"
155        Path(tmp).write_text(json.dumps(payload, ensure_ascii=False, default=str), encoding="utf-8")
156        _atomic_mod.replace(tmp, path)
157    except OSError:
158        pass
159
160
161def minutes_text(seconds: float | None) -> str:
162    if seconds is None:
163        return ""
164    m = max(1, int(round(seconds / 60.0)))
165    return f"about {m} min left"
166
167
168def _hw_hash(identity: dict[str, Any]) -> str:
169    from strata_control import tune_machine
170    return tune_machine.stable_hash((identity.get("hardware") or {}).get("hard"))
171
172
173# --------------------------------------------------------------------------- tune auto
174
175def auto(a: argparse.Namespace) -> int:
176    from strata_control import autotune, engine_component, presets, tuning
177    from strata_control.tune_session import WorkerSession
178
179    machine = a.output == "json"
180    try:
181        goal, reserve = _parse_goal(a.goal)
182        cfg_path, cfg = _load_target(a.target)
183    except Exception as e:  # noqa: BLE001
184        return _fail(str(e), getattr(e, "exit_code", 2), machine)
185    if not 0 <= a.leave_ram <= 50:
186        return _fail("--leave-ram is a percentage from 0 to 50", 2, machine)
187    if a.leave_ram and goal == "speed":
188        goal = "room"
189    exe = _engine_exe(cfg)
190    if not Path(exe).exists():
191        return _fail(f"no engine was found at {exe}", 5, machine)
192    identity = presets.current_identity(cfg, exe=exe)
193    backend = (identity.get("engine") or {}).get("backend") or engine_component.detect_backend()[0] or "cpu"
194    flags = tuning.engine_flag_inventory(Path(exe))
195    opts = autotune.Options(mode=a.mode, goal=goal, reserve_mib=reserve, ram_wish_pct=a.leave_ram, use=a.use,
196                            allow_placement=a.allow_small_differences, allow_nonrepeatable=a.allow_not_repeatable,
197                            budget_s=(a.minutes * 60.0 if a.minutes else None), check_busy=not a.no_quiet_check)
198    ctx = autotune.context_from_config(cfg, engine_backend=backend, opts=opts, engine_flags=flags)
199    hw = _hw_hash(identity)
200    digest = (identity.get("model") or {}).get("sha256_shard1")
201    bad = presets.bad_signatures(hw_hash=hw, model_digest=digest, engine_sha=(identity.get("engine") or {}).get("sha256"))
202
203    cancel = threading.Event()
204    state: dict[str, Any] = {"stage": "start", "message": "Starting", "state": "running"}
205
206    def say(line: str) -> None:
207        if not machine:
208            print(line, file=sys.stderr, flush=True)
209
210    def progress(p: dict[str, Any]) -> None:
211        state.update(p)
212        state["minutes_left"] = None if p.get("eta_s") is None else max(1, int(round(p["eta_s"] / 60.0)))
213        state["text"] = (f"Finding the fastest settings for your PC… {minutes_text(p.get('eta_s'))}"
214                         if p.get("eta_s") is not None else "Finding the fastest settings for your PC…")
215        _write_status(a.status_file, state)
216        say(f"[{p.get('elapsed_s', 0) // 60:>3d}m] {p['message']}" + (f"  ({minutes_text(p['eta_s'])})" if p.get("eta_s") else ""))
217
218    workdir = Path(a.work_dir) if a.work_dir else Path(tempfile.mkdtemp(prefix="strata-tune-"))
219    if not a.work_dir:
220        atexit.register(shutil.rmtree, workdir, True)       # its own scratch folder goes with the run (--work-dir keeps the logs)
221    session = WorkerSession(base_config=cfg, python=sys.executable, serve_dir=_serve_dir(a), workdir=workdir,
222                            boot_timeout_s=a.boot_timeout, lock=_lock_factory(a, say), log=say)
223    base_args = [str(x) for x in cfg.get("args") or []]
224    # the wish becomes part of the base: leave-room asks the engine for the reserve if the configuration has none yet
225    if goal == "room" and reserve and "--vram-reserve-mib" not in base_args and ctx.family == "flash-next" \
226            and backend in ("cuda", "hip") and (flags is None or "--vram-reserve-mib" in flags):
227        base_args += ["--vram-reserve-mib", str(reserve)]
228        ctx.base_args = list(base_args)
229    tuner = autotune.Tuner(session, base_args, dict(cfg.get("env") or {}), ctx, opts, progress=progress, cancel=cancel,
230                           history_bad=bad, quiet=None)
231    say(f"Tuning {presets.choices_from_config(cfg).get('model')} ({a.mode}); engine {exe}")
232    try:
233        result = tuner.run()
234    except KeyboardInterrupt:
235        cancel.set()
236        result = tuner.result
237        result.outcome, result.message = "cancelled", "Stopped. Your settings were not changed."
238    out = result.to_dict()
239    choices = presets.choices_from_config(cfg, use=a.use)
240    choices["goal"], choices["reserve_mib"] = goal, reserve
241    if a.leave_ram:
242        choices["leave_ram_pct"] = a.leave_ram
243    saved = None
244    try:
245        presets.record_trials(result.trials, hw_hash=hw, model_digest=digest,
246                              engine_sha=(identity.get("engine") or {}).get("sha256"))
247    except OSError:
248        pass
249    if result.outcome in ("improved", "default_confirmed") and not a.no_save:
250        try:
251            saved = presets.create(out, choices=choices, identity=identity, name=a.name, mode=a.mode)
252        except presets.PresetError as e:
253            result.notes.append(str(e))
254    out["preset"] = ({"id": saved["id"], "name": saved["name"]} if saved else None)
255    autotune.Tuner.finalize(result)
256    out.update({"code": result.code, "reason_code": result.reason_code, "values": result.values})
257    out["values"]["preset_name"] = saved["name"] if saved else None
258    state.update({"state": "done", "result": out, "stage": "done"})
259    _write_status(a.status_file, state)
260    if machine:
261        print(json.dumps({"schema_version": 1, "ok": True, "result": out}, ensure_ascii=False, default=str))
262    else:
263        print(_human_result(out, saved))
264    return {"improved": 0, "default_confirmed": 0, "cancelled": 130}.get(result.outcome, 6)
265
266
267def _human_result(r: dict[str, Any], saved: dict[str, Any] | None) -> str:
268    lines = [""]
269    if r["outcome"] == "improved":
270        lines.append(f"Done in {r['seconds'] / 60:.0f} min: +{r['gain_pct']:.0f}% faster answers"
271                     + (f", saved as '{saved['name']}'." if saved else "."))
272        s = r["settings"]
273        shown = {**{k: v for k, v in s["args"].items()}, **s["env"], **{f"per request {k}": v for k, v in s["per_request"].items()}}
274        lines.append("  Changed: " + ", ".join(f"{k} {v}" for k, v in shown.items()))
275        lines.append(f"  Measured: {r['base'].get('decode_tok_s')} -> {r['chosen'].get('decode_tok_s')} tok/s "
276                     f"({r['faster_pairs']} of {r['pairs']} pairs faster)")
277        from strata_control.tune_knobs import ANSWER_NOTICE
278        from strata_control.tune_knobs import ANSWER_NOTICE_UNSTEADY
279        unsteady = r["answers"].get("default_repeatable") is False and r["answers"]["class"] in ANSWER_NOTICE_UNSTEADY
280        lines.append("  " + (ANSWER_NOTICE_UNSTEADY if unsteady else ANSWER_NOTICE).get(r["answers"]["class"], ""))
281    else:
282        lines.append(r["message"] or r["outcome"])
283        if saved:
284            lines.append(f"  Saved as '{saved['name']}' so it is not tuned again on reopen.")
285    for n in r.get("notes") or []:
286        lines.append(f"  note: {n}")
287    return "\n".join(lines)
288
289
290# --------------------------------------------------------------------------- presets
291
292def presets_command(a: argparse.Namespace) -> int:
293    from strata_control import presets
294
295    machine = a.output == "json"
296    cmd = a.presets_command
297    try:
298        if cmd == "list":
299            items = presets.list_presets(model=a.model)
300            human = "\n".join(f"{'*' if p['active'] else ' '} {p['id'][:8]}  {p['name']}  "
301                              f"{(p.get('measured') or {}).get('gain_pct') or 0:+.0f}%  {p['answers']['class']}"
302                              for p in items) or "No saved presets yet. Run: strata tune auto <profile>"
303            return _print({"presets": [_summary(p) for p in items]}, machine, human)
304        if cmd == "status":
305            return _status(a, machine)
306        if cmd == "effective":
307            return _effective(a, machine)
308        if cmd == "off":
309            return _off(a, machine)
310        if cmd == "show":
311            p = presets.find(a.preset)
312            return _print({"preset": p}, machine, json.dumps(p, indent=2, ensure_ascii=False))
313        if cmd == "apply":
314            p = presets.activate_preset(a.preset)
315            return _print({"preset": _summary(p), "notice": presets.notice(p)}, machine,
316                          f"'{p['name']}' is now active. It is used the next time the model starts. Undo: strata presets undo {p['id'][:8]}")
317        if cmd == "rename":
318            p = presets.rename(a.preset, a.name)
319            return _print({"preset": _summary(p)}, machine, f"Renamed to '{p['name']}'.")
320        if cmd == "delete":
321            p = presets.find(a.preset)
322            presets.delete(a.preset)
323            return _print({"deleted": p["id"]}, machine, f"Deleted '{p['name']}'.")
324        if cmd == "undo":
325            if a.config:
326                _path, cfg = _load_target(a.config)
327                ident = presets.current_identity(cfg)
328                slot = presets.slot_key(presets.choices_from_config(cfg), (ident.get("model") or {}).get("sha256_shard1"))
329            else:
330                slot = a.preset
331            back = presets.undo(slot)
332            return _print({"active": _summary(back) if back else None}, machine,
333                          f"Back to '{back['name']}'." if back else "Back to the standard settings.")
334        if cmd == "export":
335            data = presets.export_preset(a.preset)
336            if a.file:
337                Path(a.file).write_text(json.dumps(data, indent=2, ensure_ascii=False), encoding="utf-8")
338                return _print({"file": a.file}, machine, f"Wrote {a.file}")
339            print(json.dumps(data, indent=2, ensure_ascii=False))
340            return 0
341        if cmd == "import":
342            data = json.loads(Path(a.file).read_text(encoding="utf-8-sig"))
343            p = presets.import_preset(data)
344            return _print({"preset": _summary(p)}, machine, f"Imported '{p['name']}'. Apply it with: strata presets apply {p['id'][:8]}")
345        if cmd == "recheck":
346            return _recheck(a, machine)
347    except presets.PresetError as e:
348        return _fail(str(e), 5, machine)
349    except (OSError, ValueError) as e:
350        return _fail(str(e), getattr(e, "exit_code", 2), machine)
351    return _fail("unknown presets command", 2, machine)
352
353
354def _summary(p: dict[str, Any]) -> dict[str, Any]:
355    from strata_control import presets
356    m = p.get("measured") or {}
357    return {"id": p["id"], "name": p["name"], "active": bool(p.get("active")), "created": p.get("created"),
358            "choices": p.get("choices"), "settings": p.get("settings"), "answers": p.get("answers"),
359            "notice": presets.notice(p), "gain_pct": m.get("gain_pct"), "decode_tok_s": m.get("decode_tok_s"),
360            "baseline_decode_tok_s": (p.get("baseline") or {}).get("decode_tok_s"), "tuner": p.get("tuner"),
361            "recheck": p.get("recheck"), "slot": p.get("slot")}
362
363
364def _effective(a: argparse.Namespace, machine: bool) -> int:
365    """The values a start will really use (owner feedback, item 11): the configuration with the active saved tuning put on top,
366    plus the list of what the tuning changed, so Expert mode can show the tuned numbers and not the untuned ones."""
367    from strata_control import presets, tune_knobs
368    _path, cfg = _load_target(a.target)
369    merged, info = presets.overlay(cfg)
370    before = [str(x) for x in cfg.get("args") or []]
371    after = [str(x) for x in merged.get("args") or []]
372    changed = []
373    for flag in sorted({x for x in before + after if x.startswith("--")}):
374        was, now = tune_knobs._current(before, flag), tune_knobs._current(after, flag)
375        if was != now:
376            changed.append({"flag": flag, "was": was, "now": now})
377    payload = {"applied": bool(info.get("applied")), "preset": info.get("preset"), "state": info.get("state"), "reasons": info.get("reasons", []),
378               "why_not": info.get("why_not"), "warnings": info.get("warnings") or [], "notice": info.get("notice"),
379               "args": merged.get("args"), "env": merged.get("env") or {},
380               "sampling": merged.get("sampling") or {}, "changed": changed, "per_request": info.get("per_request") or {}}
381    human = (f"Using your tuning '{info['preset']['name']}'" if info.get("applied") else "No saved tuning is applied; the standard settings run.")
382    return _print(payload, machine, human)
383
384
385def _off(a: argparse.Namespace, machine: bool) -> int:
386    """Switch the saved tuning off for these choices. It is kept (and listed), so switching it back on is one step."""
387    from strata_control import presets
388    _path, cfg = _load_target(a.target)
389    ident = presets.current_identity(cfg)
390    slot = presets.slot_key(presets.choices_from_config(cfg), (ident.get("model") or {}).get("sha256_shard1"))
391    presets.deactivate_slot(slot)
392    return _print({"active": None}, machine, "Back to the standard settings. Your tuning is kept and can be switched on again.")
393
394
395def _status(a: argparse.Namespace, machine: bool) -> int:
396    from strata_control import presets
397    _path, cfg = _load_target(a.target)
398    ident = presets.current_identity(cfg)
399    choices = presets.choices_from_config(cfg)
400    slot = presets.slot_key(choices, (ident.get("model") or {}).get("sha256_shard1"))
401    idx = presets._index().get(slot) or {}
402    items = [p for p in presets.list_presets() if p.get("slot") == slot]
403    active = next((p for p in items if p["id"] == idx.get("active")), None)
404    stale = presets.staleness(active, ident) if active else None
405    default = presets.default_name(choices)
406    return _print({"slot": slot, "suggested_name": default, "choices": choices,
407                   "active": _summary(active) if active else None, "state": stale["state"] if stale else None,
408                   "reasons": stale["reasons"] if stale else [], "presets": [_summary(p) for p in items],
409                   "can_undo": bool(idx.get("history")) or bool(active),
410                   "switched_off": bool(not active and idx.get("history")),
411                   "last_active": next((_summary(p) for p in items if p["id"] == (idx.get("history") or [None])[-1]), None) if not active else None},
412                  machine, (f"Active: '{active['name']}' ({stale['state']})" if active else "No saved tuning for these choices yet."))
413
414
415def _recheck(a: argparse.Namespace, machine: bool) -> int:
416    from strata_control import autotune, presets, tuning
417    from strata_control.tune_session import WorkerSession
418    preset = presets.find(a.preset)
419    _path, cfg = _load_target(a.target)
420    exe = _engine_exe(cfg)
421    ident = presets.current_identity(cfg, exe=exe)
422    stale = presets.staleness(preset, ident)
423    if stale["state"] == "hard":
424        return _fail("this PC changed too much for a re-check (" + "; ".join(stale["reasons"]) + "): tune again with strata tune auto", 5, machine)
425    engine_changed = int((preset.get("identity", {}).get("engine") or {}).get("tuning_epoch") or 0) != \
426        int((ident.get("engine") or {}).get("tuning_epoch") or 0)
427    opts = autotune.Options(use=(preset.get("choices") or {}).get("use", "chat"))
428    ctx = autotune.context_from_config(cfg, engine_backend=(ident.get("engine") or {}).get("backend"), opts=opts,
429                                       engine_flags=tuning.engine_flag_inventory(Path(exe)))
430    say = (lambda s: None) if machine else (lambda s: print(s, file=sys.stderr, flush=True))
431    workdir = Path(a.work_dir) if a.work_dir else Path(tempfile.mkdtemp(prefix="strata-recheck-"))
432    if not a.work_dir:
433        atexit.register(shutil.rmtree, workdir, True)       # its own scratch folder goes with the run (--work-dir keeps the logs)
434    session = WorkerSession(base_config=cfg, python=sys.executable, serve_dir=_serve_dir(a), workdir=workdir,
435                            boot_timeout_s=a.boot_timeout, lock=_lock_factory(a, say), log=say)
436    state: dict[str, Any] = {"state": "running"}
437
438    def progress(p: dict[str, Any]) -> None:
439        state.update(p)
440        _write_status(a.status_file, state)
441        say(p["message"])
442
443    out = autotune.recheck(session, [str(x) for x in cfg.get("args") or []], preset, ctx=ctx, engine_changed=engine_changed,
444                           progress=progress)
445    out["identity"] = ident
446    updated = presets.record_recheck(preset["id"], out)
447    state.update({"state": "done", "result": {k: v for k, v in out.items() if k != "identity"}})
448    _write_status(a.status_file, state)
449    human = {"keep": "Still as fast as when it was saved. Kept.",
450             "retune": "Not as fast as before: " + str(out.get("reason")) + "\nYou can tune again with: strata tune auto",
451             "inconclusive": "Could not tell (the PC was busy). Kept; try again later."}[out["verdict"]]
452    return _print({"verdict": out["verdict"], "reason": out.get("reason"), "result": {k: v for k, v in out.items() if k != "identity"},
453                   "preset": _summary(updated)}, machine, human)