[PR #3522] [Other] calibrate: keep the PCIe/draft-floor winner only when it beats this run's own noise instead of the fixed >3% #4666

Open
opened 2026-11-07 15:38:12 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3522
Author: @dsenchankau
Created: 10/20/2026
Status: 🔄 Open

Base: main ← Head: calibration-noise


📝 Commits (4)

  • 3111ecc git commit -m 'calibrate: decide the PCIe/floor confirmation against the run's own measured noise
  • d5a1b37 Merge branch 'main' into calibration-noise
  • 1da8954 Merge branch 'main' into calibration-noise
  • c72b7ab Merge branch 'main' into calibration-noise

📊 Changes

3 files changed (+171 additions, -27 deletions)

View changed files

📝 docs/DETAILS.md (+4 -1)
📝 tools/calibrate.py (+84 -20)
📝 tools/test_calibrate.py (+83 -6)

📄 Description

Problem and result

--calibrate decides the PCIe share and the draft floor against a fixed margin: the winner of the sweeps is
kept only when the interleaved confirmation measures it "more than 3% faster". The machine's own run-to-run
variation is often as large as that margin. Measured on one PC, three consecutive tuning runs of the same
model measured their own variation at 1.7%, 3.0% and 5.2%. A fixed 3% line therefore drops real gains of
1-3% and keeps noise of up to 3%. The 2026-10-19 run that started this: the sweep winner (worth about +2%
on the confirmation rounds) was thrown away, and a draft floor the sweep never chose was written into the
config as --spec-min-p 0.5 because the settings builder always emitted the pair.

After the change the confirmation buys seven fresh default-vs-candidate pairs and keeps the pair only when
the mean gain is unlikely to be that run's own variation (a t of 2.5 or more, the scatter floor taken from
the run's own sweep repeats). The decision line is printed with the numbers: mean gain, measured noise, t,
verdict. A sweep tie goes to the default, only a coordinate that actually won lands in the config, and
apply() never adds a flag the calibration did not choose. On the same PC the new rule kept a real +18.9%
pair (noise 1.7%, t 17.5; end to end 70.3 -> 80.6 tok/s on iq3_s) and refused a +1.9% pair that fresh
samples could not separate from noise (noise 3.0%, t 1.14; defaults stayed, config gained no flags).

Related discussion: none. This is a focused fix inside the opt-in --calibrate flow: a PC without a tuning
run gets exactly the same settings as before, and no product default changes. What values tuning picks is
unchanged in kind: the same sweeps and the same two settings. Only the line that decides "is this gain real"
now uses the run's own measured variation instead of a fixed 3% that sits inside that variation.

Approach

The sweeps already rotate every value inside one engine start and take medians, so their repeats measure the
run's variation for free; the pooled coefficient of variation over all sweep samples becomes the noise
estimate. The confirmation pairs sit back to back, so the block-to-block drift that #1332 measured (8-28%
between engine starts) cancels inside a pair; the fixed margin could not see either effect. The pair
(pcie-frac, spec-min-p) is judged as one unit because that is the unit that goes into the config and the
two settings interact through where experts are placed. The scatter floor keeps the confirmation's own
residual drift charged to it, which makes the rule slightly conservative on a wobbly PC; that is deliberate,
and T_KEEP is the dial. All seven pairs are always paid: an early stop on a lucky or unlucky three-pair
mean was measured to strand true winners. The printed t is truncated toward zero so a value of exactly
"2.50" can never sit next to "kept the default". Steps that must restart the engine (the worker count, the
adaptive expert tier) keep the old fixed margin, because pairing is impossible across restarts.
--prefill-pipe keeps its own win-every-round rule.

Validation

  • Passed (2026-10-20, Linux, CPython 3.12.3, branch HEAD on top of 9de04cd4):
    • python tools/test_calibrate.py: 36 tests, OK. Covers: a gain that beats a noisy run, a gain that only
      scatters pair to pair, the measured noise floor dropping a steady tiny gain (t 1.08), all-seven-pairs
      behavior, dead-pair skipping, the tie-to-default sweeps, and the exact config dict emitted.
    • python -m unittest tests.terminal.test_calibration: 30 tests, OK (the settings/apply layer on the
      Terminal side).
  • Passed (hardware, one PC, i7-13700f, RTX 4080S). Two tuning runs:
    • qwen3.8-flash-next-iq3_s: sweep winner 0.2/0.7, confirmation mean +18.9% against a measured 1.7% noise
      (t 17.52), kept; final line --pcie-frac 0.20, --spec-min-p 0.70, --adapt-every 1, --adapt-swaps 80, --adapt-decay 0.97 (80.6 tok/s) against a 70.3 tok/s default tier.
    • qwen3.8-flash-next-unsloth-ud-q4_k_xl: candidate +1.9% against 3.0% measured noise (t 1.14), default
      kept; config gained no tuning flags, 45.0 tok/s.
    • One earlier run with the 0.2.0 tooling (measured noise 5.2%) refused a +3.2% bundle the sweeps had ranked (t 1.16).
  • Failed: nothing observed on this branch. Two pre-existing failures in
    tests.terminal.test_discovery.GuiLayout (test_a_remembered_older_install_and_the_app_install_are_both_listed,
    test_an_own_setting_beats_the_apps_folder: Windows folder expectations on Linux) fail identically on
    upstream/main; this PR does not touch them.
  • Not run: Windows and macOS; the AMD (HIP) tuning path; the Desktop app's calibration flow
    (strata_control/calibration.py): it reuses this tools/calibrate.py and was not exercised; any second
    PC. No C++/CUDA/HIP/SYCL code is touched.

Limits

Validation is one PC and two models; the numbers describe that machine, not all machines. The seven pairs
extend the confirmation stage to a fixed cost (the old stage also measured pairs; the difference is bounded
and now predictable). The worker-count and expert-tier steps still use the old fixed 3% margin because each
of their samples needs an engine restart. The noise estimate re-charges part of the run's block-to-block drift on purpose, which keeps the
rule conservative.


🔄 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/3522 **Author:** [@dsenchankau](https://github.com/dsenchankau) **Created:** 10/20/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `calibration-noise` --- ### 📝 Commits (4) - [`3111ecc`](https://github.com/Niko1221/Strata/commit/3111ecc64682a2f7188babcb6e6a6dac99245591) git commit -m 'calibrate: decide the PCIe/floor confirmation against the run's own measured noise - [`d5a1b37`](https://github.com/Niko1221/Strata/commit/d5a1b37050876cf4347ca6416a4654c8feb1b026) Merge branch 'main' into calibration-noise - [`1da8954`](https://github.com/Niko1221/Strata/commit/1da8954cc5825cab0042420c8060b8f208e7d151) Merge branch 'main' into calibration-noise - [`c72b7ab`](https://github.com/Niko1221/Strata/commit/c72b7abfa33667cee001328d1b8bf5b161e8a026) Merge branch 'main' into calibration-noise ### 📊 Changes **3 files changed** (+171 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+4 -1) 📝 `tools/calibrate.py` (+84 -20) 📝 `tools/test_calibrate.py` (+83 -6) </details> ### 📄 Description **Problem and result** `--calibrate` decides the PCIe share and the draft floor against a fixed margin: the winner of the sweeps is kept only when the interleaved confirmation measures it "more than 3% faster". The machine's own run-to-run variation is often as large as that margin. Measured on one PC, three consecutive tuning runs of the same model measured their own variation at 1.7%, 3.0% and 5.2%. A fixed 3% line therefore drops real gains of 1-3% and keeps noise of up to 3%. The 2026-10-19 run that started this: the sweep winner (worth about +2% on the confirmation rounds) was thrown away, and a draft floor the sweep never chose was written into the config as `--spec-min-p 0.5` because the settings builder always emitted the pair. After the change the confirmation buys seven fresh default-vs-candidate pairs and keeps the pair only when the mean gain is unlikely to be that run's own variation (a `t` of 2.5 or more, the scatter floor taken from the run's own sweep repeats). The decision line is printed with the numbers: mean gain, measured noise, `t`, verdict. A sweep tie goes to the default, only a coordinate that actually won lands in the config, and `apply()` never adds a flag the calibration did not choose. On the same PC the new rule kept a real +18.9% pair (noise 1.7%, t 17.5; end to end 70.3 -> 80.6 tok/s on `iq3_s`) and refused a +1.9% pair that fresh samples could not separate from noise (noise 3.0%, t 1.14; defaults stayed, config gained no flags). **Related discussion:** none. This is a focused fix inside the opt-in `--calibrate` flow: a PC without a tuning run gets exactly the same settings as before, and no product default changes. What values tuning *picks* is unchanged in kind: the same sweeps and the same two settings. Only the line that decides "is this gain real" now uses the run's own measured variation instead of a fixed 3% that sits inside that variation. **Approach** The sweeps already rotate every value inside one engine start and take medians, so their repeats measure the run's variation for free; the pooled coefficient of variation over all sweep samples becomes the noise estimate. The confirmation pairs sit back to back, so the block-to-block drift that #1332 measured (8-28% between engine starts) cancels inside a pair; the fixed margin could not see either effect. The pair `(pcie-frac, spec-min-p)` is judged as one unit because that is the unit that goes into the config and the two settings interact through where experts are placed. The scatter floor keeps the confirmation's own residual drift charged to it, which makes the rule slightly conservative on a wobbly PC; that is deliberate, and `T_KEEP` is the dial. All seven pairs are always paid: an early stop on a lucky or unlucky three-pair mean was measured to strand true winners. The printed `t` is truncated toward zero so a value of exactly "2.50" can never sit next to "kept the default". Steps that must restart the engine (the worker count, the adaptive expert tier) keep the old fixed margin, because pairing is impossible across restarts. `--prefill-pipe` keeps its own win-every-round rule. **Validation** - Passed (2026-10-20, Linux, CPython 3.12.3, branch HEAD on top of `9de04cd4`): - `python tools/test_calibrate.py`: 36 tests, OK. Covers: a gain that beats a noisy run, a gain that only scatters pair to pair, the measured noise floor dropping a steady tiny gain (t 1.08), all-seven-pairs behavior, dead-pair skipping, the tie-to-default sweeps, and the exact config dict emitted. - `python -m unittest tests.terminal.test_calibration`: 30 tests, OK (the settings/apply layer on the Terminal side). - Passed (hardware, one PC, i7-13700f, RTX 4080S). Two tuning runs: - `qwen3.8-flash-next-iq3_s`: sweep winner 0.2/0.7, confirmation mean +18.9% against a measured 1.7% noise (t 17.52), kept; final line `--pcie-frac 0.20, --spec-min-p 0.70, --adapt-every 1, --adapt-swaps 80, --adapt-decay 0.97 (80.6 tok/s)` against a 70.3 tok/s default tier. - `qwen3.8-flash-next-unsloth-ud-q4_k_xl`: candidate +1.9% against 3.0% measured noise (t 1.14), default kept; config gained no tuning flags, 45.0 tok/s. - One earlier run with the 0.2.0 tooling (measured noise 5.2%) refused a +3.2% bundle the sweeps had ranked (t 1.16). - Failed: nothing observed on this branch. Two pre-existing failures in `tests.terminal.test_discovery.GuiLayout` (`test_a_remembered_older_install_and_the_app_install_are_both_listed`, `test_an_own_setting_beats_the_apps_folder`: Windows folder expectations on Linux) fail identically on `upstream/main`; this PR does not touch them. - Not run: Windows and macOS; the AMD (HIP) tuning path; the Desktop app's calibration flow (`strata_control/calibration.py`): it reuses this `tools/calibrate.py` and was not exercised; any second PC. No C++/CUDA/HIP/SYCL code is touched. **Limits** Validation is one PC and two models; the numbers describe that machine, not all machines. The seven pairs extend the confirmation stage to a fixed cost (the old stage also measured pairs; the difference is bounded and now predictable). The worker-count and expert-tier steps still use the old fixed 3% margin because each of their samples needs an engine restart. The noise estimate re-charges part of the run's block-to-block drift on purpose, which keeps the rule conservative. --- <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#4666
No description provided.