Repository navigation
[AMD] Fix DSv4 draft extend taking the target compression path during prefill - #37713
Merged
HaiShaw merged 1 commit intoSep 3, 2026
Merged
Conversation
Duyi-Wang
requested review from
Fridge003,
HaiShaw,
Qiaolin-Yu,
hebiao064,
ispobock and
merrymercy
as code owners
September 3, 2026 04:48
Duyi-Wang
force-pushed
the
fix/dsv4-draft-extend-need-compress
branch
2 times, most recently
from
September 3, 2026 07:56
36ecc90 to
068f9d9
Compare
… prefill
On MI355X, DeepSeek-V4-Pro with EAGLE/MTP at TP 4 with DP attention aborts
within 90 s of the server becoming ready, on the first batch of real prefills
and before a single decode step:
HSA_STATUS_ERROR_EXCEPTION ... code: 0x1016
torch.AcceleratorError: HIP error: unspecified launch failure
eagle_worker_v2.py _draft_extend_for_prefill
deepseek_v4_backend_hip_radix.py init_forward_metadata_prefill
_attach_unified_kv_prefill_meta -> torch.repeat_interleave
Two call sites reach the prefill branch of init_forward_metadata for a draft
model, and only one rewrites forward_mode:
* eagle_worker_common.prepare_for_draft_extend() -- the decode path -- sets
ForwardMode.DRAFT_EXTEND_V2.
* eagle_worker_v2._draft_extend_for_prefill() -- the prefill path -- hands
the draft runner the target's batch untouched, so it stays
ForwardMode.EXTEND.
The backend decides compression from forward_mode alone, so on the prefill
path need_compress stays True and the draft model is sent down the compression
path. It owns no compression pool to begin with -- the two pools initialise as
draft: c4_size=0 c128_size=0
target: c4_size=1832064 c128_size=57252
so this is not a draft/target size mismatch but compression metadata computed
against a pool that does not exist. The resulting out-of-bounds access is
reported asynchronously and surfaces at the next synchronisation point, the
repeat_interleave in _attach_unified_kv_prefill_meta, which omits output_size
and so implies a sum() D2H copy. That line is where it is observed, not where
it faults.
The backend already reads model_runner.is_draft_worker in __init__ (for the
dspark check). Keep it as a second, mode-independent source of truth, so a
draft worker never takes the compression path regardless of the forward_mode
it is handed. Only draft-worker backend instances are affected.
Duyi-Wang
force-pushed
the
fix/dsv4-draft-extend-need-compress
branch
from
September 3, 2026 08:19
068f9d9 to
8c28a05
Compare
kkHuang-amd
approved these changes
Sep 3, 2026
kkHuang-amd
left a comment
Collaborator
There was a problem hiding this comment.
LGTM.
One question, this issue should be not related to TP size, right?
HaiShaw
approved these changes
Sep 3, 2026
This was referenced Sep 3, 2026
StevenChenSE
pushed a commit
to StevenChenSE/sglang
that referenced
this pull request
Sep 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
On MI355X (gfx950), DeepSeek-V4-Pro with EAGLE/MTP at TP 4 with DP attention aborts within
90 s of the server becoming ready — on the first batch of real prefills, before a single decode
step completes:
Deterministic, reproduced on clean nodes across several configurations. The reporting rank
varies (DP1 and DP2 observed), so it is not rank-specific.
Root cause
Two call sites reach the prefill branch of
init_forward_metadatafor a draft model, and onlyone rewrites
forward_mode:forward_modeeagle_worker_common.prepare_for_draft_extend()ForwardMode.DRAFT_EXTEND_V2eagle_worker_v2._draft_extend_for_prefill()ForwardMode.EXTENDThe backend decides compression from
forward_modealone (need_compress = not is_draft), so onthe prefill path a draft model is sent down the compression path. It owns no compression pool to
begin with — the two pools initialise as
so this is not a draft/target size mismatch but compression metadata computed against a pool that
does not exist. The resulting out-of-bounds access is reported asynchronously and surfaces at the
next synchronisation point — the
repeat_interleavein_attach_unified_kv_prefill_meta, whichomits
output_sizeand therefore implies asum()D2H copy. That line is where the fault isobserved, not where it occurs.
Instrumenting the branch confirms it at runtime: on the failing ranks the draft worker is handed
ForwardMode.EXTEND, and the write offsets it computes (c4_out_locup to 64) point into a poolof size 0.
Modifications
The backend already reads
model_runner.is_draft_workerin__init__(for the dspark check).Keep it as a named attribute and use it as a second, mode-independent source of truth:
A draft worker now never takes the compression path regardless of the
forward_modeit ishanded. Only draft-worker backend instances are affected; the target is unchanged.
Fixing it here rather than by rewriting
forward_modein_draft_extend_for_prefillkeeps theblast radius to this backend —
forward_modeis read by the logits processor, the CUDA-graphrunners and several other backends.
Tests
Full agentic replay (long-context, tool-heavy, multi-turn) on a single MI355X node, TP 4 + DP
attention, EAGLE MTP (3 steps, topk 1, 4 draft tokens), hierarchical cache, concurrency 32.
hipErrorLaunchFailurePrefill batchDecode batchreturned=1/354, then stalledreturned=330/354,errors=0Same image, same node class, same workload; the only difference is this patch.
🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ❌ Run #33732720236
Latest PR Test (Extra): ❌ Run #33735198934
Latest PR Test (AMD ROCm 7.2): ❌ Run #33732720244