- strata_control/drafting.py is the one place: the choice (saved in the model's run config as "drafting"), the table card class -> suggested drafter with the measured evidence (Auto picks DFlash2 only where it was faster on every tested prompt; today no class qualifies, so Auto is the MTP everywhere), the pinned drafter (incoai/Qwen3.8-Flash-Next-DFlash2 rev a22a1744, sizes and SHA-256 of the repository), what each choice puts on the engine arguments, and the plain "Drafting: MTP (DFlash2 didn't fit)" words read from the engine's own log. - serve/server.py applies the choice at every start and reports "drafting" / "drafting_note" in /metrics. - strata launch --drafting writes it to the launch config and presets, shows it in --plan, adds the drafter to the download plan when it would be used, fetches it before the start (a failure starts the MTP and says so), and prints the engine's fallback line. - strata drafting plan|fetch (JSON/JSONL for the app). tools/dflash2_pack.py now reads safetensors with numpy alone (no torch on the person's PC), byte for byte the same file as before (checked against the earlier version), and ships in the Terminal bundle. - DFlash2 is for Qwen3.8-Flash-Next (qwen, gyro) only. The engine in this release runs it only in its CLI run, not with --serve, so while drafting.ENGINE_SERVES_DFLASH2 is False the choice starts the MTP, says "DFlash2 isn't available in this mode yet" and downloads nothing.
59 lines
2.4 KiB
Python
59 lines
2.4 KiB
Python
"""``strata drafting plan|fetch``: the DFlash2 drafter file (strata_control/drafting_fetch.py). The app calls it with ``--output jsonl``."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from strata_control import acquisition, drafting, drafting_fetch
|
|
|
|
|
|
def add_parser(sp) -> None:
|
|
drafting_p = sp.add_parser("drafting", help="the DFlash2 drafter file: what it would download, and fetch it")
|
|
d_sp = drafting_p.add_subparsers(dest="drafting_command", required=True)
|
|
for name, text in (("plan", "say what fetching would download; nothing is changed"),
|
|
("fetch", "download the drafter (pinned, checked) and pack it for the engine")):
|
|
one = d_sp.add_parser(name, help=text)
|
|
one.add_argument("--data-dir", metavar="DIR", help="the model data folder (default: the one Strata uses)")
|
|
one.add_argument("--output", choices=("human", "json", "jsonl"), default="human")
|
|
|
|
|
|
def _data_dir(a) -> Path:
|
|
if a.data_dir:
|
|
return Path(a.data_dir)
|
|
from strata_cli.launch.catalog import Catalog
|
|
return Catalog().data_dir()
|
|
|
|
|
|
def run(a) -> int:
|
|
machine = a.output in ("json", "jsonl")
|
|
folder = _data_dir(a)
|
|
if a.drafting_command == "plan":
|
|
result = drafting_fetch.plan(folder)
|
|
if machine:
|
|
print(json.dumps({"schema_version": 1, "ok": True, **result}, ensure_ascii=False))
|
|
else:
|
|
print(result["text"])
|
|
return 0
|
|
|
|
def show(step: str, done: int, total: int) -> None:
|
|
if a.output == "jsonl":
|
|
print(json.dumps({"event": "progress", "step": step, "done": done, "total": total}, ensure_ascii=False), flush=True)
|
|
elif not machine and total:
|
|
print(f"\r{step} {done / 1e9:.2f} of {total / 1e9:.2f} GB", end="", flush=True)
|
|
|
|
try:
|
|
out = drafting_fetch.ensure(folder, progress=show)
|
|
except (drafting_fetch.DraftingError, acquisition.AcquisitionRefused) as exc:
|
|
if machine:
|
|
print(json.dumps({"schema_version": 1, "ok": False, "error": {"code": "drafting_failed", "message": str(exc)}}, ensure_ascii=False))
|
|
else:
|
|
print(f"\nstrata: {exc}", file=sys.stderr)
|
|
return 5
|
|
if machine:
|
|
print(json.dumps({"schema_version": 1, "ok": True, "event": "result", "pack": str(out)}, ensure_ascii=False))
|
|
else:
|
|
print(f"\nThe DFlash2 drafter is ready: {out}")
|
|
return 0
|