Skip to content

docs/npu.md: the draft loop, and the measured answer on whether to serve it - #1150

Merged
bong-water-water-bong merged 4 commits into
mainfrom
npu/mtp-docs-draft-loop
Nov 5, 2026
Merged

bong-water-water-bong merged 4 commits into
mainfrom
npu/mtp-docs-draft-loop

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

What

One new subsection in docs/npu.md (61 lines, docs only): "The draft loop, and whether to serve it", placed under
Add-on routes directly after The MTP head (FastFlowLM's container -> ours) — the two are the same question asked
twice, and the head-import section already ends with "the mode-1 or Q4_K forms are the ones to run" without saying what
running them buys.

The MTP brief's fourth deliverable is the serve recipe for the draft route. That answer existed only in this lane's
working directory, which is not a place a recipe can live: it is owner-facing, it decides a serve default, and it is
the one artefact that must survive the lane.

What it says, each number with the setting it was measured under

  • What exists: the four pieces (npu/mtp/draft.h policy, mtp_head.* drafter, forward_base.h adapter with the
    deferred GDN commit, tools/mtp_acceptance measurements) and what --offline / --live / --live --match /
    --batchcheck each measure. --match is called out because it is what makes the two per-depth tables one
    measurement sampled two ways instead of two computations that quietly differ.
  • The one rule that must hold: the drafter's cache is the base's committed stream, row by row — feeding it the
    current chain is silent (drafts get worse, text stays right), and it cost 69 % → 14 % first-draft acceptance until
    the cursor became a checked object (engine#820). The run's stream N rows / N mismatch lines are stated as the
    check.
  • Delivered: live acceptance equals the offline protocol at every depth over 8 prompts × 64 — +0.00 / +0.55 /
    +0.09 / +1.08 pp
    (75.14 / 63.24 / 73.26 / 84.13 %), greedy text byte-identical, 0 stream mismatches — and the chain
    is prompt-dependent, 1.80-4.33 tokens/pass, mean 3.14.
  • The answer: do not enable it. Break-even is 3.2-4.1 tokens/pass by two independent measurements (wall clock ÷
    pass count = 3.87; the 8-prompt split — faster on exactly the three above 4.12 at 0.73-0.77×, slower on all five
    below 3.20 at 1.08-1.74×, median 1.14×). 1bit forward-serve has no draft route at all today (one step() per
    token), and 1bit serve --mtp is the HRX/llama path, a different thing — so nobody re-derives that.
  • Two settings worth having regardless: OMP_WAIT_POLICY=passive, free, 1.2-2.4× on every batched pass; and
    tau redistributes cost rather than moving it (0.598-0.623 s/token across arms differing 2× in chain and 4× in
    head calls), while tau = 0.6 leaves depths 3-4 with no offers — hence tau = 0 for any per-depth measurement.
  • Refuted, with the numbers: folding the step into the next verify batch (chain 2.82 → 1.07, depth-1 82 % →
    6.9 %
    ), and lagging the hidden without lagging the cursor (0/92 accepted with the mismatch counter at 0 — a
    silently broken loop, not a slow one).
  • What would change it: a cheaper verify batch (the array wait is ~60 % of a batched pass) or a chain reliably
    above 3.9 (k = 6 bought +0.05; depth 6 measured 0 %).
  • The two ways these numbers have been misread here, stated next to them: cross-window arm comparison (plain decode
    is host-bound, so load inflates it and flatters the route) and acceptance length vs tokens per pass.

Docs only — no code, no test, no device; tools/copyright.py --check clean. Nothing here is a projection: every
figure is from a measured window of 2026-11-05, and the gates that would reopen the answer are named with the lane
that owns them.

…ve it

The brief's deliverable includes the serve recipe for the MTP draft route, and until now that
answer lived only outside the tree.  It belongs next to the head-import section, because the two
questions are the same one asked twice: what the head is, and what running it buys.

Every number here is measured on the 27B with the pb16i-exact head at k=4, and each is stated with
the setting it was measured under:

* live acceptance equals the offline protocol at every depth over 8 prompts x 64 (+0.00 / +0.55 /
  +0.09 / +1.08 pp), text byte-identical, 0 stream mismatches -- and the cursor/stream rule that
  makes it so (engine#820) is written down, because breaking it is silent;
* the chain is prompt-dependent (1.80-4.33 tokens/pass, mean 3.14), the draft route is faster only
  above a break-even of 3.2-4.1 measured two independent ways, so the answer is: do not enable it;
* OMP_WAIT_POLICY=passive is free and worth 1.2-2.4x on every batched pass; tau redistributes cost
  rather than moving it (0.598-0.623 s/token across arms differing 2x in chain, 4x in head calls);
* the fold is refuted by measurement (chain 2.82 -> 1.07, depth-1 82 % -> 6.9 %), and the hidden-lag
  shortcut is a silently broken loop (0/92 accepted, mismatch counter 0);
* the two ways these numbers have been misread here (cross-window arms; acceptance length vs tokens
  per pass) are stated next to them.

Docs only.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

The page is accurate about the code it describes, and the numbers are the lane's own record transcribed without drift.

Checked in the tree at this head:

  • The file table matches npu/mtp/: draft.h, forward_base.h, mtp_head.{h,cpp}, and tools/mtp_acceptance.cpp.
  • Every flag the text promises exists and is parsed: --offline (:286), --match (:290), --batchcheck (:288), --live/--positions-in/--positions-out in the same block.
  • The run-report strings it tells a reader to trust are real output: :602 prints ... stream %d rows, %d mismatch, and :679 prints match p%d: %zu offline chains at this loop's own positions.
  • DraftStream is the checked object the paragraph credits (npu/mtp/draft.h:82), and the engine#820 it cites is merged (2026-11-02), titled "the live MTP loop fed the drafter a truncated stream".
  • The two negative claims hold: app/forward_serve.cpp has no draft route (one step() per emitted token, :442), and 1bit serve --mtp is a different path (app/serve.cpp:2848).

Numbers: every figure in the page is identical to the lane's recorded per-depth table (75.14 / 63.24 / 73.26 / 84.13 %, hit counts 86/136, 84/134, 60/82, 49/59, +0.00/+0.55/+0.09/+1.08 pp), to chain 1.80-4.33 mean 3.14, break-even 3.2-4.1 (wall/passes 3.87; the 4.12 / 3.20 split), OMP_WAIT_POLICY=passive 1.2-2.4x, fold 2.82 -> 1.07 and 82 % -> 6.9 %, the 0/92 lagged-hidden run, and k = 6 buying +0.05. I did not re-run them: the runs need the NPU device, the owner's Bonsai serve holds that lock, and no artifact survives on this box for me to score independently. So this is a transcription and structure check, not a re-measurement.

One nit, and it is in the paragraph that warns about the confusion rather than practising it: "The tool prints both, named" is not quite true. --offline does print expected tokens per pass (chain) %.2f = 1 + sum_j c_hit[j]/c_tot[0] (:252), but the --live summary prints acceptance length under the label acceptance length %.2f tokens/pass (:888) and alongside it passes/token, which is the reciprocal. A reader who goes to the tool after reading this paragraph will find the two quantities it is told to keep apart printed with the same name. Either the label wants to be tokens/iter, or the sentence wants to say which subcommand names which.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit f721ffc)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

820 - Partially compliant

Compliant requirements:

  • Fix the MTP drafter's cursor handling to correctly track committed rows and avoid truncating the stream
  • Implement a DraftStream class to manage the cursor and cache state with proper checks
  • Update tools/mtp_acceptance.cpp to properly measure and report draft loop behavior
  • Ensure commit_verify_rows() truncates last_hidden_rows_ to the accepted prefix
  • Document the draft loop behavior and its performance characteristics in docs/npu.md

Non-compliant requirements:

  • None

Requires further human verification:

  • The device confirmation measurements are not included in this PR
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Documentation Clarity

The documentation section on the draft loop introduces several performance claims and measurements, but does not explicitly state how the performance metrics were obtained or validated in a hardware environment. Specifically, the claims about token throughput and performance gains should be verified with actual hardware measurements to ensure accuracy and reproducibility.

**Measured on 2026-11-05, on the 27B `bonsai2-27b-pb16i` with the pb16i-exact head, `k = 4`, 64 tokens,
`tau = 0`:**

* live acceptance equals the offline protocol **at every depth** over 8 prompts × 64 tokens: depth 1 **+0.00**,
  depth 2 **+0.55**, depth 3 **+0.09**, depth 4 **+1.08** pp (75.14 / 63.24 / 73.26 / 84.13 %), with greedy text
  byte-identical to plain decode on all 8 prompts and 0 stream mismatches.
* the chain is **prompt-dependent**: 1.80 to 4.33 tokens per pass, mean **3.14** over the same 8 prompts.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

Re-verdicted at 466c95c3. The delta since ddbb82d2 is Merge remote-tracking branch 'ssh-origin/main' plus the one paragraph the merged #1130 needs: container.tile_order, documented where the plan's other three decisions are. It is accurate against the code that landed:

  • npu/plan/plan.h:138 std::string tile_order = "engine-1";, :187 p.tile_order = c.value("tile_order", "engine-1") - so "Absent means engine-1, so every container written before the field existed keeps loading" is exactly right, and it is the reason #1130 needed no format bump.
  • :188-190 refuses anything else by name: "plan: " + path + " container.tile_order \"" + … - which is what "an id this decoder does not implement is a refusal naming it" says, and it is now in the page's own list of names the forward refuses (docs/npu.md:75).

The framing is the useful part and it is honest about why the field exists: the tile order "cannot be probed at all" from the plan side, every structural check passes on a wrong order (same names, dtypes, byte counts, chunk kinds), the container loads and the model "answers badly" - the same class as #1109/#1110. That is the sentence a future reader needs before they wonder why a static field is trusted.

Everything from my ddbb82d2 review is unchanged and still holds: the tool/flag/string claims against tools/mtp_acceptance.cpp (--offline :286, --batchcheck :288, --match :290, stream %d rows, %d mismatch :602), DraftStream at npu/mtp/draft.h:82, forward-serve running one step() per token (app/forward_serve.cpp:442), and the per-depth numbers identical to the lane's recorded window. One nit from that review still stands and is now the only one on this PR: mtp_acceptance.cpp:888 prints acceptance length under the label tokens/pass, while the paragraph tells a reader to trust that the tool "prints both, named".

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit f41e1ad

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY at f41e1ad3 — the push is a main merge, and this PR's one file is byte-identical to the head I reviewed.

  • Own diff is still docs/npu.md, +61/-0. git diff 466c95c3 f41e1ad3 touches six files and not docs/npu.md, so every line I checked (the draft loop, the "what is measured and what is not" answer, the app/forward_serve.cpp:442 one-step getter and the npu/mtp/forward_base.h row) is unchanged.
  • The merge brought in #1143's comment rewrite of npu/mtp/forward_base.h. Re-read the consequence: this page describes that file only as a table row ("BaseModel over the real Q4nxNpuForward, with the deferred GDN commit"), which the rewrite leaves accurate — and the page's prefix-cache paragraph already states the same consequence #1143 pinned (restoring a prefix applies the last token's GDN update twice).
  • CI at this head: build SUCCESS, CodeQL + five Analyze legs SUCCESS, hw_gate SKIPPED, pr_agent fail (expected).

BEHIND is main moving under it, not a conflict.

@bong-water-water-bong
bong-water-water-bong merged commit 5681e8d into main Nov 5, 2026
9 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the npu/mtp-docs-draft-loop branch November 5, 2026 22:27
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit f721ffc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant