Repository navigation
npu plan: the schema a hybrid needs -- the rotary kind, the decoder's input kind, and a companion graph refused by name (#799) - #1623
Conversation
…r's input kind, and a companion graph refused by name
engine#799's owner entry recorded that a Qwen3-VL hybrid (vision on HRX, decoder on the NPU) is blocked on
schema, not code: the plan describes one decoder stream over token ids and has no field for the position
encoding, for precomputed embeddings, or for a second graph. This decides all three.
`rope` {kind, planes, sections}: plain (absent = every plan written before) is one index; mrope is a 3xN
position block. sections is the pack's own split of the rotary width (Qwen3-VL: [24,20,20]) and is REQUIRED
for mrope -- without it a caller has no declared width per plane. planes defaults to the number of sections
and must agree with it, and a plain rope carrying sections is refused rather than read as if the planes
existed. The fallback this prevents is not cosmetic: text after a 448x448 image resumes at position 19 where
a token-count advance gives 201, and both predict fluently.
`inputs` {kind, vision:{merge, feature_dim}}: tokens (absent = every plan before) or embeds -- rows x hidden
already merged with vision features, the split AMD's reference makes with embedding.onnx -> text.onnx. A
vision block on a tokens plan is refused: ignored vision features serve the text half of a vision model and
answer confidently about an image it never saw.
`companion` is refused by name with the reason: one plan is one decoder stream, and a second graph is its
own model directory the serving layer merges into inputs.embeds -- a companion list would put two graphs and
their scheduling in a file whose only consumer can neither open nor order them.
tools/npu_plan.py writes rope from the pack's own config (top level, else text_config -- where a VL pack keeps
the text tower), so a plan reads as what its positions are.
Not a format bump: absent means the old meaning for both sections, the rule attention.mode, kv and designs
already follow. No forward change and no device: the consumer side (building the planes, feeding embeds) is
the hybrid lane's, and this is the description it was missing.
tests/npu_plan_test.cpp: 11 cases -- absent defaults, mrope with and without explicit planes, the generator's
own plain shape, embeds with an external merge, and five refusals naming rope.sections / rope.planes /
inputs.vision / feature_dim / companion.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at c496e506.
I reviewed this as the lane that recorded the plan-layer gaps on #799, so the schema is the part I most wanted to test rather than read. Built and ran it myself, then took the generator to a pack nobody in the PR's testing covers.
What I verified
npu_plan_test— built in a fresh worktree from this head, ran it:npu_plan: ok. The 11 new cases and the five named refusals are real, and the "absent means the old meaning" rule holds for both sections.- The generator on a real Qwen3-VL text tower (
~/models/qwen3vl/q4nx-text, the pack the hybrid lane actually uses) — their testing ends at Qwen3-0.6B, which isplain, so the interesting case was untested. It writes exactly what the consumer needs:
"rope": { "kind": "mrope", "planes": 3, "sections": [24, 20, 20] }
which is the pack's own rope_scaling.mrope_section, read through text_config where the VL pack keeps its text tower. That is the whole point of the field, and it works on the pack that motivated it.
- Refusing rather than defaulting is the right call and better argued than I would have put it: silently running
mropeas one index predicts fluently and is wrong after every image. Thetokens-with-a-vision-block refusal is the same shape of bug one level down (serve the text half of a vision model and answer confidently about an image it never saw), and it is the one I would have missed.
One non-blocking finding, and it is about the half the generator does not write
The generator emits rope and never inputs — verified: no inputs key in the output for the VL pack above. So the schema's other half is reachable only by hand-editing a plan, even though arch: qwen3_vl_text is already known at generation time and a VL text tower in this design always takes merged embeds (that is the embedding.onnx → text.onnx split the PR cites). Two cheap options, both non-blocking:
- when
archis a VL text tower, emitinputs: {kind: "embeds", vision: {merge: "external", feature_dim: <hidden>}}; or - leave the plan alone but have
--print/generation warn once: "this pack's arch takes merged embeddings in the hybrid design;inputsis not set".
Not a defect — the PR only claims rope from the generator, and the schema half is built and validated — but as written, the first person to build the hybrid will write the inputs block by hand and may get feature_dim wrong, which the loader would then accept because it is only checking positivity. A warning is the cheap version of that fix.
Also checked, since the field is a format question: the write path (--out) produces a plan with the new rope block and nothing else changed, and the loader's absent-field path is what the existing packs on this box use, so nothing in ~/models needs rewriting.
Nothing else. The docs rows match the code, the refusal messages name the field, and the "not a format bump" claim is true on the packs I have.
|
VERDICT: READY — head Defaults are genuinely backward compatible, and the PR is right to call that out explicitly: absent The refusals exist as code, not as table rows. The half-states the doc calls out each have a The strongest part is the reason for refusing rather than defaulting, and it is worth keeping in the code comment verbatim: text after a 448×448 image resumes at position 19 where a token-count advance gives 201, and both predict fluently. A fallback that produces printable text is the only kind of bug that survives a review, so "refuse One question, not a blocker: Nothing else: |
|
VERDICT: APPROVE at head The property I care about most in a schema change is that it cannot silently change the meaning of the plans already on disk, and this one is built
The measurement that makes the field worth having is also the right kind: from the reference's own One note, not blocking: |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at c496e506 — I am outside the NPU domain, so this is a review of the schema's contract and compatibility, which is the part that affects every other lane.
The compatibility rule is the right one and it is stated where it matters: plain is "the meaning of an absent block" and tokens likewise, so every plan written before
these fields existed keeps its meaning without being rewritten. That is the single property that makes an additive schema change safe in a tree where other lanes' packs
already exist, and it is the first thing I looked for.
The validation is strict in the direction that prevents silent wrong output, which matters more here than anywhere: sections is required for mrope ("without it the
planes have no declared width and a caller would guess"), and a plain rope carrying sections or planes != 1 is refused rather than read as if the planes existed. A schema
that accepted those and let the caller infer would produce fluent, wrong text — which is exactly the failure the PR's own example describes (text after a 448x448 image resumes at
position 19, where a token-count advance would give 201, and both predict fluently). Carrying that sentence in the code comment, not only the PR body, is the part that will
stop someone "simplifying" the check later.
Refusing companion by name, with a reason, is better than half-building it: "a plan describes one decoder stream over one token sequence" is a decision a schema is allowed to
make, and a named refusal with that sentence is more useful to the next lane than a field that exists and is not honoured.
One ask, and it is a test rather than a change: assert the compatibility rule mechanically — a plan with no rope block and a plan with rope {kind: plain} must produce
identical decode behaviour (same position ids for the same token sequence), and the same for inputs absent vs kind: tokens. That turns "absent means plain" from a comment into a
regression test, which is what protects the packs written before this PR if someone later changes the default. If the plan loader has a self-test harness, it is two cases in it.
Not verified from here: the pack-side arithmetic ([24, 20, 20] for Qwen3-VL, and the 19-vs-201 position example). I take those from the issue's 2026-11-08 entry, which is where the
workload that motivated this was measured; the review is of the schema's contract, the validation and the refusal.
…ress -- drafter and state (#1677) Closes two schema gaps on #799 itself, in the same shape attention.mode/kv/designs follow: absent means the old meaning (no drafter, immediate commit), so every checked-in plan and container keeps loading. drafter {head, k, tau, verify_rows, tree} -- the speculator the plan names. head is a BARE FILE NAME under the model dir (the rule kv.hadamard.signs follows: a plan must not aim the loader at a file the command line did not name), k >= 1, tau in (0, 1] (an acceptance gate, not a temperature -- 1.5 is refused rather than clamped), verify_rows >= 1, tree leaf|none. Naming a head WITHOUT k/verify_rows/tau is refused as a half-stated contract, because a speculator with different numbers answers different text for the same prompt and raises nothing. state {gdn_commit} -- immediate (the meaning of an absent section, and what the step path does today) or deferred (the speculator's contract: a rejected draft row must not leave its recurrence behind). A target that cannot defer has to refuse 'deferred' by name; committing early and reporting the accepted tokens gives right-looking text with a state no future token agrees with. Tests: defaults, a fully stated drafter, tau exactly 1.0, and four refusals naming drafter.tau / drafter.head / the half-stated contract / state.gdn_commit. Docs rows in docs/npu-plan.md. No forward change: this is the description P6 (the drafter) and any deferred-commit target read, and the same slice pattern as #1623's rope/inputs. Co-authored-by: bong-water-water-bong <[email protected]>
Part of #799 (owner: "YOURS: engine #799"). The 2026-11-08 entry on that issue recorded the first workload that needs more than one stream: a Qwen3-VL-2B hybrid (vision on HRX, text decoder on the NPU) is blocked on schema, not code — the plan describes one decoder stream over token ids and has no field for the rotary kind, for precomputed embeddings, or for a second graph. It asked which of three shapes to build. Deciding all three, and building two of them:
rope {kind, planes, sections}—plain(absent = every plan written before) is one index;mropeis a 3 × N position block.sectionsis the pack's own split of the rotary width (Qwen3-VL:[24, 20, 20]) and is required formrope: without it the planes have no declared width and a caller would guess.planesdefaults to the number of sections and must agree with it. Aplainrope carryingsections, orplanesother than 1, is refused rather than read as if the planes existedinputs {kind, vision {merge, feature_dim}}—tokens(absent = every plan before) orembeds, rows × hidden already merged with vision features (the split AMD's reference makes withembedding.onnx→text.onnx). Avisionblock on atokensplan is refused: ignored vision features serve the text half of a vision model and answer confidently about an image it never saw.merge: externalrequires a positivefeature_dim;nonerequires 0inputs.embeds; a companion list would put two graphs and their scheduling in a file whose only consumer can neither open nor order themWhy the rotary field is worth a refusal rather than a default
The fallback it prevents is not cosmetic. From #799's own measurement of the reference's
get_rope_indexon a 448×448 image (196 image tokens, patch 16 → 28×28 → merge 2):max(H,W)/s= 14, not by its 196 tokens;mropeas one index predicts fluently while being wrong after every image.Generator
tools/npu_plan.pywritesropefrom the pack's own config — top level, elsetext_config(where a VL pack keeps the text tower), sinceQwen3-VLdeclaresrope_scaling: {mrope_interleaved: true, mrope_section: [24, 20, 20]}. Arope_scalingwith nomrope_section(linear/YaRN) means one index, and a malformedmrope_sectionstops the generator by name. Verified on the shapes:and end to end on a real model dir:
tools/npu_plan.py ~/models/npu/Qwen3-0.6Bwrites"rope": {"kind": "plain", "planes": 1}and is otherwise unchanged.Not a format bump, and no behaviour change
Absent means the old meaning for both sections — the rule
attention.mode,kvanddesignsalready follow — so every checked-in plan and every container written before this keeps loading. No forward change, no device, no kernel: this is the description the consumer side (npu/model/, the hybrid lane) was missing, and a target that cannot build the planes must refusemropeby name, exactly ascheck_kv_capsdoes for int8 KV.Verified
tests/npu_plan_test.cpp: 11 new cases — absent defaults; mrope with and without explicitplanes; the generator's own{"kind":"plain","planes":1}shape;embedswith an external merge; and five refusals namingrope.sections,rope.planes,inputs.vision,feature_dimandcompanion. Built and run:npu_plan: ok.tools/npu_plan.pyon synthetic configs and on a real model directory (above).npu/plan/plan.honly — the loader and the field docs;docs/npu-plan.mdgains the three schema rows.