Skip to content

qwen38: an image load drafts with MTP, its walks on each sequence's rotation table and a span's rows - #1015

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-mmproj-mtp
Oct 30, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-mmproj-mtp

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

이미지(--mmproj)를 싣고도 Qwen3.8 MTP draft가 동작하도록 했고, 이미지가 있는 요청의 출력이 draft 없는 경로와 같음을 GB10에서 확인했습니다.

What and why

--mmproj beside BLOOMERY_DRAFT=mtp was refused by name, and an unset draft was turned off for the image load, because the draft's walks read the load's flat rotation table instead of each sequence's own. Now the draft's four walks read the live sequence's rotation table, and the draft's store walk writes a media span's rows (the image embeddings, 2560 values a row) in place of the token embeddings. The draft joins inside the existing media_call frame, so the first image key reads the prepared rotation. An image load drafts by the same rule as a text load. The prompt cache and snapshots still refuse a sequence that holds an image, and the Qwen3.5 seat keeps its refusal.

Release notes: Added: MTP drafting on Qwen3.8 image loads (--mmproj with BLOOMERY_DRAFT=mtp).

Code shape

  • No second copy. The image rows reuse media_call, CallRows and SeqRope; the embedding width is read once through MediaCarrier::width. The duplicated hidden-width accessor Policy::hidden_width is gone.
  • Model code holds only architecture facts. The Qwen3.8 adapter supplies the embedding width and the frame; the common draft code gained no per-model branch.
  • Dead code is gone. The media refusal, the Draft38Off::Media turn-off path on this seat, the two tests that pinned them and Policy::hidden_width are removed; docs/serving.md and the defaults-twins.tsv row describe the current behavior.
  • No silent failure. A media span of the wrong width, a media row outside a store walk, and an image load after a captured draft walk are named errors.
  • Comments state what is true now.
  • No relaxed gate. The two removed seat tests carry a PIN(2026-10-30): note; no band or tolerance moved.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

Duplication found or removed (path:line), or "none": none.

What I ran

Head 643873205f8a75b305a978dda9021b614020c6b0, base 9d92cbc637a9a9ae7dae9881813cc9831e5cb38c. Model Qwen3.8-Flash-Next-FP4-Local (b9ce18a6887e18c089fdea8509a33e63429a3300) with mmproj-BF16.gguf from unsloth/Qwen3.8-Flash-Next-GGUF (766911a6b7369840a91dbcd95f9f997acaab6cd6).

Boundary gate. The gate puts an image at call offset 0 after four text ids (72 image rows, so the draft's store crosses a 64-row block), under the zyxt section order. It compares each stored draft row with a replay of the token-7 embedding, checks that the image keys differ from the text rotations, and checks that drafted ids equal plain ids with a real proposal. Run on head 4a4f860af37213a0f32805540efdbd4603cd5994 (base 9540dc3f605ac0206b4f395f8878b97b981c9ac0):

cargo oxide test --arch sm_121a -- -p bloomery-gpu-gates --release --features gpu,checkpoint --bin gate_qwen4exp_mtp --no-run --message-format=json-render-diagnostics
bash tools/gpu-gate.sh --executable <the built gate_qwen4exp_mtp> --ignored hw_mtp_input_validity --nocapture
(media-draft) image at call offset 0 after 4 text ids, 72 image rows across store blocks: 77 of 77 store rows = embedding-token replay; image keys differ from text rotations true PASS
(media-draft) drafted ids = plain ids true, proposed true PASS
test result: ok. 1 passed; 0 failed

Four changes to the code each make the same gate exit non-zero, so it covers the fix:

draft joins before the media_call frame: 76 of 77 store rows = embedding-token replay ... FAIL
splice_media call removed: 5 of 77 store rows = embedding-token replay ... FAIL
rope_table(rope, seq_rope.as_ref()) replaced by &rope.table: image keys differ from text rotations false FAIL
embedding width replaced by the hidden width: a media span at 0..72 with 184320 row values, want 737280

Real binary. bloomery-serve built from this source, BLOOMERY_DRAFT=mtp against BLOOMERY_DRAFT=off, one 448x448 PNG with an image description request (temperature 0, max_tokens 32, thinking off):

cargo oxide build --arch sm_121a -- -p bloomery-gpu-gates --features glm5next,clef,mimo2,solar2,minimaxm3,flint,gemma-embedding2,hf,vision,checkpoint --release --bin bloomery-serve
target/release/bloomery-serve --model qwen38 -m <the target above> --mmproj <the projector above> --host 127.0.0.1 --port 18093 --ctx-size 16384 --parallel 2
prompt_n=234, predicted_n=32, mtp draft_n=24, draft_n_accepted=20
SERVER image drafted text == plain text: True

The owning gate and a server run with text and two-slot requests, on head c7acf1f9ad0ea4e8f61e04f7a9239874d9e673f0:

BLOOMERY_TIER=fixture BLOOMERY_BOX_LOCAL=1 BLOOMERY_BOX_CARD=local BLOOMERY_GATE_CARD=any just gate-gpu-qwen4exp-mtp
(f) a walk with media rows: qwen4exp Mtp38: a walk with media rows outside a store walk: only a media prompt call's store walks read them PASS
(f) a store walk with media rows of the hidden width: qwen4exp Mtp38: media rows of 10240 values a row; the draft's embedding rows are 2560 PASS
(f) a media load after a captured draft walk: qwen4exp enable_media: a load whose MTP draft has no captured walks: ... PASS
clauses: 28 ran, 4 left to the real tier
gpu-gate.sh: gate_qwen4exp_mtp ran 343 s (exit 0)
image: drafted text == plain text: True; mtp draft_n=113 accepted=81
image (two slots at once): drafted text == plain text: True; draft_n=124 accepted=82
text: drafted text == plain text: True; mtp draft_n=133 accepted=65
text (two slots at once): drafted text == plain text: True; draft_n=125 accepted=61
RESULT PASS

No speed claim is made.

Hardware (if the change is for a machine)

One DGX Spark, nvidia-smi --query-gpu=name,driver_version,memory.total: NVIDIA GB10, 595.84. All runs above used --arch sm_121a.

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

…otation table and a span's rows

The media load refused the MTP draft because the draft's walks read the
load's plain rotation table. They now read the table of the sequence they
walk, as the target's do, and each sequence's captured walks move with it.
A media prompt call under the draft runs through the body's own media call
with the unit sink (Qwen38Model::prompt38_media_with), and the draft's
store walks copy a span's rows over the embedding rows of its positions,
the rows the target consumed there. Media rows outside a store walk, or of
another width than the embedding's, are refused by name.

The seat no longer turns the draft off or refuses BLOOMERY_DRAFT=mtp
beside --mmproj; its media call goes through SlotDrafts::prefill_media.
The shared window builds a call's span rows at the body's embedding width
(MtpBody::embed_width), which Qwen3.8's four-stream hidden row is not.
@github-actions github-actions Bot added documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset needs-gpu Changes code a card must check, and carries no gate run on a card labels Oct 30, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: CLEAN: The performance-evidence request is non-blocking; no must-fix items remain.

Non-blocking

⚠ Supply the dispatch performance proof: crates/gpu/src/arch/qwen3moe/mtp38.rs:2810.
Image prompt storage adds 10,240 host-to-device bytes per image position [derived: 2,560 f32 values], with one blocking copy per contiguous image run in each store block.
Provide the identical PTX scan for the host dispatch refactor and the same-lease A/B required by AGENTS.md's Measuring section. Include image prompt latency with MTP on/off and a base/head text control to establish the added copy cost.

Checked

Duplicates: dryer reported zero pairs; gpu-gates was outside its scan.

Complexity: media_prompt is a new setup/reference/draft pipeline at 27; hw_mtp_input_validity 24→31 adds metadata and media checks; refusals 13→16 adds refusal cases; store_rows 35→37 adds the media-copy loop.

Silent failure: call_rows rejects media outside store walks and incorrect embedding widths. enable_media rejects existing draft captures. These refusals propagate errors.

Tests: removing the mode or width guard fails the updated unit assertions. The media gate compares stored rows and drafted ids, checks image keys against text rotations, and requires a proposal. GPU tests were not rerun here.

Gates: no tolerance or acceptance threshold moved. The two removed media-refusal tests have a dated PIN and reason; the larger context and ubatch exercise a span across store blocks.

Escape catalog: no C1–C4 pattern matched.

Notes

The PR supplies functional gate commands and output for NVIDIA GB10, driver 595.84, with commit hashes and model identity. It supplies no PTX comparison or timed A/B.

Card check: gpu-evidence. This pull request changes crates/app/src/arch/qwen3moe/mtp.rs, crates/app/src/mtp.rs, crates/app/src/mtp/policy.rs … and carries a gate run on the author's card, which counts as verified.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@github-actions github-actions Bot added gpu-evidence Verified on the author's card: the pull request carries the gate run and its output and removed needs-gpu Changes code a card must check, and carries no gate run on a card labels Oct 30, 2026
@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit c67b158 into midagedev:main Oct 30, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app gpu-evidence Verified on the author's card: the pull request carries the gate run and its output host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant