Skip to content

[qwen 3.8 next] Fuse hybrid speculative state commits across state pools - #41171

Open
Qiaolin-Yu wants to merge 1 commit into
mainfrom
qiaolin/qwen-next-state-commit
Open

Qiaolin-Yu wants to merge 1 commit into
mainfrom
qiaolin/qwen-next-state-commit

Conversation

@Qiaolin-Yu

@Qiaolin-Yu Qiaolin-Yu commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Target verification commits accepted GDN, convolution, and PLE states through multiple launches. Combine compatible state pools and active/tracking writes while preserving tracking overwrite precedence.

Modifications

Cache validated state geometry with storage/layout invalidation, preserve integer state bits and strided convolution windows, and retain unsupported-path fallbacks.

This PR is independently based on main. QSA KV preparation is tracked separately in #40972.

Accuracy Tests

Added focused tests for this change:

python -m pytest -q test/registered/unit/layers/test_mamba_state_scatter_triton.py
python -m pytest -q test/registered/unit/layers/test_next_state_commit.py

Independent branch test rerun: 33 passed, 6 subtests passed on NVIDIA B200. Each PR was tested from its own main-based source snapshot.

Combined implementation validation with official sgl-eval 0.1.0, temperature 1, top-p 1, maximum 131072 tokens, 8 repeats over 30 questions, concurrency 128, thinking enabled, no acceptance simulation:

Mode Correct / total Accuracy Length truncations Request errors
Normal decode 229/240 95.42% 9 0
NEXTN, 3 steps / top-k 1 / 4 draft tokens 228/240 95.00% 8 0

Real MTP acceptance length was approximately 2.146, including the bonus token, estimated by weighting the complete rounded log intervals by request count.

Audited all 8 prediction files per mode against native metrics, generation settings and token totals. These are integration results with the optimization series enabled, not an isolated accuracy A/B for this PR.

Speed Tests and Profiling

Benchmark scope: the E2E results below were measured with the full optimization series combined. Reproducing that implementation requires all PRs listed below, including this PR. They are not standalone performance results for this PR.

Full optimization series used for integration measurements

  • #40972: Fuse QSA KV preparation and sparse block expansion
  • #41166: Fuse small CUDA graph input buffer copies
  • #41167: Reduce repeated overlap batch snapshot work
  • #41168: Skip speculative KV allocation transfers when no pages are needed
  • #41169: Fuse simulated speculative acceptance tensor preparation
  • #41170: Fuse speculative relay payload stores and avoid single-request gathers
  • #41171: Fuse hybrid speculative state commits across state pools (this PR)
  • #41172: Fuse exact greedy chain verification with argmax finalization
  • #41173: Fuse QSA graph replay metadata across draft steps
  • #41174: Fuse Mamba tracking index lookup and skip uniform-position transfers
  • #41175: Fuse NEXTN verify and draft graph input preparation

Each split PR is independently based on main; the list above describes the combined benchmark source, not a required merge order. The combined AIME26 results in Accuracy Tests also use this full series (with acceptance simulation disabled).

Evidence specific to this change

At serving-sized batch size 1, the state-commit microbenchmark decreased from approximately 10.00 to 5.63 microseconds without tracking and 10.88 to 7.75 microseconds with tracking. The active/tracking consolidation alone did not produce a measurable E2E throughput improvement in the cumulative run.

The combined E2E table below must not be used to infer this PR's individual throughput gain.

Full-series E2E performance (all PRs above combined)

Hardware and workload: NVIDIA B200 x4 / TP4, nvidia/Qwen3.8-Flash-Next-NVFP4, 8192 input / 1024 output tokens, 5 requests at concurrency 1, plan stream disabled:

Mode Median TPOT across 3 runs Decode throughput derived from TPOT Median fwd occupancy across 3 runs
Normal decode 4.1270 ms 242.30 token/s 98.90%
NEXTN, 3 steps / top-k 1 / 4 draft tokens 1.6936 ms 590.44 token/s 97.79%

Forward occupancy was collected with SGLang's device timer. Per-run values were 98.90%, 98.91%, and 98.89% for normal decode, and 97.75%, 97.79%, and 97.80% for NEXTN. These are full-series integration measurements with plan stream disabled; the NEXTN runs use simulated acceptance length 3.3, as in the performance table.

Every run completed 5 requests and generated 5120 output tokens. Decode throughput is 1000 / mean TPOT in milliseconds; the table reports the median of three runs. NEXTN performance uses simulated acceptance length 3.3. These measurements do not establish an isolated main-versus-this-PR speedup.

Checklist

  • Pre-commit formatting and checks pass.
  • Focused regression tests included.
  • Independent branch test rerun complete.
  • Current combined accuracy validation complete.

CI States

Latest PR Test (Base): ❌ Run #36056860534
Latest PR Test (Extra): ❌ Run #36056860291
Latest PR Test (AMD ROCm 10): ❌ Run #36056860516

@puncsky

puncsky commented Oct 20, 2026

Copy link
Copy Markdown

A bounded GB10 baseline that may help scope the state-commit optimization here. I did not run this PR, and these numbers do not estimate its fused-pool gain; they test only whether increasing the existing SSM copy tile is sufficient.

Environment: DGX Spark GB10 / SM121, CUDA 13, pinned SGLang 0.5.21 image lmsysorg/sglang@sha256:b1259f3ea3275f66237c498ea388919729018bc9f01c3d638391e06e2cf3f469, source e00930c5489053f26d86b179cee0d087f846acbb. We changed only the SSM tile constant from 1024 to 4096/8192/16384; all other Python AST nodes match. Actual Qwen3.8-27B geometry is 48 recurrent layers, 48 × 128 × 128 FP32 SSM elements per entry, four speculative positions, batch 1/8/16.

Tile b1 live copy ms b8 live copy ms b16 live copy ms b16 all-masked tracking ms
1024 1.3795 11.1239 22.5202 0.3180
4096 1.3968 11.0705 22.1420 0.0908
8192 1.3930 11.0604 22.0708 0.0639
16384 1.3888 10.9900 21.9492 0.0619

Each cell is a 25-sample CUDA-event median for the operation, not HTTP latency. The largest tile improves b16 live copy by 2.54%, while b1 regresses by about 0.67%. FP32/BF16 exact state and convolution-window checks passed for all four variants, including invalid/freed slots, partial/all accepted indices, checkpoint crossings, changing request generations, envelope strides and tail masks. This is copy-semantics coverage, not recurrent-engine integration validation. Variant order is fixed, so this is a candidate screen rather than repeated server A/B.

A separate historical b16 trace has 499.840 ms of live scatter and 6.246 ms of tracked scatter within an 8251.581 ms GPU span. Logical live read+write traffic is 101,770,592,256 bytes, about 203.6 GB/s. Actual tracking masks were not retained, so physical tracked traffic is unknown. Under a conditional 273 GB/s streaming-bandwidth assumption, even zero-cost tracking plus that live-copy roofline would save only about 1.64% of the historical span. This is not a hardware traffic-counter bound, cache-aware proof or universal limit on a layout/fusion rewrite.

We therefore rejected tile-only tuning without running serving/quality gates. The evidence distinguishes a bandwidth-heavy live-state path from launch/tracking consolidation; it does not reject the architectural work in this PR. The newer upstream verify scratch-row mapping is absent from this old image, so any current-main port also needs that correctness contract preserved. No claimed end-to-end gain or regression bound follows from this screen.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants