[PR #4333] [Engine] --mtp-q4 head/all fails at bind when no draft-head subset is installed #5011

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4333
Author: @xyzzing
Created: 10/27/2026
Status: 🔄 Open

Base: main ← Head: pr/mtpq4-guard


📝 Commits (1)

  • 92d33e2 mtp: --mtp-q4 head/all fails at bind when no draft head subset is installed

📊 Changes

3 files changed (+11 additions, -2 deletions)

View changed files

📝 include/strata/core/mtp.hpp (+2 -1)
📝 src/core/mtp.cpp (+6 -0)
📝 src/program/generate.cpp (+3 -1)

📄 Description

Problem and result

--mtp-q4 head (and all) silently did nothing when no draft-head subset is installed: make_q4_head() was only reachable inside the draft_vocab.bin branch of MtpDrafter::bind(), so with no rt/draft_vocab.bin (and no --mtp-draft-vocab) the engine kept drafting over the full head, at full cost, with no hint anything was off. Found while A/B-ing the flag on our box: the head-gemv stage timing did not move (0.612 vs 0.616 ms/eval) and no --mtp-q4: load line appeared — a wasted measurement window that looked like a null result for the flag.

After: bind() fails at startup with the fix named — install a subset (tools/draft_vocab.py) or use --mtp-q4 proj. Nothing else changes: without the flag the behavior is byte-identical, and with a subset installed the flag behaves exactly as before (verified on our production lineage: a 5-pair A/B with the guard in place, 10/10 cells clean, the subset arm engaged with its usual load line and gemv).

none — searched issues/PRs for mtp-q4; #3728 covers per-pack draft-head expert formats, not this flag's subset requirement.

Approach

One guard in MtpDrafter::bind() after the subset branch: when q4_head_ was requested and dhead_ is still null, error out instead of continuing. It fires for every subset-absent path (file missing, empty file, --mtp-draft-vocab pointing nowhere, STRATA_MTP_FULL_HEAD=1), and correctly stays silent for the shared-drafter path (which already has dhead_ from the shared instance) and for rebinds. Doc surfaces updated so the requirement is stated where the flag is documented: the usage line, the option comment, and set_q4's header comment.

Compatibility: none — the flag is opt-in, the default path is untouched, and the failure mode moves from "silently wrong" to "fails at startup with the fix named".

Validation

Passed:

  • ninja -C build-pr -k 0 -j 6 on this branch (HIP, gfx1100, ROCm 10.2 nightly SDK, upstream main 5e8a4cca + this commit): 494/495 targets (495 steps, one warning-only), binary links.
  • Bind-guard smoke on the built binary: one-shot run with --mtp-draft-vocab <0-byte file> --mtp-q4 head exits 1 with mtp: --mtp-q4 head/all requantizes the draft head's subset, but no subset is installed - rt/draft_vocab.bin (or --mtp-draft-vocab FILE) is absent or empty, or STRATA_MTP_FULL_HEAD=1 excludes it; install one (tools/draft_vocab.py) or use --mtp-q4 proj. Log line in the run log.
  • Same guard on our production lineage (0.1.48.1 fork, commit 37e35bc3): one-shot decode cells and a 5-pair promotion A/B (full head vs a 41,327-token subset), 10/10 cells rc=0 with the guard active, production config, gfx1100. Records kept in our repo (record-dvocab-head-20261027.json).

Failed: none observed.

Not run: SYCL and Metal builds — no SYCL toolchain on this AMD-only box and Metal is macOS-only (per-PR CI here builds neither; our fork CI compiles CUDA and HIP in vendor containers, see the run linked in the thread). CUDA is now compile-validated on this branch head (run 40592315497, both containers green).

Limits

None known. The flag's requirement of an installed subset is by design (Q4_0 re-quantization of the borrowed head's rows only makes sense for the gathered subset); what changes is that missing it now names the fix instead of silently drafting over the full head.


2026-11-06: rebased onto main (9f7d977d2) — force-pushed, applies clean. Version guard re-checked on the new base: the bug is still present (the unguarded bind path sits at src/core/mtp.cpp ~843 on main). The CUDA compile-validation run cited below was on the previous head; the fork CI re-runs on this push, and the comment thread will carry the new run when it lands.


🔄 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/4333 **Author:** [@xyzzing](https://github.com/xyzzing) **Created:** 10/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr/mtpq4-guard` --- ### 📝 Commits (1) - [`92d33e2`](https://github.com/Niko1221/Strata/commit/92d33e2c3fe9695ec16d9c67e2de00f0542166d9) mtp: --mtp-q4 head/all fails at bind when no draft head subset is installed ### 📊 Changes **3 files changed** (+11 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/core/mtp.hpp` (+2 -1) 📝 `src/core/mtp.cpp` (+6 -0) 📝 `src/program/generate.cpp` (+3 -1) </details> ### 📄 Description ## Problem and result `--mtp-q4 head` (and `all`) silently did nothing when no draft-head subset is installed: `make_q4_head()` was only reachable inside the `draft_vocab.bin` branch of `MtpDrafter::bind()`, so with no `rt/draft_vocab.bin` (and no `--mtp-draft-vocab`) the engine kept drafting over the full head, at full cost, with no hint anything was off. Found while A/B-ing the flag on our box: the head-gemv stage timing did not move (0.612 vs 0.616 ms/eval) and no `--mtp-q4:` load line appeared — a wasted measurement window that looked like a null result for the flag. After: `bind()` fails at startup with the fix named — install a subset (`tools/draft_vocab.py`) or use `--mtp-q4 proj`. Nothing else changes: without the flag the behavior is byte-identical, and with a subset installed the flag behaves exactly as before (verified on our production lineage: a 5-pair A/B with the guard in place, 10/10 cells clean, the subset arm engaged with its usual load line and gemv). ## Related discussion none — searched issues/PRs for `mtp-q4`; #3728 covers per-pack draft-head expert formats, not this flag's subset requirement. ## Approach One guard in `MtpDrafter::bind()` after the subset branch: when `q4_head_` was requested and `dhead_` is still null, error out instead of continuing. It fires for every subset-absent path (file missing, empty file, `--mtp-draft-vocab` pointing nowhere, `STRATA_MTP_FULL_HEAD=1`), and correctly stays silent for the shared-drafter path (which already has `dhead_` from the shared instance) and for rebinds. Doc surfaces updated so the requirement is stated where the flag is documented: the usage line, the option comment, and `set_q4`'s header comment. Compatibility: none — the flag is opt-in, the default path is untouched, and the failure mode moves from "silently wrong" to "fails at startup with the fix named". ## Validation **Passed:** - `ninja -C build-pr -k 0 -j 6` on this branch (HIP, gfx1100, ROCm 10.2 nightly SDK, upstream main `5e8a4cca` + this commit): 494/495 targets (495 steps, one warning-only), binary links. - Bind-guard smoke on the built binary: one-shot run with `--mtp-draft-vocab <0-byte file> --mtp-q4 head` exits 1 with `mtp: --mtp-q4 head/all requantizes the draft head's subset, but no subset is installed - rt/draft_vocab.bin (or --mtp-draft-vocab FILE) is absent or empty, or STRATA_MTP_FULL_HEAD=1 excludes it; install one (tools/draft_vocab.py) or use --mtp-q4 proj`. Log line in the run log. - Same guard on our production lineage (0.1.48.1 fork, commit 37e35bc3): one-shot decode cells and a 5-pair promotion A/B (full head vs a 41,327-token subset), 10/10 cells rc=0 with the guard active, production config, gfx1100. Records kept in our repo (`record-dvocab-head-20261027.json`). **Failed:** none observed. **Not run:** SYCL and Metal builds — no SYCL toolchain on this AMD-only box and Metal is macOS-only (per-PR CI here builds neither; our fork CI compiles CUDA and HIP in vendor containers, see the run linked in the thread). CUDA is now compile-validated on this branch head (run 40592315497, both containers green). ## Limits None known. The flag's requirement of an installed subset is by design (Q4_0 re-quantization of the borrowed head's rows only makes sense for the gathered subset); what changes is that missing it now names the fix instead of silently drafting over the full head. --- **2026-11-06:** rebased onto main (9f7d977d2) — force-pushed, applies clean. Version guard re-checked on the new base: the bug is still present (the unguarded bind path sits at `src/core/mtp.cpp` ~843 on main). The CUDA compile-validation run cited below was on the previous head; the fork CI re-runs on this push, and the comment thread will carry the new run when it lands. --- <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#5011
No description provided.