Repository navigation
[Perf] DeepSeek-V4: Fuse inverse RoPE into wo_a FP8 quantization - #43786
Conversation
|
B300 aiopt v0.5.21 validation and complete reproduction commands are in the description. Local validation uses that available build; exact main validation is left to upstream CI/review. The PR is now ready for review. Cleanup commit 7c5d3eb shares the quantization/packed-scale epilogue and host validation, reuses output allocation, and caches configuration-derived eligibility in initialization. The existing CPU fixture gets the new attribute's default. The two new GPU tests remain unchanged; no new test methods or CI suites were added. Local syntax, repository-pinned Ruff/isort/clang-format and static gate-equivalence checks passed. Earlier GPU correctness and performance results predate this refactor, so updated kernel/graph/serving and performance validation remains pending. The first greedy mismatch remains documented with an unresolved cause. |
7c5d3eb to
c21b049
Compare
|
Hi @BBuf, could you please ask your review agent to review the full cumulative diff of this PR? It fuses inverse RoPE into the CUDA UE8M0 FP8 activation quantization before DeepSeek-V4's
All repository-pinned pre-commit checks on the six changed files passed after rebase. The PR documents earlier B300 correctness/performance results, including the unresolved first-startup greedy mismatch; those GPU results predate the cleanup/rebase, so GPU validation of the current head is still pending. Could you also help authorize the relevant upstream CI when appropriate? Thanks! |
|
/tag-and-rerun-ci |
|
/tag-and-rerun-ci |
|
/tag-and-rerun-ci |
2 similar comments
|
/tag-and-rerun-ci |
|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
Port the one-line test-fixture correction from mickqian in sgl-project#47736 (be43d56). Initialize skips_prefill_metadata_on_idle_dp_rank=False on the mocked attention backend to fix the upstream CPU replay test. Production kernel/model code and the B200 tests are unchanged.
Port the one-line test-fixture correction from DarkSharpness in sgl-project#47758 (44b1e4b). Model the no-linker-offload case with tree_cache=SimpleNamespace(linker=None), allowing process_decode_queue to reach the existing held-destination publication assertion. No test skips, weakened assertions, or production changes.
|
/tag-and-rerun-ci |
1 similar comment
|
/tag-and-rerun-ci |
|
/tag-and-rerun-ci |
BBuf
left a comment
There was a problem hiding this comment.
LGTM. The earlier validation request remains open.
Empty commit to trigger CI for PR sgl-project#43786. The source tree is identical to fddd180; no production code or tests changed.
|
/tag-and-rerun-ci |
2 similar comments
|
/tag-and-rerun-ci |
|
/tag-and-rerun-ci |
|
Hi @BBuf, the latest AMD CI for this PR hit an infrastructure/API-quota failure in The Stage A GPU job was still The wait action exited on this API error after about 10 minutes, before its configured 240-minute timeout; downstream Stage B/C jobs were skipped. This failure contains no GPU test result and does not indicate a failure of the fusion kernel. The upstream GPU jobs are currently still queued. Could you help rerun the failed wait job and downstream CI once the API quota recovers? It may also be worth checking whether |
|
/rerun-failed-ci |
|
Hi @BBuf, following up with a new NVIDIA CI blocker and the current-head kernel results (head Our wo_a tests passed: the B200 kernel job ran The new root failure is the upstream Inkling/EAGLE fixture: 1-gpu-large (0) failed in CI checked out merge DarkSharpness's existing #47860 addresses this exact fixture by setting |
|
[BBuf Review Agent] @Phoenix3334 Both files match main |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
2 similar comments
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
@BBuf Could your agent help recover the remaining Base CI on head
The B200 JIT kernel job, all three Xeon jobs after retry, and the AMD main workflow have passed on this head. Could you check the H100 runner queue and rerun the failed Base jobs and downstream checks when capacity is available? Full-model serving/performance validation remains outstanding. Thanks! |
|
/rerun-failed-ci |
1 similar comment
|
/rerun-failed-ci |
|
[BBuf Review Agent] @Phoenix3334 these still fail after a rerun, and I can't tell from the logs whether it's this PR. Could you take a look?
|
|
@BBuf I checked the full log and compared the sources against the CI merge’s actual main parent. The assertion is in this job, Run test log lines 5754–5761: CI merge This identifies a DLLM throughput-threshold failure, with no evidence tying it to the fusion. I have not run a same-runner main control, so I cannot yet distinguish baseline performance from runner variability. No threshold changes or test skips were made; I will handle the rerun. |
|
/rerun-failed-ci |
|
[BBuf Review Agent] @Phoenix3334 Confirmed those three files match main |
Summary
Fuse inverse RoPE into CUDA UE8M0 FP8
wo_aactivation quantization for DeepSeek-V4. Previously a separate inverse-RoPE kernel wrote rotated BF16 activations to memory before quantization read them again. The fused kernel avoids that intermediate round-trip and launch.Changes
SGLANG_OPT_FP8_WO_A_FUSED_INVROPE(opt-in, off by default). This covers the CUDA FP8 path; it complements, but is not additive with, the separate BF16wo_afusion.Validation
test_fp8_wo_a.py, 7/7 passed, including FP8 code/packed-scale numerical equivalence and CUDA Graph capture/replay with updated inputs. Hosted lint passed.Scope and limitations
Do not attribute the historical +1.61% result to the final merged implementation. The local performance experiment predates the code cleanup/refactor; post-refactor full-model serving, accuracy and throughput were not independently remeasured. One earlier baseline startup also differed on one greedy probe; later comparisons matched, but the original discrepancy remains unexplained. Kernel correctness/Graph Replay ≠ end-to-end serving correctness or performance.
Related: ROCm fusion #37658, BF16 fusion #39957.
Historical experiment matrices, CI runs and investigation notes (original PR body)
Archive notice: The sections below preserve the original investigation record, including earlier intermediate findings and CI statuses. The concise summary above states the final interpretation and validation boundaries.
Motivation
DeepSeek-V4 applies inverse RoPE to attention output before the
wo_aprojection. The CUDA UE8M0 FP8 path currently launches inverse RoPE separately, writes rotated BF16 values to memory, and reloads them for activation quantization.This PR folds inverse RoPE into the
wo_aquantization kernel, keeping rotated values in registers and preserving the intermediate BF16 rounding boundary. It complements #39957, which fuses inverse RoPE with a small-batch BF16 wo_a projection. This PR instead quantizes the activation before the FP8 wo_a DeepGEMM path.#37658 introduced the analogous inverse-RoPE + FP8 input-quantization optimization on ROCm/aiter and the existing
SGLANG_OPT_FP8_WO_A_FUSED_INVROPEflag. This PR extends that flag to the CUDA UE8M0 path. The BF16 and FP8 wo_a gates are mutually exclusive, so their reported speedups are not additive.Modifications
MQALayer.__init__; check graph state, pre-applied inverse RoPE and current tensor properties at execution time.SGLANG_OPT_FP8_WO_A_FUSED_INVROPE, off by default, with existing fallbacks.Accuracy Tests
Current-head upstream kernel validation (2026-11-02)
PR head:
fb4e80ea8474e8fdb7aab692119202f4834a424c. CI checked out merge5da168b82470b256b49f494dc27ceb991c4399c1, combining this head with upstream main1599b166ac856f4fd192feb2c16304fae7860a72.The B200 kernel job executed
test/registered/kernels/ops/quantization/test_fp8_wo_a.py: all 7 tests passed.The runner summary also records this file as
"passed": true(elapsed: 23seconds for the file subprocess, distinct from unittest's 12.830 seconds). This covers both new tests—production-path numerical equivalence for FP8 codes and packed scales, and CUDA Graph capture/replay with updated inputs—alongside the existing quantization-path tests. Hosted Lint also passed on this head.These are kernel correctness and graph-replay results for the current head. They do not establish full-model serving accuracy, bitwise-equal serving logits, or post-refactor performance gains. Full-model serving and performance validation after the refactor remain pending.
Historical local GPU validation (B300, aiopt v0.5.21)
Local GPU validation uses aiopt v0.5.21 on 8×B300. It shares upstream's packed-int32 UE8M0 contract. On that backport:
These local GPU results predate cleanup commit
7c5d3eb7ce. That commit shares the quantization code and caches eligibility. Subsequent main-based B200 kernel validation is documented below; full-model serving validation after the refactor remains pending. No full model accuracy evaluation is claimed.Local checks on the cleanup: Python syntax, Ruff, isort and clang-format passed. An exhaustive static eligibility comparison matched the previous predicate for configurations with attention output width equal to the configured head dimension.
Source preparation and current head (2026-11-02)
The branch was originally rebased onto main
c757c4bb7c55d1eb69fdb2bdc6e6fb8507acb7a0and subsequently updated by merging main. The current head isfb4e80ea8474e8fdb7aab692119202f4834a424c, with upstream main1599b166ac856f4fd192feb2c16304fae7860a72incorporated.The quantization helper and kernel tests follow upstream's
ops/quantizationpaths, with imports updated accordingly. The shared host validation retains upstream'skDLGPUdevice definition. Repository-pinned pre-commit checks on the six changed files, Python syntax checks andgit diff --checkpassed during the earlier rebase preparation. Current-head hosted Lint and B200 kernel results are documented above. Full-model serving and performance validation after the cleanup/rebase remain pending; the historical performance results below are not measurements of this current head.Upstream CI and DCP fixture correction (2026-11-01)
At
38c39bddb75b4b53fdcc1fd2d791307f4f973fdc(via CI merge769fc5fcce14), B200 CI executedtest/registered/kernels/ops/quantization/test_fp8_wo_a.py: 7 tests passed (Ran 7 tests in 11.821s; OK). This includes production-path numerical equivalence, CUDA Graph replay, and the existing quantization-path tests. These are main-based kernel correctness results; they do not revalidate the historical performance gains or full-model serving behavior.That run's CPU failure was the independent DCP replay fixture missing
skips_prefill_metadata_on_idle_dp_rank. The test file was identical in the PR head and its main base (Git blobef5beb976949ec8fb56be440812c166c5e2b2177).Follow-up commit
289c324carries the one-line test-fixture correction from mickqian's #47736 (source commitbe43d568ca8115e173bd4b9f5d106a3060ae1f8b): setskips_prefill_metadata_on_idle_dp_rank=Falseon the mocked backend. The corrected file matches that source exactly. No production kernel/model code or B200 tests changed after the passing run. The subsequent CI run was stopped by the independent decode-queue fixture failure described below.Decode-queue scheduler fixture correction (2026-11-01)
The next CPU run stopped in
test_decode_queue_cleanup.py::TestHeldDestinationPublication::test_publishes_while_retracted_requests_wait: its mocked scheduler lackstree_cache, whichprocess_decode_queuenow reads even with HiCache disabled. Both the failing test anddisaggregation/decode.pyare identical between that CI merge (632c7f4) and its actual upstream main parent (e298298), so this is a second independent baseline fixture issue. That shard stopped before executing its scheduled DCP test.Commit
fddd180carries the one-line correction from DarkSharpness's #47758 (source44b1e4b35608c8e388b1d16dc86ceec34514bcc3):tree_cache=SimpleNamespace(linker=None). It models the no-linker-offload case while preserving the existing metadata-publication assertion. No test is skipped and no assertion is removed.The corrected file matches #47758 exactly. All applicable pre-commit hooks passed locally on that file. The source PR's targeted CPU run passed 12 tests at its own source head; this is separate from validation of our updated head. CI on the earlier head
fddd180was triggered but stopped at the per-user 120-minute cooldown gate before tests executed. The logged previous accepted trigger is 2026-11-01 14:28:02 UTC, so the earliest retry under that cooldown is 16:28:02 UTC / 2026-11-02 00:28:02 UTC+8. Production code and B200 tests remain unchanged from the previous passing B200 run. After the cooldown expired, empty commitddcabbetriggered another historical CI run on 2026-11-02. It has since been superseded by the main merges leading tofb4e80e; see the current-head validation above.Non-main adaptation
The backport omits
and inv_rope is Nonebecause v0.5.21 lacks that local variable. Main defines it, so this PR retains the guard to avoid double rotation. Local full-model serving validation is on the available aiopt build; the current main-based head has the hosted B200 kernel coverage documented above. Full-model serving validation on that head remains pending.Speed Tests and Profiling
B300 ×8, DeepSeek-V4-Pro, aiopt v0.5.21, TP8/DP8, MegaMoE, 60k input / 1 output, C16, N160, seeds 1/2/3. Radix cache disabled; prefill-delayer enabled. aiakperf uses random token IDs through the
sglangrunner, so this benchmark does not measure real-text tokenization throughput.Each arm used one fresh server startup and three seed runs; fused preceded baseline. These are not three independent paired startups. Fused per-seed throughput: 103,476.7 / 103,283.0 / 103,287.0 tok/s; TTFT: 9.4312 / 9.4523 / 9.4514 s. Baseline raw per-run values and exact dependency/image identifiers are not included in this summary.
These measurements predate the cleanup commit and remain evidence for the preceding implementation; performance after the refactor needs confirmation. Cross-build absolute throughput is not attributed to fusion. No v0.5.21 multi-shape sweep is claimed.
Prior v0.5.17-derived B300 evidence
B300, DeepSeek-V4-Pro, TP8 / DP8, MegaMoE, prefill-dominated workload (output length 1). Each working point is the mean of 3 runs per arm.
The earlier build reported positive throughput deltas in 24/24 paired comparisons and 48 runs without CUDA errors. Its numerical tests reported identical FP8 codes and scales, and its greedy decode comparison produced identical tokens. The upstream port changes the scale storage contract and must be revalidated independently.
Reproduction: tests, server, greedy probe and benchmark
Apply the PR changes to the build, with the non-main
inv_ropeadaptation above. Use the same model weights, dependencies and launch parameters for both arms. The fusion flag is fixed for each server startup. Run the three seeds on one server per arm, then restart with the other flag. The recorded run order was fused first, baseline second.Kernel tests
python3 -m pytest -s test/registered/kernels/ops/quantization/test_fp8_wo_a.py \ -k "fused_inverse_rope"The numerical test covers T ∈ {0, 1, 32, 100, 777, 2047, 8192, 8193}, G ∈ {2, 16}, BF16 strided inputs, FP8 codes, packed scales and output strides. The graph test captures and replays with updated inputs.
Server launch
Set
MODEL_PATHto the local DeepSeek-V4-Pro weights. Run separately withFLAG=1(fused) andFLAG=0(baseline).Wait for inference readiness before sending probes. Stop all workers belonging to this server and verify its ports/GPU allocations have been released before starting the next arm.
Greedy serving probe
Run once per startup, setting a distinct
ACC_OUTfilename; compare the returned texts across saved files.Prefill benchmark
Use the same
MODEL_PATHandFLAGas the running server. For SEED=1, 2, 3, run the following warmup then formal commands, ensuring no warmup requests remain in flight before the formal measurement. Use separate output directories per arm/seed.After applying the cleanup commit, also run the existing full kernel test file to cover the shared unfused quantization path and the existing CPU fixture:
Checklist
fb4e80e(job).fb4e80evia CI merge5da168b: 7 tests passed (job).CI States
Latest PR Test (Base): ❌ Run #41445853732
Latest PR Test (Extra): ❌ Run #41445853576
Latest PR Test (AMD ROCm 10): ✅ Run #41445853908