[PR #4652] [TUI] tune: probe the flags an engine accepts but does not document #5131

Open
opened 2026-11-07 16:32:56 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4652
Author: @bbingoCN
Created: 10/30/2026
Status: 🔄 Open

Base: main ← Head: f-tune-probe-flags


📝 Commits (1)

  • 9c6184d tune: probe the flags an engine accepts but does not document

📊 Changes

5 files changed (+109 additions, -8 deletions)

View changed files

📝 strata_cli/launch/params.py (+2 -2)
📝 strata_cli/tune_commands.py (+3 -2)
📝 strata_control/tune_knobs.py (+13 -0)
📝 strata_control/tuning.py (+49 -4)
📝 tests/tuning/test_tuning.py (+42 -0)

📄 Description

Problem and result

strata tune auto and strata launch --tune skipped the adapt_tier_fast and adapt_decay_09
arms on every PC, with the reason "this engine does not accept --adapt-every, --adapt-swaps,
--adapt-decay".

The engine accepts all three. Engine 0.1.52 parses --adapt-decay
(src/program/generate.cpp:3167) and the string is in the binary; it is simply absent from the
text --help prints. The tuner builds the set of usable flags by regex over --help
(strata_control/tuning.py, engine_flag_inventory), and plan_arms drops an arm when any flag
it names is outside that set — so one missing help line silently disabled two arms.

Result: a flag the engine's own parser accepts now counts as accepted, documented or not. On this
PC (engine 0.1.52, IQ3_S, 128K, RTX 3080 20 GB) the thorough sweep chose
['kv_resident_64k', 'spec3', 'pin_by_need', 'host_core_last', 'kv_grow'] before the change and
adds adapt_tier_fast and adapt_decay_09 after it.

Approach

  • engine_flag_inventory(engine, wanted=None): after parsing the help text, any flag in wanted
    that the help did not list is asked of the binary and kept when the parser takes it. wanted
    is optional, so existing callers and the "no usable help" behaviour (None) are unchanged.
  • engine_accepts_flag(engine, flag): runs the flag bare. A flag the parser knows either asks
    for its value (--adapt-decay needs a value) or runs on; an unknown one is named back
    (unknown argument: --adapt-decay). A dummy value must not be passed: a bare flag turns that
    value into an unknown positional argument, whose message is the same "unknown argument" line.
  • The probe costs one short process per flag, so only the flags that can matter are probed:
    tuning.dimension_flags() | tune_knobs.arm_flags() — 21 flags here, of which 6 are not in the
    help. tune_knobs.arm_flags() is new and gathers Arm.requires_flags() across ARMS.
  • Four call sites pass wanted (strata_cli/tune_commands.py twice,
    strata_cli/launch/params.py, and plan_tuning in tuning.py, which imports tune_knobs
    late to keep the module dependency one-way).
  • No engine source is touched, so no backend needs rebuilding.

The alternative — adding the missing line to the engine's --help — is worth doing too and is
independent; this change also protects against the next undocumented flag, which a help-text
fix would not.

Validation

Passed (Linux x86_64, Python 3.12, CUDA engine 0.1.52, RTX 3080 20 GB):

  • python -m unittest discover -s tests/tuning — 277 tests, OK (274 before; 3 added).
  • python -m unittest discover -s tests/terminal -p 'test_*tun*.py' — 40 tests, OK.
  • tests.terminal.test_launch and tests.terminal.test_issues_022 — 147 tests, OK (15 skipped).
  • Against the real engine binary, with the real Context for this machine and
    mode='thorough':
    • help-only flag set: chosen ['kv_resident_64k', 'spec3', 'pin_by_need', 'host_core_last', 'kv_grow'],
      adapt_tier_fast and adapt_decay_09 skipped for "does not accept".
    • with the probe: the same five plus adapt_tier_fast and adapt_decay_09.
    • engine_accepts_flag on the real binary: --adapt-decay True, --adapt-every True,
      --adapt-swaps True, --hybrid-rows False (a Qwen3.6-only flag this Qwen3.8 engine really
      lacks), --no-such-flag False.
    • flag_list() in launch/params.py returns 145 flags including --adapt-decay.
  • The three new tests use stand-in engines only (no GPU, no weights), matching the file's existing
    fixtures: an undocumented-but-supported flag is kept, a refused flag stays out, the probe passes
    the flag alone, and a silent engine still returns None.

Failed: none observed.

Not run:

  • Windows and macOS. The probe uses the same engine_command / engine_env helpers as the
    existing --help read, and the tests run stand-ins through sys.executable, which is what the
    Windows path needs; neither OS was exercised here.
  • AMD HIP, SYCL and Metal engines. No ROCm, oneAPI or Mac on this machine. The change is in the
    Python control layer and treats every backend identically, but only a CUDA engine was run.
  • A full --tune thorough with the fix. The arm list above comes from plan_arms on the real
    flag inventory and this machine's Context, not from a completed sweep. Measuring the two arms
    takes ~45 minutes of restarts on this PC and is left to the run that will use the fix.

Limits

  • Probing adds one process per wanted-and-undocumented flag: 6 here, ~0.2 s each. It runs once per
    tuning run, not per candidate.
  • A flag that is documented and refused is not probed; the help list is still trusted in that
    direction, as before.
  • --adapt-async's arm remains skipped on this machine for a separate reason (it is marked
    non-repeatable and strata launch passes only --allow-small-differences); that is not changed
    here.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4652 **Author:** [@bbingoCN](https://github.com/bbingoCN) **Created:** 10/30/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `f-tune-probe-flags` --- ### 📝 Commits (1) - [`9c6184d`](https://github.com/Niko1221/Strata/commit/9c6184d05855d5d6de569a4d797784164b2b831b) tune: probe the flags an engine accepts but does not document ### 📊 Changes **5 files changed** (+109 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `strata_cli/launch/params.py` (+2 -2) 📝 `strata_cli/tune_commands.py` (+3 -2) 📝 `strata_control/tune_knobs.py` (+13 -0) 📝 `strata_control/tuning.py` (+49 -4) 📝 `tests/tuning/test_tuning.py` (+42 -0) </details> ### 📄 Description ## Problem and result `strata tune auto` and `strata launch --tune` skipped the `adapt_tier_fast` and `adapt_decay_09` arms on every PC, with the reason "this engine does not accept --adapt-every, --adapt-swaps, --adapt-decay". The engine accepts all three. Engine 0.1.52 parses `--adapt-decay` (`src/program/generate.cpp:3167`) and the string is in the binary; it is simply absent from the text `--help` prints. The tuner builds the set of usable flags by regex over `--help` (`strata_control/tuning.py`, `engine_flag_inventory`), and `plan_arms` drops an arm when any flag it names is outside that set — so one missing help line silently disabled two arms. Result: a flag the engine's own parser accepts now counts as accepted, documented or not. On this PC (engine 0.1.52, IQ3_S, 128K, RTX 3080 20 GB) the thorough sweep chose `['kv_resident_64k', 'spec3', 'pin_by_need', 'host_core_last', 'kv_grow']` before the change and adds `adapt_tier_fast` and `adapt_decay_09` after it. ## Approach - `engine_flag_inventory(engine, wanted=None)`: after parsing the help text, any flag in `wanted` that the help did not list is **asked of the binary** and kept when the parser takes it. `wanted` is optional, so existing callers and the "no usable help" behaviour (`None`) are unchanged. - `engine_accepts_flag(engine, flag)`: runs the flag **bare**. A flag the parser knows either asks for its value (`--adapt-decay needs a value`) or runs on; an unknown one is named back (`unknown argument: --adapt-decay`). A dummy value must not be passed: a bare flag turns that value into an unknown *positional* argument, whose message is the same "unknown argument" line. - The probe costs one short process per flag, so only the flags that can matter are probed: `tuning.dimension_flags() | tune_knobs.arm_flags()` — 21 flags here, of which 6 are not in the help. `tune_knobs.arm_flags()` is new and gathers `Arm.requires_flags()` across `ARMS`. - Four call sites pass `wanted` (`strata_cli/tune_commands.py` twice, `strata_cli/launch/params.py`, and `plan_tuning` in `tuning.py`, which imports `tune_knobs` late to keep the module dependency one-way). - No engine source is touched, so no backend needs rebuilding. The alternative — adding the missing line to the engine's `--help` — is worth doing too and is independent; this change also protects against the *next* undocumented flag, which a help-text fix would not. ## Validation **Passed** (Linux x86_64, Python 3.12, CUDA engine 0.1.52, RTX 3080 20 GB): - `python -m unittest discover -s tests/tuning` — 277 tests, OK (274 before; 3 added). - `python -m unittest discover -s tests/terminal -p 'test_*tun*.py'` — 40 tests, OK. - `tests.terminal.test_launch` and `tests.terminal.test_issues_022` — 147 tests, OK (15 skipped). - Against the real engine binary, with the real `Context` for this machine and `mode='thorough'`: - help-only flag set: chosen `['kv_resident_64k', 'spec3', 'pin_by_need', 'host_core_last', 'kv_grow']`, `adapt_tier_fast` and `adapt_decay_09` skipped for "does not accept". - with the probe: the same five plus `adapt_tier_fast` and `adapt_decay_09`. - `engine_accepts_flag` on the real binary: `--adapt-decay` True, `--adapt-every` True, `--adapt-swaps` True, `--hybrid-rows` False (a Qwen3.6-only flag this Qwen3.8 engine really lacks), `--no-such-flag` False. - `flag_list()` in `launch/params.py` returns 145 flags including `--adapt-decay`. - The three new tests use stand-in engines only (no GPU, no weights), matching the file's existing fixtures: an undocumented-but-supported flag is kept, a refused flag stays out, the probe passes the flag alone, and a silent engine still returns `None`. **Failed:** none observed. **Not run:** - Windows and macOS. The probe uses the same `engine_command` / `engine_env` helpers as the existing `--help` read, and the tests run stand-ins through `sys.executable`, which is what the Windows path needs; neither OS was exercised here. - AMD HIP, SYCL and Metal engines. No ROCm, oneAPI or Mac on this machine. The change is in the Python control layer and treats every backend identically, but only a CUDA engine was run. - A full `--tune thorough` with the fix. The arm list above comes from `plan_arms` on the real flag inventory and this machine's `Context`, not from a completed sweep. Measuring the two arms takes ~45 minutes of restarts on this PC and is left to the run that will use the fix. ## Limits - Probing adds one process per wanted-and-undocumented flag: 6 here, ~0.2 s each. It runs once per tuning run, not per candidate. - A flag that is documented and **refused** is not probed; the help list is still trusted in that direction, as before. - `--adapt-async`'s arm remains skipped on this machine for a separate reason (it is marked non-repeatable and `strata launch` passes only `--allow-small-differences`); that is not changed here. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#5131
No description provided.