[GH-ISSUE #4102] [Other] how to convert "local" settings (strata-*.json) to launch-presets (strata launch)? #1792

Closed
opened 2026-11-04 01:54:07 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @AlBundy33 on GitHub (Oct 25, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4102

Hi,

I usually use start-here.bat and therefore have some strata-*.json files in my project folder.
I've also tuned and benchmarked the local models.

No I've seen that I can run a TUI with strata.py launch which is nice.
But the TUI does not now anything of my current configurations which is no problem because I recreate them but unfortunately the tune-infos are missing.

I ran the calibration and benchmark with this script

#!/usr/bin/env python3
r"""Calibrate and benchmark every installed model of this Strata folder, one after the other.

    .venv\Scripts\python.exe calib-bench-all.py        (Windows)
    .venv/bin/python calib-bench-all.py                (Linux)

Nothing is invented here; the script calls the functions the two scripts you know call:

  - `setup.calibrate_config(...)`  - the sweep behind `START-HERE.bat --calibrate`: it measures the engine settings for
                                      this PC, writes them into the model's `strata-*.json` and remembers them per PC
                                      and model in `%APPDATA%\Strata\settings.json`.
  - `tools/strata_bench.py`        - the quick speed check behind `BENCH.bat`: it starts the server with the model's
                                      settings, sends the fixed suite (chat, 4K prompt, 16K prompt, agent session) over
                                      the real API, 3 runs each, medians, and writes a shareable report.

Which models to run is decided by setup's own functions, not by a list in this file: `setup.installed_configs()` is
the list START-HERE.bat offers, and `setup.calibration_targets(have, None, None)` is the list `--calibrate` runs
without `--model`. It leaves out the families with their own engine path (Qwen3.6, DeepSeek-V4.1), because the
Flash-Next sweep measures settings that path does not have. Those models are named with the reason, and are tuned by
`strata tune auto` instead (the server applies the saved preset at every start, so a benchmark measures it).

Options: --plan (show the list, run nothing), --model SIZE and --family NAME (which models to run; the same names as
`START-HERE.bat --calibrate --model ... --family ...`, matched by setup's own `calibration_targets`, so `--model
IQ2_XS --family swift` means exactly the Swift config), --skip-tuned (a model whose calibration for this PC is saved:
write the saved settings into the config and benchmark them, do not measure again), --no-calibrate, --no-bench, --no-long
(the 32K prompt is the slowest part), --clients N (N requests at once; the config needs --parallel for them to run
together), --port, --out DIR, --keep-serving (do not stop the running server first).
"""
from __future__ import annotations

import argparse
import json
import subprocess
import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parent
for extra in (ROOT, ROOT / "tools"):
    if str(extra) not in sys.path:
        sys.path.insert(0, str(extra))

import setup                                          # the code START-HERE.bat runs
import strata_bench                                   # the code BENCH.bat runs
import calibrate as CAL                               # the sweep itself, used by setup.calibrate_config


def describe(p: Path) -> str:
    ch = setup.choices_from_config(p)
    return f"{p.name}: {ch['family']} {ch['model']}, context {ch['context']}"


def main(argv=None) -> int:
    have = setup.installed_configs()
    sizes = sorted({setup.choices_from_config(p)["model"] for p in have} - {None})
    fams = sorted({setup.choices_from_config(p)["family"] for p in have} - {None})

    ap = argparse.ArgumentParser(description="Calibrate and benchmark every installed model (see the top of this file).")
    ap.add_argument("--plan", action="store_true", help="show what would run and stop")
    ap.add_argument("--model", choices=sizes, help="run only this model size (default: every installed one)")
    ap.add_argument("--family", choices=fams, help="run only this family: " + ", ".join(fams))
    ap.add_argument("--skip-tuned", action="store_true",
                    help="for a model whose calibration for this PC is saved: write the saved settings into the config "
                         "and benchmark them, do not measure again")
    ap.add_argument("--no-calibrate", action="store_true", help="benchmark only")
    ap.add_argument("--no-bench", action="store_true", help="calibrate only")
    ap.add_argument("--no-long", action="store_true", help="leave out the 32K prompt test")
    ap.add_argument("--clients", type=int, default=0, metavar="N", help="also send N requests at once")
    ap.add_argument("--port", type=int, help="the port to start each server on (default: the config's)")
    ap.add_argument("--out", help="where the results folders go (default: bench/results)")
    ap.add_argument("--keep-serving", action="store_true", help="do not stop the server that is running")
    a = ap.parse_args(argv)

    targets = setup.calibration_targets(have, a.model, a.family)          # what `--calibrate --model X --family Y` runs
    tuneable = set(setup.calibration_targets(have, None, None))
    for p in have:
        if p not in targets:
            setup.say(f"  not run ({describe(p)})" + (": --calibrate cannot measure this model's engine path; use strata tune auto"
                      if p not in tuneable else ""))
    for p in targets:
        setup.say(f"  {describe(p)}: calibrate and benchmark")
    if not targets:
        setup.warn(f"nothing to run: {a.model or a.family} is not installed among the models setup can calibrate "
                   f"(installed: {', '.join(p.name for p in have)})")
        return 1
    if a.plan:
        setup.say("nothing was run (--plan)")
        return 0

    if not a.keep_serving:
        subprocess.call([sys.executable, str(ROOT / "strata.py"), "launch", "--stop"])

    results = []
    for p in targets:
        cfg = json.loads(p.read_text(encoding="utf-8-sig"))
        setup.say()
        setup.say(f"==================== {describe(p)} ====================")

        if a.no_calibrate:
            cal = "not asked for"
        elif a.skip_tuned and (rec := setup.setup_calibration(cfg, cfg.get("backend") == "hip")):
            cfg["args"] = CAL.apply(cfg["args"], rec.get("settings") or {})
            if "env" in rec:
                cfg["env"] = CAL.apply_env(cfg.get("env"), rec["env"])
            setup.write_config(p, cfg)
            cal = f"saved settings applied ({rec.get('date')}, {rec.get('tok_s')} tok/s measured), not measured again"
            setup.say("  " + cal + " (--skip-tuned)")
        else:
            cal = "ok" if setup.calibrate_config(p) else "FAILED (the default settings stay)"
            if cal.startswith("FAILED"):
                setup.warn(f"  {p.name}: {cal}")

        bench = "not asked for"
        if not a.no_bench:
            argv_b = ["--config", str(p)]
            if not a.no_long:
                argv_b.append("--long")
            if a.clients:
                argv_b += ["--clients", str(a.clients)]
            if a.port:
                argv_b += ["--port", str(a.port)]
            if a.out:
                argv_b += ["--out", a.out]
            rc = strata_bench.main(argv_b)
            bench = f"ok (results in {a.out or 'bench/results'})" if rc == 0 else f"FAILED (exit {rc})"
        results.append((p.name, cal, bench))

    setup.say()
    setup.say("Done:")
    for name, cal, bench in results:
        setup.say(f"  {name}: calibrate {cal}; benchmark {bench}")
    setup.say("Compare two runs side by side:")
    setup.say("  .venv\\Scripts\\python.exe tools\\strata_bench.py --compare-only <newer> --compare <older>")
    return 0


if __name__ == "__main__":
    sys.exit(main())
Originally created by @AlBundy33 on GitHub (Oct 25, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4102 Hi, I usually use start-here.bat and therefore have some strata-*.json files in my project folder. I've also tuned and benchmarked the local models. No I've seen that I can run a TUI with strata.py launch which is nice. But the TUI does not now anything of my current configurations which is no problem because I recreate them but unfortunately the tune-infos are missing. I ran the calibration and benchmark with this script ```python #!/usr/bin/env python3 r"""Calibrate and benchmark every installed model of this Strata folder, one after the other. .venv\Scripts\python.exe calib-bench-all.py (Windows) .venv/bin/python calib-bench-all.py (Linux) Nothing is invented here; the script calls the functions the two scripts you know call: - `setup.calibrate_config(...)` - the sweep behind `START-HERE.bat --calibrate`: it measures the engine settings for this PC, writes them into the model's `strata-*.json` and remembers them per PC and model in `%APPDATA%\Strata\settings.json`. - `tools/strata_bench.py` - the quick speed check behind `BENCH.bat`: it starts the server with the model's settings, sends the fixed suite (chat, 4K prompt, 16K prompt, agent session) over the real API, 3 runs each, medians, and writes a shareable report. Which models to run is decided by setup's own functions, not by a list in this file: `setup.installed_configs()` is the list START-HERE.bat offers, and `setup.calibration_targets(have, None, None)` is the list `--calibrate` runs without `--model`. It leaves out the families with their own engine path (Qwen3.6, DeepSeek-V4.1), because the Flash-Next sweep measures settings that path does not have. Those models are named with the reason, and are tuned by `strata tune auto` instead (the server applies the saved preset at every start, so a benchmark measures it). Options: --plan (show the list, run nothing), --model SIZE and --family NAME (which models to run; the same names as `START-HERE.bat --calibrate --model ... --family ...`, matched by setup's own `calibration_targets`, so `--model IQ2_XS --family swift` means exactly the Swift config), --skip-tuned (a model whose calibration for this PC is saved: write the saved settings into the config and benchmark them, do not measure again), --no-calibrate, --no-bench, --no-long (the 32K prompt is the slowest part), --clients N (N requests at once; the config needs --parallel for them to run together), --port, --out DIR, --keep-serving (do not stop the running server first). """ from __future__ import annotations import argparse import json import subprocess import sys from pathlib import Path ROOT = Path(__file__).resolve().parent for extra in (ROOT, ROOT / "tools"): if str(extra) not in sys.path: sys.path.insert(0, str(extra)) import setup # the code START-HERE.bat runs import strata_bench # the code BENCH.bat runs import calibrate as CAL # the sweep itself, used by setup.calibrate_config def describe(p: Path) -> str: ch = setup.choices_from_config(p) return f"{p.name}: {ch['family']} {ch['model']}, context {ch['context']}" def main(argv=None) -> int: have = setup.installed_configs() sizes = sorted({setup.choices_from_config(p)["model"] for p in have} - {None}) fams = sorted({setup.choices_from_config(p)["family"] for p in have} - {None}) ap = argparse.ArgumentParser(description="Calibrate and benchmark every installed model (see the top of this file).") ap.add_argument("--plan", action="store_true", help="show what would run and stop") ap.add_argument("--model", choices=sizes, help="run only this model size (default: every installed one)") ap.add_argument("--family", choices=fams, help="run only this family: " + ", ".join(fams)) ap.add_argument("--skip-tuned", action="store_true", help="for a model whose calibration for this PC is saved: write the saved settings into the config " "and benchmark them, do not measure again") ap.add_argument("--no-calibrate", action="store_true", help="benchmark only") ap.add_argument("--no-bench", action="store_true", help="calibrate only") ap.add_argument("--no-long", action="store_true", help="leave out the 32K prompt test") ap.add_argument("--clients", type=int, default=0, metavar="N", help="also send N requests at once") ap.add_argument("--port", type=int, help="the port to start each server on (default: the config's)") ap.add_argument("--out", help="where the results folders go (default: bench/results)") ap.add_argument("--keep-serving", action="store_true", help="do not stop the server that is running") a = ap.parse_args(argv) targets = setup.calibration_targets(have, a.model, a.family) # what `--calibrate --model X --family Y` runs tuneable = set(setup.calibration_targets(have, None, None)) for p in have: if p not in targets: setup.say(f" not run ({describe(p)})" + (": --calibrate cannot measure this model's engine path; use strata tune auto" if p not in tuneable else "")) for p in targets: setup.say(f" {describe(p)}: calibrate and benchmark") if not targets: setup.warn(f"nothing to run: {a.model or a.family} is not installed among the models setup can calibrate " f"(installed: {', '.join(p.name for p in have)})") return 1 if a.plan: setup.say("nothing was run (--plan)") return 0 if not a.keep_serving: subprocess.call([sys.executable, str(ROOT / "strata.py"), "launch", "--stop"]) results = [] for p in targets: cfg = json.loads(p.read_text(encoding="utf-8-sig")) setup.say() setup.say(f"==================== {describe(p)} ====================") if a.no_calibrate: cal = "not asked for" elif a.skip_tuned and (rec := setup.setup_calibration(cfg, cfg.get("backend") == "hip")): cfg["args"] = CAL.apply(cfg["args"], rec.get("settings") or {}) if "env" in rec: cfg["env"] = CAL.apply_env(cfg.get("env"), rec["env"]) setup.write_config(p, cfg) cal = f"saved settings applied ({rec.get('date')}, {rec.get('tok_s')} tok/s measured), not measured again" setup.say(" " + cal + " (--skip-tuned)") else: cal = "ok" if setup.calibrate_config(p) else "FAILED (the default settings stay)" if cal.startswith("FAILED"): setup.warn(f" {p.name}: {cal}") bench = "not asked for" if not a.no_bench: argv_b = ["--config", str(p)] if not a.no_long: argv_b.append("--long") if a.clients: argv_b += ["--clients", str(a.clients)] if a.port: argv_b += ["--port", str(a.port)] if a.out: argv_b += ["--out", a.out] rc = strata_bench.main(argv_b) bench = f"ok (results in {a.out or 'bench/results'})" if rc == 0 else f"FAILED (exit {rc})" results.append((p.name, cal, bench)) setup.say() setup.say("Done:") for name, cal, bench in results: setup.say(f" {name}: calibrate {cal}; benchmark {bench}") setup.say("Compare two runs side by side:") setup.say(" .venv\\Scripts\\python.exe tools\\strata_bench.py --compare-only <newer> --compare <older>") return 0 if __name__ == "__main__": sys.exit(main()) ```
Author
Owner

@github-actions[bot] commented on GitHub (Oct 25, 2026):

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes".

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6398547166 --> @github-actions[bot] commented on GitHub (Oct 25, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes". Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@github-actions[bot] commented on GitHub (Oct 25, 2026):

Thanks, this follows the format now.

<!-- gh-comment-id:6398708272 --> @github-actions[bot] commented on GitHub (Oct 25, 2026): Thanks, this follows the format now.
Author
Owner

@Niko1221 commented on GitHub (Nov 5, 2026):

Thanks for taking the time to report this.

Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.11. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6660000275 --> @Niko1221 commented on GitHub (Nov 5, 2026): Thanks for taking the time to report this. Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.11. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#1792
No description provided.