Repository navigation
spark-model: split a lone sequence's qwen4_exp draft head across the pair (C1 +4% on 2x DGX Spark, exact) - #375
Conversation
…pair ATLAS_QWEN4EXP_MTP_DRAFT_TP splits the draft head of a batched propose only. A lone sequence drafts on the per-sequence propose, so on the TP2 pair the worker idled through it: 8.4 ms of a 49.5 ms verify step at C1, the draft head 611 us of each ~1.5 ms position (nsys, both ranks). ATLAS_QWEN4EXP_MTP_DRAFT_TP_ONE=1 (default off, needs the switch above, agreed by both ranks through the parity word) announces that propose as a one-row plan and runs each position's draft head through the existing TpRun::head. The one-row scalar tier writes the per-sequence head's bytes, so drafts, acceptance and output are unchanged. A grammar-masked propose reads the full head and is never announced. Preliminary, single harness: 2x DGX Spark, Qwen3.8-Flash-Next FP4-Local, 3 runs each of 1024 tokens. C1 94.4/95.3/95.6 -> 98.6/99.5/99.1 tok/s, C8 unchanged; 27 decode and 4 long-prompt outputs identical. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
qwen4exp_moe_c8_tc3_plan gained a sixth argument (has_shared) and the bench still passed five, so `time` segfaulted inside cuLaunchKernel. POOLS=p (with LAYER_PASSES) reads launch i from pool i % p instead of one 256-expert pool for every launch, as a step's 48 layers do. On a GB10 with real C1/C8 routing, one pool reads at 219-232 GB/s and 48 pools (34 GB) at 208-211 GB/s; preliminary, one box, min of 11 passes. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
ATLAS_QWEN4EXP_SLAB_PACK=1 (default off) opts the qwen4_exp loader into the fast loader's pack_slab: one allocation a shard instead of one cuMemAlloc a tensor, each rounded to 2 MB pages. The server refused packing at TP/EP > 1 for every loader. The loader is now the single source for its topology: Nemotron's policy already returns false there, so its behaviour is unchanged. qwen4_exp's frees are of its own buffers or go through WeightStore::reclaim, and a packed tensor is strictly interior to its slab, where the backend's free is a no-op. Preliminary, single harness: 2x DGX Spark, Qwen3.8-Flash-Next FP4-Local, 3 runs of 1024 tokens, same binary, switch off -> on. Pre-KV footprint 61.0 -> 55.8 GB a rank, KV budget 29.7 -> 34.8 GB; C1 98.4/99.5/99.5 -> 99.9/101.1/101.0 tok/s, C8 205.7/206.5/206.2 -> 209.4/209.9/209.5. 27 decode and 4 long-prompt outputs identical. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…cations With POOLS=48 and real routing on a GB10, tc3 fused reads at 208-211 GB/s with one cudaMalloc a projection and 218-221 GB/s carved from slabs; no difference with one pool. Preliminary, one box. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
@maplepaladin73 Thanks. The nsys breakdown makes the case for the lone-sequence split clearly. Before we gate this on the pair, could you split it? This repo merges one change per PR, and each PR is measured as its own binary against its parent's, on what it touches. This branch has three independent changes:
On your question: I'd fold (1) into I've approved the CI workflows for this branch, so the workspace jobs will report here. Your measurements are on Generated with Devin |
|
@maplepaladin73 Code review of Correctness: looks right.
Nit (robustness): Before merge:
The branch still merges cleanly into 🤖 Generated with Claude Code |
Summary
On the TP2 pair,
ATLAS_QWEN4EXP_MTP_DRAFT_TPsplits the qwen4_exp draft head across the two ranks, but only for a batched propose. A lone sequence drafts on the per-sequence propose, so the worker idles through every draft step at C=1.This adds
ATLAS_QWEN4EXP_MTP_DRAFT_TP_ONE=1(default off; needsATLAS_QWEN4EXP_MTP_DRAFT_TP=1). With it the model announces a lone sequence's propose as a one-row plan, and each draft position runs the existingTpRun::headat one row. No new protocol: the worker walks the samePlan::swapsit already walks, withn = 1.What motivated it (nsys, both ranks, C=1, 1024 tokens, upstream
a92bd068): rank 1 idle 24% of the request, in one ~8.4 ms gap per 49.5 ms verify step; rank 0 spends 87% of that gap in the drafter, the draft headw4a16_gemvbeing 611 us of each ~1.5 ms position.Why output cannot change
qwen4exp_mtp_tp_gpu_one_row_shards_assemble_to_the_per_sequence_headcompares the assembled shards againstDraftHead::projectfor the BF16 rows and the NVFP4 copy.Test plan
cargo fmt --all -- --checkATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo clippy -p spark-model --tests(clean; the full--workspacerun was not done)bash scripts/check-license-headers.sh— not run (no docker on the dev host); both new files carry the SPDX linetypos— not run (not installed on the dev hosts)cargo test --release -p spark-model --lib qwen4exp_mtp— 29 passed, including the three new lockstep tests inqwen4exp_mtp_tp_one_tests.rscargo test --release -p spark-model --lib qwen4exp_mtp_tp_gpu -- --ignored— 3 passedMeasurement (preliminary, single harness)
Fingerprint: 2x DGX Spark (GB10), TP=2/EP=2,
nvidia/Qwen3.8-Flash-Next-FP4-Local, this branch ona92bd068,--speculative --num-drafts=7 --max-num-seqs=8 --kv-cache-dtype=bf16 --enable-prefix-caching --max-prefill-tokens=16384, the deployment's lever profile plusATLAS_PLE_FAULT_THREADS=256. Harness: 8 distinct code/prose prompts, temperature 0, thinking off,max_tokens1024, one warm-up pass, 3 runs, client-side aggregate tok/s. One variable between the two legs: the new switch.a92bd068on all 27 decode requests and on 4 long prompts (3.6K–25K tokens), in both legs.json_schemarequest. No ERROR lines on either rank.Not measured: a single node, other qwen4_exp checkpoints,
ATLAS_QWEN4EXP_DRAFT_VOCABid lists (refused by the existingbatchablecheck), and anything beyond this one harness.Second commit: MoE bench fixes (dev script only)
scripts/dev/qwen4exp_moe_c8_bench.sh timesegfaulted:qwen4exp_moe_c8_tc3_plantakes six arguments (has_shared) and the bench passed five.POOLS=poption: launchireads pooli % p, as a step's 48 layers do, instead of one 256-expert pool for every launch. With real C1/C8 routing on a GB10 thetc3 fusedread rate is 219-232 GB/s on one pool and 208-211 GB/s on 48 pools (preliminary: one box, min of 11 passes). No engine code is touched.Third commit: qwen4_exp may slab-pack its shards (
ATLAS_QWEN4EXP_SLAB_PACK=1, default off)The fast loader's
pack_slab(one allocation a shard instead of onecuMemAlloca tensor) was refused at TP/EP > 1 for every loader, inserve_phases/weights.rs. This moves that decision to the loader, which the trait doc already calls the owner of the policy. This touches a shared gate: Nemotron's policy already returnsfalseat TP/EP > 1, and no other loader opts in, so their behaviour is unchanged.Why it is safe for qwen4_exp, one rank or the TP=EP=2 pair:
slab_layoutreserves offset 0, so every packed tensor is strictly interior to its slab, and the CUDA backend'sfreeof an interior pointer is a no-op. The loader's frees are of its own buffers (gpu_concat_rows, the per-rank copiestp_shardmakes at tp > 1) or go throughWeightStore::reclaim/free_loader_source. Under a slab a reclaim returns no memory; the footprint below is net of that.Same fingerprint and harness as above, same binary, switch off -> on (preliminary, single harness, 3 runs):
register_slabdefaults to a no-op there).A fourth commit adds
SLAB=1to the MoE bench (dev script only), which is where the read-rate effect was first seen.Notes for reviewers
ATLAS_QWEN4EXP_MTP_DRAFT_TPinstead of being its own switch.qwen4exp_mtp_tp.rswould have crossed 500 lines, so the lone-sequence pieces live inqwen4exp_mtp_tp_one.rs.Pair,config()andhead()in the existing test modules becamepub(super)/pub(crate)so the new tests reuse them.CLA
Generated with Devin