Skip to content

fix: Enable DP-Attention + EAGLE speculative decoding on AMD HIP - #1

Open
Chronostasys wants to merge 2 commits into
mainfrom
fix/dp-attention-eagle-hip
Open

Chronostasys wants to merge 2 commits into
mainfrom
fix/dp-attention-eagle-hip

Conversation

@Chronostasys

Copy link
Copy Markdown
Collaborator

Fix 5 HIP compatibility bugs that prevent DP-Attention=2 + EAGLE speculative decoding with CUDA graph capture on AMD ROCm (gfx942).

See commit message for details.

Tested on: 8x AMD MI300X (gfx942), ROCm 6.4.4, SGLang v0.5.14

Fix 5 HIP compatibility bugs that prevent DP-Attention=2 + EAGLE
speculative decoding with CUDA graph capture on AMD ROCm (gfx942):

1. dsa_indexer.py: HIP branch of _get_topk_paged() was missing
   q_offset truncation for q_fp8/weights, and batch_size truncation
   for seqlens_32/block_tables in target_verify/draft_extend modes.
   Under DP-Attention, q_fp8 has local DP-group batch size while
   seqlens_32 has global batch size, causing a shape mismatch.
   Fix: mirror the CUDA branch's q_fp8[:q_offset] truncation pattern.

2. parallel_state.py: attention TP group (attn_tp_group) was not
   enabling PyNccl on HIP, causing it to fall back to
   torch.distributed.all_reduce (NCCL backend). NCCL's watchdog thread
   checks hipEvent during CUDA graph capture, triggering
   hipErrorCapturedEvent on ROCm.
   Fix: add is_hip() to the use_pynccl condition.

3. parallel_state.py: attention TP group was still creating a
   ProcessGroupNCCL instance (with watchdog thread) even with
   use_pynccl=True, because the backend was still 'nccl'.
   Fix: use 'gloo' backend on HIP so no NCCL watchdog is created.

4. parallel_state.py: regular TP group (_TP) also lacked
   use_pynccl=is_hip(), causing torch.distributed.all_reduce to be
   called during CUDA graph capture (hipErrorStreamCaptureUnsupported).
   Fix: add use_pynccl=is_hip() to _TP initialization.

5. parallel_state.py: graph_capture() context manager did not include
   _ATTN_TP in its group iteration list, so attention TP group's
   PyNccl communicator was never enabled during graph capture,
   causing fallback to NCCL and hipErrorStreamCaptureUnsupported.
   Fix: add _ATTN_TP to the graph_capture group list.

All changes are conditional on is_hip() or forward_mode checks and
do not affect NVIDIA/CUDA code paths.

Tested on: 8x AMD MI300X (gfx942), ROCm 6.4.4, SGLang v0.5.14
  - DP=1 + EAGLE: works without patches 2-5 (only patch 1 needed)
  - DP=2 + EAGLE: requires all 5 patches
  - accept_length=6.0 (near-saturating), throughput/gpu=643 at c=16
@Chronostasys
Chronostasys force-pushed the fix/dp-attention-eagle-hip branch 2 times, most recently from 20955e8 to 53605d2 Compare July 9, 2026 15:15
…ernel

GLM-5.2 DSA KV cache has head_dim=576 (k_nope=512 + k_rope=64),
which is not a multiple of 128. The original load_vec/store_vec
assumed kBytes % 128 == 0, causing JIT compilation to fail and
disabling HiCache entirely.

Fix: For 128-aligned sizes, keep the original package selection
logic (128/kNumThreads) to ensure zero behavioral change. For
non-128-aligned sizes, fall back to the largest supported package
size (16B/8B/4B) that divides kBytes/kNumThreads evenly.

Verified:
- All standard sizes (128/256/512/1024/2048) with kNumThreads
  8/16/32 produce identical package sizes as the original code
- New size 576 with kUnroll=2 (kNumThreads=16): unit=4, 9 loops
- New size 576 with kUnroll=4 (kNumThreads=8): unit=8, 9 loops
- Both cover exactly 576 bytes per element
@Chronostasys
Chronostasys force-pushed the fix/dp-attention-eagle-hip branch from ebd106d to f9ac5f2 Compare July 9, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant