Skip to content

[Fix] deepseek-v4: Preserve decoder-tail token-count ownership - #45915

Merged
ch-wan merged 1 commit into
mainfrom
cheng/hot-fix/decoder-tail-global-counter
Oct 23, 2026
Merged

ch-wan merged 1 commit into
mainfrom
cheng/hot-fix/decoder-tail-global-counter

Conversation

@ch-wan

@ch-wan ch-wan commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

This PR is part of a stack (oldest at bottom):

Motivation

DeepSeek-V4 decoder-tail graphs need the current live token prefix on every replay. A row graph previously owned only the LOCAL count, so a distinct GLOBAL MoE count could not safely follow changing replay sizes. This prevented capture of supported attention-TP-sharded tails; borrowing the parent counter would instead leave captured kernels reading another batch's state.

This change gives each opted-in graph its own LOCAL and GLOBAL count views. Replay updates both while preserving the parent batch's counters and the existing default row-runner behavior.

Changes

  • Pass the gathered tail's live row count from DecoderReplayTail.run to RowBucketGraphRunner.
  • Derive the LOCAL count for the captured TP bucket and keep the GLOBAL prefix in its own graph-owned view.
  • Pack both int32 counts into one int64 allocation and update them with one fill, preserving the single-allocation/single-update structure.
  • Separate graph cache entries by count domains and attention-TP sharding. Custom MoE bounds without a supported owner continue to decline capture.

Review order

  1. python/sglang/srt/models/deepseek_v4_replay_tail.py: capture admission and the gathered GLOBAL prefix.
  2. python/sglang/srt/model_executor/runner/row_bucket_graph_runner.py: count storage, localization, cache identity and replay updates.
  3. test_num_token_non_padded_localization.py and test_decoder_tail_moe_bound.py: domain selection, parent-storage preservation and changing-prefix replay.

Validation

Based on main 25ad569ff9. Checks ran on the integrated source f3a116529a; all four implementation/test files match this PR's f3d331d859 exactly.

  • The complete 13-test localization unit file passed within a combined 181-test CPU suite.
  • On 1× NVIDIA B300, SM10.3, PyTorch 2.14.1+cu130, the two CUDA counter-ownership tests and two virtual-rank subtests passed. They execute real captures/replays across buckets, changing and idle prefixes, scalar/vector counter shapes, and unchanged parent pointers/values.
  • The CUDA fixture executes production batch-copy, allocation, fill, cache and tail-run paths. Decoder-layer math and distributed recording are substituted.
  • Normal configured pre-commit hooks passed.

Full-model attention, real multi-rank collectives and serving performance were not tested. These checks establish count ownership and CUDA replay behavior, not a whole-stack performance result. Eager CPU submission overhead is outside the performance scope.

Rebase validation

This five-PR stack was rebased without conflicts onto main 8b9f72417f. All five patches retain their stable patch IDs relative to the preceding published stack; the newer main commits do not touch the stack's changed files. The existing removal of the unused materialized_routing parameter and its three call-site arguments in #45917 is preserved.

Each rebased PR commit passed its configured pre-commit checks independently. The final stack passes git diff --check, and all 72 changed Python files parse successfully. CPU test suites, native GPU tests and performance measurements were not rerun for this rebase. Previously reported results, including those at integrated e6670af1ad, remain evidence for those earlier revisions with their stated limits.

CPU CI follow-up

Run 39935811691 exposed an upstream Flux2 import test registered in the CPU suite, whose environment lacks the diffusion dependencies. The import chain also queries the active GPU. #45915 moves that check to the existing CUDA diffusion unit suite, which installs those dependencies, while retaining its XPU registration and the real subprocess check that blocks Intel Triton imports. This registration fix is propagated through the stack.

The Flux2 import check passes on 1× NVIDIA B300 with PyTorch 2.14.1+cu130, Triton 3.8.0 and Diffusers 0.37.0; its five Intel-XPU numerical cases are skipped on CUDA and were not rerun on XPU. Full integrated registry collection validates 2,535 files / 3,077 registrations, including the enabled diffusion/XPU selections and the preceding GGUF MUSA fix. Configured checks pass for the changed files. Only three test files change across this follow-up; production code is unchanged. A fresh full CI result is not claimed.

Merge preparation

Rebased this component onto main 9d7ad308bd for squash merge. Resolved the overlap with #46040 by keeping the CPU registration removed and retaining the diffusion CUDA import regression alongside its XPU registration. No test suites or performance measurements were rerun for this merge. Earlier validation sections describe their named revisions.


CI States

Latest PR Test (Base): ❌ Run #40011615879
Latest PR Test (Extra): ❌ Run #40011615862
Latest PR Test (AMD ROCm 10): ❌ Run #40011615911

@ch-wan
ch-wan force-pushed the cheng/hot-fix/decoder-tail-global-counter branch from b556b74 to c6e2917 Compare October 23, 2026 19:27
@ch-wan
ch-wan merged commit 1340044 into main Oct 23, 2026
109 of 126 checks passed
@ch-wan
ch-wan deleted the cheng/hot-fix/decoder-tail-global-counter branch October 23, 2026 19:28
@ch-wan
ch-wan restored the cheng/hot-fix/decoder-tail-global-counter branch October 23, 2026 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant