Skip to content

[AMD] fix dsv4 indexer dtype dispatch on gfx950 - #29479

Merged
HaiShaw merged 4 commits into
sgl-project:mainfrom
HaiShaw:fix_fp8
Jul 9, 2026
Merged

HaiShaw merged 4 commits into
sgl-project:mainfrom
HaiShaw:fix_fp8

Conversation

@billishyahao

@billishyahao billishyahao commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

Motivation

The DeepSeek-V4 indexer and the unified-KV paged-decode kernel selected their FP8 data type with is_hip(), which hardcodes torch.float8_e4m3fnuz for all AMD GPUs. This is only correct on CDNA3 (gfx942). This PR aligns the dtype so the dispatch is correct on gfx950 (and unchanged on gfx942 / NVIDIA).

Modifications

  • python/sglang/srt/layers/attention/dsv4/indexer.py
    • Select FP8_DTYPE / FP8_MAX via is_fp8_fnuz() instead of is_hip().
    • Import is_fp8_fnuz from sglang.srt.layers.quantization.fp8_kernel; drop the
      now-unused is_hip import.
  • python/sglang/srt/layers/attention/dsv4/unified_kv_kernels/paged_decode.py
    • Select _FP8_DTYPE via is_fp8_fnuz() instead of the hardcoded
      torch.float8_e4m3fnuz; add the import and update the storage comment.

Accuracy Tests

GSM8K on gfx950 (MI355) with DeepSeek-V4-Pro, tp=8, --kv-cache-dtype fp8_e4m3, --attention-backend dsv4:

lm_eval --model local-completions \
  --model_args model=/models/DeepSeek-V4-Pro,base_url=http://localhost:8000/v1/completions,num_concurrent=16,max_retries=3,tokenized_requests=False \
  --tasks gsm8k --num_fewshot 5
|Tasks|Version|     Filter     |n-shot|  Metric   |   |Value |   |Stderr|
|gsm8k|      3|flexible-extract|     5|exact_match|↑  |0.9507|±  |0.0060|
|     |       |strict-match    |     5|exact_match|↑  |0.9515|±  |0.0059|

Speed Tests and Profiling

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ❌ Run #29009248782
Latest PR Test (Extra): ❌ Run #29009248687

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@billishyahao billishyahao changed the title [AMD] fix indexer dtype dispatch on gfx950 [AMD] fix dsv4 indexer dtype dispatch on gfx950 Jun 27, 2026
if is_hip():
if is_fp8_fnuz():
FP8_DTYPE = torch.float8_e4m3fnuz
FP8_MAX = torch.finfo(FP8_DTYPE).max

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@billishyahao cross repos, we use abs up to 224.0, not 240.0 as FP8_MAX for e4m3fnuz.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get it! I re-checked the usage and FP8_MAX is invoked within indexer.py so I removed this part totally.

@HaiShaw
HaiShaw merged commit 336b64e into sgl-project:main Jul 9, 2026
95 of 109 checks passed
michaelzhang-ai pushed a commit that referenced this pull request Jul 10, 2026
Co-authored-by: HAI <hixiao@gmail.com>
(cherry picked from commit 336b64e)
Fridge003 pushed a commit that referenced this pull request Jul 10, 2026
…h on gfx950 (#29479) (#30725)

Co-authored-by: billishyahao <bill.he@amd.com>
Co-authored-by: HAI <hixiao@gmail.com>
michaelzhang-ai pushed a commit that referenced this pull request Jul 10, 2026
Co-authored-by: HAI <hixiao@gmail.com>
(cherry picked from commit 336b64e)
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
…h on gfx950 (sgl-project#29479) (sgl-project#30725)

Co-authored-by: billishyahao <bill.he@amd.com>
Co-authored-by: HAI <hixiao@gmail.com>
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
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.

2 participants