perf(qwen): shard TP4 HC prefill and coalesce recurrent checkpoints - #779
original-el8 wants to merge 9 commits into
Conversation
Co-authored-by: Codex <noreply@openai.com> Signed-off-by: Jason Cook <jasonc@maxlyn.com>
Co-authored-by: Codex <noreply@openai.com> Signed-off-by: Jason Cook <jasonc@maxlyn.com>
Co-authored-by: Codex <noreply@openai.com> Signed-off-by: Jason Cook <jasonc@maxlyn.com>
Preserve the causal language model entry point so pure text prefills can use opt-in HC row ownership. Deepstack image inputs retain the full-row path. Co-authored-by: Codex <noreply@openai.com> Signed-off-by: Jason Cook <jasonc@maxlyn.com>
…points Advertise checkpoint capacity only with B12X aligned GDN and PLE state. Export both convolution histories and preserve independent MTP draft state. Keep VLLM_QWEN3_8_PREFILL_COALESCE disabled by default pending serving qualification. Co-authored-by: Codex <noreply@openai.com> Signed-off-by: Jason Cook <jasonc@maxlyn.com>
The multimodal runner supplies deepstack buffers for text prefills as well as image inputs. Narrow additive residuals to each rank alongside HC state so these prefills can enter ownership mode. Co-authored-by: Codex <noreply@openai.com> Signed-off-by: Jason Cook <jasonc@maxlyn.com>
Direct forward bypasses compiled piecewise graph wrappers. Preserve the active-capture and full-graph exclusions, and require complete pure-prefill metadata. Co-authored-by: Codex <noreply@openai.com> Signed-off-by: Jason Cook <jasonc@maxlyn.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe pull request adds HC prefill support for Qwen3.8 Flash Next, including TP row ownership, deferred reductions, eligibility checks, and environment configuration. It also adds PLE and GDN prefill checkpoint metadata, checkpoint storage, scheduler integration, and tests. ChangesQwen3.8 Flash Next prefill
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~60 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant CausalLM
participant hc_prefill
participant QwenModel
participant DecoderLayers
participant TPGroup
CausalLM->>hc_prefill: evaluate prefill eligibility
hc_prefill->>QwenModel: create row ownership
QwenModel->>DecoderLayers: run eager prefill with owner
DecoderLayers->>TPGroup: reduce-scatter deferred results
QwenModel->>TPGroup: gather final rows
Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable current-head risk remains from the reviewed changes. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Signed-off-by: Jason Cook <jasonc@maxlyn.com>
Signed-off-by: Jason Cook <jasonc@maxlyn.com>
TL;DR: Add two opt-in Qwen3.8-Flash-Next prefill optimizations: distribute HyperConnection token rows across TP4 ranks, and coalesce prompt tails while exporting complete recurrent checkpoints. Together, they raise cold prefill from 3275 → 4370 tokens/s at 8K (+33.4%), 3152.5 → 3950.5 at 64K (+25.3%), and 2759 → 3330.5 at 128K (+20.7%) on four DGX Sparks. Combined decode means meet the 3% regression gate; short C8 windows limit precision. Both features default off. Coalescing requires B12X #386.
Purpose
Qwen's expanded HyperConnection (HC) state repeats substantial work on every TP rank. During eligible pure prefills,
VLLM_QWEN3_8_HC_PREFILL_MODE=shardgives each rank one quarter of the token rows. HC mixing and residual updates run on those rows; all-gather supplies attention/MoE inputs, and reduce-scatter returns each block's partial output to its owning rank. PLE receives complete sequences, image deepstack residuals follow the row partition, and final sample/MTP states return in global token order.The multimodal wrapper enters the causal model's admission path. Eligible prefills call the model forward directly, bypassing compiled wrappers. Other forwards retain full-row processing; when HC mode is enabled, target block reductions move to the decoder-layer boundary. The MTP draft layer retains its existing reductions. HC ownership uses the TP NCCL communicator; prepared RoCEnante decode collectives remain available.
VLLM_QWEN3_8_PREFILL_COALESCE=1allows the scheduler to join a prompt tail across an internal cache boundary. GDN exports recurrent state and raw convolution history, and the companion B12X API exports PLE's normalized convolution window. Metadata tracks destination slots through cache-group remapping. Qwen MTP draft attention state is independent of target recurrent state; prefix lookup retains its existing lookahead replay requirements.Runtime controls and compatibility
VLLM_QWEN3_8_HC_PREFILL_MODEoffoff: replicated compiled path;control: replicated eager prefill with deferred reductions;shard: token ownership during eligible prefillVLLM_QWEN3_8_PREFILL_COALESCE01: one internal checkpoint per GDN/PLE request under aligned cachingHC mode requires BF16, TP4/PP1/DP1/DCP1/PCP1, no EP/EPLB, sequence-parallel MoE or DBO. Ranks agree on configuration at startup. Admission requires at least 1024 rows divisible by four, complete pure-prefill GDN metadata, and no active graph capture, full graph replay, dummy run or microbatching. Decode and mixed batches do not activate row ownership. Qualification covers GB10; other hardware is unqualified.
Coalescing requires B12X GDN prefill/decode, aligned recurrent caching and no request-boundary checkpoint mode. Install B12X #386 before enabling it. HC sharding works independently of checkpoint coalescing. The combined measured configuration enables both flags.
Checkpoint preparation
PLE preparation also primes the internal checkpoint-export executable with inactive offsets and destination slots. Coalescing can invoke this executable during graph warmup even when no request writes a checkpoint; priming it avoids a frozen-kernel-resolution failure after changing MTP depth. Prepared-call reset and close restore the live staging buffers and touched recurrent state. This changes startup preparation only.
The regression test covers coalescing enabled and disabled, inactive checkpoint sentinels, execution order, and restoration of live buffers. Both cases pass. An immutable image containing the fix passes TP4 startup, CUDA graph capture, arithmetic/tool-call checks, prefix replay, and concurrent vision smoke checks at MTP2, MTP3, and MTP4. All three depths also complete three repetitions of 8K/64K/128K cold prefill and C1/C8 short/8K decode with clean post-benchmark health checks. Each MTP depth uses a fresh Torch/vLLM cache because cached AOT graphs contain numeric prepared-plan handles. Compatible content-addressed B12X/Triton/FlashInfer caches remain reusable.
Test Result: serving performance
Status: implemented and qualified for the configuration below. Values are arithmetic mean tokens/s from two repetitions, measured on the same immutable image with runtime flags selecting each arm. The reference is that image with both flags off. All cold-prefill samples have zero cached tokens.
The eager control differs from the compiled reference by less than 0.4% at every prefill length. HC ownership accounts for most of the improvement; coalescing adds its largest benefit at 8K.
Combined and HC-only means meet the declared 3% decode regression gate. Coalescing alone fails short-context C8 at -3.61%. Decode uses continuous requests with 256 output tokens, a three-second warmup and a 20-second observation window. C8 reaches eight active requests but averages about 7.4–7.9 during request turnover; some samples are underfilled or capacity-limited. Prompt nonces and MTP acceptance vary between runs. These short sequential measurements do not establish statistical equivalence or an isolated decode-kernel speedup. All measured arms completed without request errors, warmup timeouts, OOMs or container restarts.
Individual baseline and combined samples, tokens/s
Conditions and source identity
Four DGX Sparks, NVIDIA GB10, TP4/PP1/DP1/DCP1/PCP1, Qwen3.8-Flash-Next NVFP4 with full resident PLE, InstantTensor loading, MTP3, max batched tokens 8192, max sequences 16, max model length 262144, BF16 KV and 28 GiB KV per rank. Hybrid alignment yields an effective 752-token block size. Prefix caching, chunked prefill and async scheduling are enabled; recurrent caching uses
alignwith default retention interval zero. Decode uses full/piecewise graphs at 4/8/16/32/64 rows. RoCEnante thresholds are 2 MiB all-reduce and 16 MiB all-gather over the dual-HCA fabric.Measured vLLM:
b0cf3b82341433caa2b350b1b71fc98b11c8ed92, based on JJ59fbf050084aefe2a2dd3b19b271a7eb3527c6ae. Measured B12X:e9653dc1eae2b7b19357c51a420bd597fe3012ed; the companion PR has the identical full source treeaed60ccc03821db784c875b8ea124acf7e0055f1after cherry-picking onto the merged RoCEnante fixes. All ranks used image IDsha256:e2140e8359fb185a5f06e26dbc18d5f4f9ba4b3adb694fd39c1ec9948ecbb027.Test Plan and correctness results
Source checks ran in the candidate image with
CUDA_VISIBLE_DEVICES=andVLLM_TARGET_DEVICE=cpu:101 unique passes, 22 GPU-only skips. Three metadata cases initially lacked the Hugging Face config fixture; rerunning the complete metadata file with the existing
Qwen/Qwen3.5-0.8Bconfig cache gave 8 passed / 2 skipped. No source change was needed. Commit pre-commit hooks pass.The companion B12X native PLE selection passes 4 GPU tests, covering mixed requests, short history offsets, graph replay without allocation, and high destination slots beyond signed 32-bit element offsets. Serving logs confirm the expected HC activation on all four ranks: 96 reduce-scatters and 99 gathers per eligible target forward.
Combined functional checks pass arithmetic, tool use, image color, cold/warm prefix reuse and concurrent C8 replay. A 6598-token vision prompt exercises nonzero deepstack residuals during long prefill and returns the expected result on cold and warm requests. Two fresh 8192-token text prompts have zero cold cache hits, reuse 6768 tokens when warm, and reproduce their eight-token continuations.
Teacher-forced evaluation uses fixed 8192-token prose and code corpora, identical token IDs per arm, temperature zero, prompt logprobs and top-five probabilities. Gates are mean NLL increase ≤0.02 nats and top-1 agreement ≥99% where the baseline top-two margin is ≥0.2 nats:
Both corpora pass; the separate HC and coalescing arms also pass. These checks do not establish general model quality, broad hardware support or long-duration reliability. General benchmark accuracy evaluation remains unrun.
Four-rank integer gather/reduction oracles pass. BF16 all-reduce and reduce-scatter each have about 0.26% relative RMS error against an FP64 sum, while their two-block synthetic HC outputs differ by about 0.44%. The original 0.4% cross-path threshold fails; the fixed-prompt model checks above provide separate numerical evidence and do not imply bitwise equivalence.
Serving benchmark invocation and method
The local
benchmark-qwen.pyadapter runsllm_decode_bench.pyand fixesenable_thinking=falsefor generation and tokenization. Adapter SHA-256:dfdde00f72923a6aac8bf4b8111cef7d4b2ebc1bf303a67e71cf52ec2154dfe5; harness SHA-256:053989edff8c9c93e2b96e61342b2ffbd9851e03deba17e6d3fc96fcd6694c1e. These local harness files are not included in this source PR.Prefill rates use server-measured prefill duration, with exact nominal lengths plus two chat-template tokens and explicit zero cached tokens. The baseline and combined sample table retains both repetitions. Raw responses, metrics, rank logs, source/image receipts and fixed protocols are retained in the local qualification bundle
qwen38-hc-20260916; this PR reports their results without publishing the full local bundle.Related work and review status
Open-PR checks found no duplicate Qwen TP4 HC ownership plus GDN/PLE checkpoint integration. #700 and #699 implement analogous GLM mHC ownership and KDA continuation checkpoints. This PR handles Qwen's HC layout, GDN/PLE history, multimodal residuals and MTP contract. Upstream #53909 adds standalone Qwen kernels, not this distributed ownership or scheduler integration.
AI assistance was used for implementation, testing and PR preparation. This is a draft against the maintained JJ fork. Human line-by-line review and independent validation remain pending before marking it ready to merge.
Summary by CodeRabbit
New Features
Tests