Skip to content

Commit f7af076

Browse files
1am9trashfunctionstackxclaudechunfangamd
authored
[AMD][MI35X] 0706 DSV4 sglang mtp (#2108)
* Update config and change log * Update config and change log * fix: source benchmark_lib.sh from repo-level benchmarks/ dir The script sourced ../benchmark_lib.sh, but the lib lives at benchmarks/benchmark_lib.sh (two levels up from fixed_seq_len/), so every lib function (check_env_vars, wait_for_server_ready, run_benchmark_serving, ...) was undefined and the run produced no result JSON (run 28836023139). Matches the ../../benchmark_lib.sh path used by sibling scripts like dsv4_fp4_mi355x_sglang.sh. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Bump docker version * Fix format --------- Co-authored-by: functionstackx <47992694+functionstackx@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: Chun Fang <chun.fang@amd.com>
1 parent cbc9f65 commit f7af076

3 files changed

Lines changed: 28 additions & 133 deletions

File tree

benchmarks/single_node/fixed_seq_len/dsv4_fp4_mi355x_sglang_mtp.sh

Lines changed: 20 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,9 @@
66
# 2026-05-27, commit deaba74), which fixes the ROCm HIP-radix backend's
77
# per-step draft out_cache_loc slicing under CUDA graph (the bug behind the
88
# false-EOS / truncated-generation symptom in sgl issue #20404) and validates
9-
# GSM8K 0.950 with MTP on. The EAGLE chain follows that PR's accuracy config
10-
# for the DP-attention path (steps=2, topk=1, draft=3); the TP-only
11-
# low-concurrency path uses the (3,1,4) chain shared with dsr1_fp4_mi355x_mtp.sh.
12-
#
13-
# Image: #26383 is on sglang `main`, so this runs on the mainline ROCm nightly
14-
# (lmsysorg/sglang-rocm:v0.5.12.post1-rocm720-mi35x-*), NOT a rocm/sgl-dev:*-DSv4
15-
# build. The -DSv4 images are cut from the amd/deepseek_v4 branch, which has not
16-
# merged #26383 (latest da28108 = f96ac98 + build fixes + an unrelated MLA-decode
17-
# refactor; it still crashes at MTP graph capture, run 26723126211). Mainline
18-
# carries #26383 but omits deep_gemm, which DSv4-Pro's default fp8 wo_a path
19-
# imports. AMD doesn't need deep_gemm (it uses aiter/tilelang/torch), and every
20-
# deep_gemm use on the DSv4 path is behind an env-flag fallback, so the block
21-
# below detects deep_gemm's absence and routes around it: SGLANG_OPT_FP8_WO_A_GEMM=0
22-
# (dequant fp8 wo_a -> bf16 + torch.einsum; also skips the weight-load
23-
# transform_sf_into_required_layout that crashed run 26727984372) and
24-
# SGLANG_TOPK_TRANSFORM_512_TORCH=1 (torch topk). The indexer already routes to
25-
# tilelang + torch paged-MQA-logits and MHC to aiter via flags set below. On a
26-
# -DSv4 image that carries #26383, bump amd-master.yaml and the detect restores
27-
# the deep_gemm perf path. RUN_EVAL on the high-conc points gates accuracy.
28-
29-
source "$(dirname "$0")/../benchmark_lib.sh"
9+
# GSM8K 0.950 with MTP on.
10+
11+
source "$(dirname "$0")/../../benchmark_lib.sh"
3012

3113
check_env_vars \
3214
MODEL \
@@ -50,97 +32,12 @@ if [[ "$MODEL" != /* ]]; then hf download "$MODEL"; fi
5032
# from the amd/deepseek_v4 branch in sgl-project/sglang). To bump sglang,
5133
# bump the image tag in configs/amd-master.yaml.
5234

53-
# Transformers in the container doesn't recognize the `deepseek_v4` model_type.
54-
# PR #23608's fallback in hf_transformers_utils.get_config tries to handle this
55-
# by writing a patched config to /tmp, but in practice isn't catching the error
56-
# in this image. Patch the cached config.json directly instead: set model_type
57-
# to `deepseek_v3` so AutoConfig.from_pretrained succeeds, and keep
58-
# architectures=['DeepseekV4ForCausalLM'] so SGLang dispatches to its native
59-
# DSv4 model class (python/sglang/srt/models/deepseek_v4.py).
60-
python3 << PYEOF
61-
import json
62-
from huggingface_hub import hf_hub_download
63-
path = hf_hub_download(repo_id="$MODEL", filename="config.json")
64-
with open(path) as f:
65-
config = json.load(f)
66-
if config.get("model_type") == "deepseek_v4":
67-
config["model_type"] = "deepseek_v3"
68-
with open(path, "w") as f:
69-
json.dump(config, f, indent=2)
70-
print(f"Patched {path}: model_type deepseek_v4 -> deepseek_v3")
71-
else:
72-
print(f"No patch needed: model_type is {config.get('model_type')!r}")
73-
PYEOF
74-
75-
# DSv4 FP4-experts path. Tracks the env block in python/run_dsv4.sh on the
76-
# amd/deepseek_v4 branch (HEAD's active block is FP8; we override the two
77-
# FP4-specific flags below):
78-
# SGLANG_DSV4_FP4_EXPERTS=True -> route experts through the FP4 kernels
79-
# SGLANG_FORCE_TRITON_MOE_FP8=0 -> dispatch MoE through aiter and apply
80-
# the swiglu_limit clamp in the triton
81-
# MoE fallback path.
82-
export SGLANG_REASONING_EFFORT=max
83-
export SGLANG_OPT_USE_FUSED_COMPRESS=true
84-
export SGLANG_OPT_USE_OLD_COMPRESSOR=false
85-
export SGLANG_OPT_USE_TILELANG_SWA_PREPARE=false
86-
export SGLANG_OPT_USE_JIT_KERNEL_FUSED_TOPK=false
87-
export SGLANG_OPT_USE_FUSED_HASH_TOPK=true
88-
export SGLANG_OPT_DEEPGEMM_HC_PRENORM=false
89-
export SGLANG_OPT_USE_TILELANG_MHC_PRE=false
90-
export SGLANG_OPT_USE_TILELANG_MHC_POST=false
91-
export SGLANG_OPT_USE_AITER_MHC_PRE=true
92-
export SGLANG_OPT_USE_AITER_MHC_POST=true
93-
export SGLANG_ENABLE_THINKING=1
94-
export SGLANG_USE_AITER=1
95-
export SGLANG_USE_ROCM700A=1
96-
export SGLANG_TOPK_TRANSFORM_512_TORCH=0
97-
export SGLANG_FP8_PAGED_MQA_LOGITS_TORCH=1
98-
export SGLANG_DSV4_FP4_EXPERTS=True
99-
export SGLANG_OPT_DPSK_V4_RADIX=1
100-
export SGLANG_OPT_USE_OVERLAP_STORE_CACHE=false
101-
export SGLANG_OPT_USE_FUSED_STORE_CACHE=true
102-
export SGLANG_FORCE_TRITON_MOE_FP8=0
103-
export SGLANG_HACK_FLASHMLA_BACKEND=triton
104-
export SGLANG_OPT_USE_TILELANG_INDEXER=true
105-
export SGLANG_OPT_USE_TRITON_SWA_PREPARE=true
35+
export SGLANG_DEFAULT_THINKING=1
36+
export SGLANG_DSV4_REASONING_EFFORT=max
37+
export SGLANG_USE_ROCM700A=0
38+
export SGLANG_HACK_FLASHMLA_BACKEND=unified_kv_triton
10639
export AITER_BF16_FP8_MOE_BOUND=0
107-
export SGLANG_OPT_FUSE_WQA_WKV=true
108-
export SGLANG_OPT_USE_FUSED_PAGED_COMPRESS=true
109-
export SGLANG_OPT_USE_MULTI_STREAM_OVERLAP=0
110-
111-
# MTP-specific knobs landed alongside the graph fix in sgl#26383:
112-
# SGLANG_OPT_USE_TRITON_FUSED_MHC -> fused Triton mhc_post_pre for low conc
113-
# (defaults True in post-#26383 images;
114-
# set explicitly so the recipe is auditable)
115-
# SGLANG_OPT_C4_SPARSE_TOPK -> sparse-attention top-k used in the PR's
116-
# DSv4 MTP accuracy run
117-
export SGLANG_OPT_USE_TRITON_FUSED_MHC=1
118-
export SGLANG_OPT_C4_SPARSE_TOPK=512
119-
120-
# Mainline ROCm nightlies carry #26383 but omit deep_gemm (only rocm/sgl-dev:*-DSv4
121-
# builds bundle it). DSv4-Pro's default fp8 wo_a path imports deep_gemm at weight
122-
# load; detect its absence and route the deep_gemm-touching paths to their torch
123-
# fallbacks. No-op on a deep_gemm-bearing image, so this recipe works on both.
124-
# SGLANG_OPT_FP8_WO_A_GEMM=0 -> wo_a fp8 weights dequantized to bf16 at load
125-
# (_dequant_fp8_wo_a) + o-proj via torch.einsum;
126-
# also skips the post-load deep_gemm
127-
# transform_sf_into_required_layout that crashed.
128-
# SGLANG_TOPK_TRANSFORM_512_TORCH=1 -> torch topk-transform instead of the kernel.
129-
# SGLANG_OPT_USE_TOPK_V2=0 -> skip plan_topk_v2 in the indexer metadata;
130-
# its jit kernel is CUDA-only (topk/ptx.cuh
131-
# #includes <cuda/ptx>) and won't build for
132-
# gfx950. topk_metadata is unused on the torch
133-
# topk path, so empty is fine.
134-
# SGLANG_ENABLE_JIT_DEEPGEMM=0 -> global off; nothing to JIT without the module.
135-
if python3 -c "import deep_gemm" >/dev/null 2>&1; then
136-
echo "deep_gemm present -> using fp8 wo_a / deep_gemm perf path"
137-
else
138-
echo "deep_gemm absent -> routing DSv4 fp8 wo_a / topk around it (mainline nightly)"
139-
export SGLANG_OPT_FP8_WO_A_GEMM=0
140-
export SGLANG_TOPK_TRANSFORM_512_TORCH=1
141-
export SGLANG_OPT_USE_TOPK_V2=0
142-
export SGLANG_ENABLE_JIT_DEEPGEMM=0
143-
fi
40+
14441

14542
SERVER_LOG=/workspace/server.log
14643
PORT=${PORT:-8888}
@@ -156,28 +53,25 @@ start_gpu_monitor
15653
PARALLEL_ARGS=(
15754
--tensor-parallel-size "$TP"
15855
)
159-
# EAGLE chain is selected by DP_ATTENTION. The DP-attention path mirrors the
160-
# sgl#26383 DSv4 ROCm accuracy config (steps=2, topk=1, draft=3); the TP-only
161-
# low-concurrency fallback uses the longer (3,1,4) chain that low batch sizes
162-
# benefit from, matching dsr1_fp4_mi355x_mtp.sh.
16356
SPEC_FLAGS=(
16457
--speculative-algorithm EAGLE
16558
--speculative-num-steps 3
16659
--speculative-eagle-topk 1
16760
--speculative-num-draft-tokens 4
16861
)
62+
CHUNKED_PREFILL_SIZE=$ISL
16963
if [ "${DP_ATTENTION}" = "true" ]; then
64+
export SGLANG_SHARED_EXPERT_TP1=1
65+
export SGLANG_DP_SHARED_EXPERT_LOCAL=1
66+
export SGLANG_DP_USE_GATHERV=1
67+
export SGLANG_DP_USE_REDUCE_SCATTER=1
68+
69+
CHUNKED_PREFILL_SIZE=$((ISL * TP))
17070
PARALLEL_ARGS+=(
17171
--dp "$TP"
17272
--enable-dp-attention
17373
--enable-prefill-delayer
17474
)
175-
SPEC_FLAGS=(
176-
--speculative-algorithm EAGLE
177-
--speculative-num-steps 2
178-
--speculative-eagle-topk 1
179-
--speculative-num-draft-tokens 3
180-
)
18175
fi
18276
if [ "${EP_SIZE:-1}" -gt 1 ]; then
18377
PARALLEL_ARGS+=(--ep-size "$EP_SIZE")
@@ -192,17 +86,19 @@ python3 -m sglang.launch_server \
19286
"${SPEC_FLAGS[@]}" \
19387
--trust-remote-code \
19488
--disable-radix-cache \
195-
--attention-backend compressed \
89+
--attention-backend dsv4 \
90+
--cuda-graph-max-bs ${CONC} \
19691
--max-running-requests ${CONC} \
19792
--mem-fraction-static 0.90 \
19893
--swa-full-tokens-ratio 0.15 \
19994
--page-size 256 \
95+
--kv-cache-dtype fp8_e4m3 \
20096
--context-length $MAX_MODEL_LEN \
201-
--chunked-prefill-size 8192 \
97+
--chunked-prefill-size $CHUNKED_PREFILL_SIZE \
20298
--disable-shared-experts-fusion \
20399
--tool-call-parser deepseekv4 \
204100
--reasoning-parser deepseek-v4 \
205-
--chat-template "$(dirname "$0")/chat_templates/deepseek_v4_thinking.jinja" \
101+
--chat-template "$(dirname "$0")/../chat_templates/deepseek_v4_thinking.jinja" \
206102
--watchdog-timeout 1800 $EVAL_CONTEXT_ARGS > $SERVER_LOG 2>&1 &
207103

208104
SERVER_PID=$!

configs/amd-master.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,16 +1764,8 @@ dsv4-fp4-mi355x-sglang:
17641764
# graph + sparse triton attn optimizations, merged to main 2026-05-27). That PR
17651765
# fixes the ROCm HIP-radix MTP CUDA-graph bug (the false-EOS symptom in sgl
17661766
# #20404) and validates GSM8K 0.950 with MTP on.
1767-
#
1768-
# #26383 is on sglang `main`, NOT the amd/deepseek_v4 branch the rocm/sgl-dev:*-DSv4
1769-
# builds are cut from (latest da28108 = f96ac98 + build fixes + an unrelated
1770-
# MLA-decode refactor, still pre-#26383 -> kv_score crash, run 26723126211). So we
1771-
# pin the mainline ROCm nightly, which carries #26383. Mainline omits deep_gemm,
1772-
# but the recipe detects that and routes the DSv4 fp8 wo_a / topk paths to their
1773-
# torch fallbacks (see dsv4_fp4_mi355x_sglang_mtp.sh). When a -DSv4 image carrying
1774-
# #26383 ships, bump to it; the recipe auto-restores the deep_gemm perf path.
17751767
dsv4-fp4-mi355x-sglang-mtp:
1776-
image: lmsysorg/sglang-rocm:v0.5.12.post1-rocm720-mi35x-20260601
1768+
image: lmsysorg/sglang-rocm:v0.5.14-rocm720-mi35x-20260708
17771769
model: deepseek-ai/DeepSeek-V4-Pro
17781770
model-prefix: dsv4
17791771
runner: mi355x

perf-changelog.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4651,6 +4651,13 @@
46514651
- "Recipes sourced from NVIDIA/srt-slurm branch sa-submission-q2-2026 (gb300_nvfp4 MTP recipes)"
46524652
pr-link: https://github.com/SemiAnalysisAI/InferenceX/pull/1799
46534653

4654+
- config-keys:
4655+
- dsv4-fp4-mi355x-sglang-mtp
4656+
description:
4657+
- "Bump image to lmsysorg/sglang-rocm:v0.5.14-rocm720-mi35x-20260708"
4658+
- "Clean the export envs"
4659+
pr-link: https://github.com/SemiAnalysisAI/InferenceX/pull/2108
4660+
46544661
- config-keys:
46554662
- dsv4-fp4-b200-sglang-agentic-hicache
46564663
- dsv4-fp4-b300-sglang-agentic-hicache

0 commit comments

Comments
 (0)