Skip to content

qwen4_exp: MTP drafter absorbs verified rows and the prompt; dynamic-depth window (default-off, ported from Enntity) - #224

Merged
AzeezIsh merged 12 commits into
mainfrom
stack/qwen-mtp-absorb
Oct 29, 2026
Merged

AzeezIsh merged 12 commits into
mainfrom
stack/qwen-mtp-absorb

Conversation

@AzeezIsh

Copy link
Copy Markdown
Contributor

Stack: main ← #198 ← #223 ← this ← queued-first-chunk PR. 12 commits, ported from Enntity/atlas (AGPL-3.0, SparkQwen's drafter series 166e2b1, e7d4e1a, 73c19db, 18a54e9, 294d2ba, 5f086bd, 23350fb, 1aa8d99); credit lines sit next to the ported code.

Summary

  • ATLAS_QWEN4EXP_MTP_ABSORB=1: the drafter's KV absorbs the target's verified rows. ATLAS_QWEN4EXP_MTP_PREFILL=<rows>: drafter KV over the prompt. ATLAS_MTP_DEEP_WINDOW / _START: decision window for dynamic depth. All default-off and parity-registered. Draft-only: target tokens don't change.

Measurements (vs its parent, receipts on #216; git range-diff against the measured branch is = for all 12 commits)

  • Exactness with the switches on: C1, C8, cache C4 and the 4.4K-token prefix all equal serial 8/8; tools 21/21; contamination PASS; ssm-state-poisoning 12/12. Switches off: identical tokens and acceptance.
  • decode-floor 84.4 → 94.4 tok/s (acceptance 4.27 → 5.24); sparkDash single-stream: structured +21%, json +18%, code +12%, prose +5%; MLPerf agentic at 1 user +1.6%; at 4 concurrent, together with the next PR, +19% throughput.

Test plan

  • fmt, clippy (no warnings in touched files), host tests
  • GPU tests: KV-only parity vs full decode, MTP batch
  • CUDA build of the stack top: reiner job 911

Tracking: #220, #216.

Generated with Devin

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

CUDA release build of the stack top (#226 @ a1dab6554, which contains this PR) passes on reiner (job 911). git range-diff against the measured branches is = on every commit, so the #216 receipts apply unchanged.

data-angel and others added 11 commits October 29, 2026 02:55
…QWEN4EXP_MTP_ABSORB)

After each verify, the drafter's rows for the accepted drafts paired committed
tokens with the drafter's OWN chained streams. vLLM and TensorFold re-run the
MTP layer over the verified window with the target's streams instead. With
ATLAS_QWEN4EXP_MTP_ABSORB=1 (default off, byte-identical) the scheduler stages
the verify's accepted rows of the target's final mHC streams with the proposer
(Model::stage_mtp_absorb -> DraftProposer::stage_absorb) at every verdict site
(batched verify Phase 2, the K=2/3/4 single-sequence steppers), and the next
propose rewinds the drafter to row 0 and rewrites those positions KV-only
(TransformerLayer::decode_rows_kv_only, new: a one-layer drafter's KV row is a
function of its own input row) before drafting as before.

The batched propose's row-wise front (norm, fc_hidden, embedding branch) and
body context move to qwen4exp_mtp_rows.rs, shared with the absorb.
Rank-local (only rank 0 drafts, comm: None): no new worker command.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

(cherry picked from commit 166e2b1 of Enntity/atlas)
…=<rows>)

The drafter's KV started empty at each request, so its attention never saw
the prompt. vLLM and TensorFold run the MTP layer over the prompt, pairing the
target's final streams h_i with t_{i+1}. With ATLAS_QWEN4EXP_MTP_PREFILL=<rows>
(default off) each prefill capture point notes which highway rows hold the
chunk's final streams (DraftProposer::note_prompt_rows), and once the chunk's
prefill returns (logits computed; the passes reuse the activation buffers)
the drafter writes the last <rows> prompt positions KV-only, 64 rows a pass
(DraftProposer::absorb_prompt). The prompt's last row waits for the sampled
token, which the first propose hands over (DraftProposer::prompt_tail_token).

A restored prefix computed nothing and stays blind (only the computed suffix
is written); under the sequence-parallel prefill rank 0 writes its half of a
split chunk. A chunk that would leave less than 1/8 of the shared drafter KV
pool free is skipped. The batched row front takes explicit scratch
(RowScratch; the prompt passes use the pipelined BF16 GEMM), and the head's
constructor moves to qwen4exp_mtp_new.rs for the 500-LoC cap.

(cherry picked from commit e7d4e1a of Enntity/atlas; hand-resolved:
entry.rs hunk landed beside try_eager_drafter_prefill in
prefill_chunk_entry (same site, our file has an extra twophase caller),
and the note_mtp_prompt_rows call moved one statement up into
prefill_b_forward_layers, in front of the profile_tail call that holds
our tree's try_mtp_prefill_capture).
…opy runs

decode_rows_kv_only computed Q+gate too (the bulk of the attention weight
bytes) though a KV row never reads it: where the exact lane's K/V arm serves
(NVFP4 K/V, scalar row tiers) it now projects K and V alone, then the shared
q/k norms, RoPE and the cache write as before. The prompt passes copy each
run of consecutive highway rows in one copy instead of one per row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

(cherry picked from commit 73c19db of Enntity/atlas; applied cleanly, one -1-line offset in multi_seq/qkv.rs)
…ss fails

absorb_rows returned early on an error before copying the saved highway rows
back, leaving the propose to draft from the absorb's inputs. The passes move
to absorb_passes; the restore runs whatever they return.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

(cherry picked from commit 18a54e9 of Enntity/atlas; applied cleanly)
…DEEP_WINDOW / _START)

The per-request deep ceiling decides every 48 verifies from the floor (3), so
a short reply spends most of its steps ramping. ATLAS_MTP_DEEP_WINDOW sets the
verifies per decision (a quarter must have drafted the deepest position) and
ATLAS_MTP_DEEP_START the ceiling a request starts at. Unset = as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

(cherry picked from commit 294d2ba of Enntity/atlas; applied cleanly)
…mpt rows

With ATLAS_QWEN4EXP_MTP_PREFILL the drafter KV pool stayed one sequence's
worth (max_seq_len / 16 + 1 blocks) shared by every sequence: eight
sequences of 16,384 prompt rows held half of it for each request's lifetime
on top of the decode rows, the 1/8 rule covered only the prompt rows, and
once the pool ran dry a propose's alloc_block failed every step. The pool
now holds max_seq_len + mtp_max_seqs x window rows when the switch is on
(unchanged off), logged at startup.

Cost at 8x262k (window 16,384, ATLAS_MTP_MAX_SEQS=8): +131,072 rows of
2 KB (2 KV heads x 256 x K/V x BF16), +256 MiB; at the default
ATLAS_MTP_MAX_SEQS (32), +1 GiB. The pool is built with the proposer,
after the target's KV pool is sized, so it comes out of the headroom the
target's sizing left, not the target's KV tokens (measured on the pair:
see the release verification).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

(cherry picked from commit 5f086bd of Enntity/atlas; applied cleanly)
…r bounds

- The absorb and the prompt rows check once that they can run (batched row
  kernels, the save buffer, a KV-only body: ATLAS_MTP_DRAFTER_QSA=1 gives
  the drafter an indexer, which has none), say so once, and otherwise leave
  the drafter as without them; before, each propose rewound the drafter and
  warned.
- Absorb, prompt-row and pool-short failures log the 1st, 2nd, 4th, ...
  occurrence (warn_sparsely) instead of one line a step.
- The prompt passes' 64-row save/restore and the chunk's rows are checked
  against hc_streams, as stage_mtp_absorb_dispatch checks its rows.
- Startup refuses ATLAS_QWEN4EXP_MTP_PREFILL with the drafter-context
  prefill's old opt-in ATLAS_MTP_DRAFTER_PREFILL (both ask for drafter KV
  over the prompt; the default drafter context never writes this
  proposer's KV).
- Src::Stage's comment says it is the rare chunk-boundary path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

(cherry picked from commit 23350fb of Enntity/atlas; applied cleanly, one -18-line offset in drafter_prefill.rs)
…ll decode

An #[ignore] GPU test on the real drafter (ATLAS_Q38_MTP_DIR): the same
synthetic rows through decode_rows_kv_only and through decode_multi_seq_rows
(the verify shape) must write byte-equal K/V rows from 4 rows up under the
exact batching lane, and stay close below (other K/V arms there).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

(cherry picked from commit 1aa8d99 of Enntity/atlas; applied cleanly, one -2-line offset in qwen4exp_mtp_absorb.rs)
…tial 030ec26)

- decode_rows_kv_only takes its rows as one KvRows value (ported from
  Enntity/atlas 030ec26, AGPL-3.0-only): the shorter forwarder keeps
  qwen3_attention/trait_impl.rs under the 500-LoC cap, and matches the
  ported GPU parity test's call shape.
- Register ATLAS_QWEN4EXP_MTP_ABSORB, _MTP_PREFILL and
  ATLAS_MTP_DEEP_WINDOW/_START for startup parity: drafter work splits
  across ranks under ATLAS_QWEN4EXP_MTP_DRAFT_TP, and the depth decisions
  steer every rank's verify.
- Per-file port credit lines (sparkqwen drafter series).
File-level Ported-from-Enntity lines stay on the six files the series
created; existing files carry a one-line // Ported from Enntity/atlas
<sha> (AGPL-3.0-only). beside the ported item instead, and every module
doc is back to its 0164cce first lines. Comments only.
@AzeezIsh
AzeezIsh force-pushed the stack/qwen-mtp-absorb branch from b1ba01e to 71f6030 Compare October 29, 2026 07:12
@AzeezIsh
AzeezIsh changed the base branch from port/199-on-198 to main October 29, 2026 07:13
@AzeezIsh AzeezIsh closed this Oct 29, 2026
@AzeezIsh AzeezIsh reopened this Oct 29, 2026
Left behind by the KvRows signature (030ec26 partial): under the real
CUDA build the file has no DevicePtr use and #![deny(warnings)] fails the
build (job 865, BUILD_EXIT=101). The ATLAS_SKIP_BUILD check misses it.
@AzeezIsh
AzeezIsh force-pushed the stack/qwen-mtp-absorb branch from 71f6030 to 74f0f29 Compare October 29, 2026 07:30
@AzeezIsh
AzeezIsh marked this pull request as ready for review October 29, 2026 07:39
@AzeezIsh
AzeezIsh merged commit e2d2468 into main Oct 29, 2026
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants