-
Notifications
You must be signed in to change notification settings - Fork 254
[AMD] [AgentX] Add MI325X Qwen3.5 FP8 SGLang MTP #2566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+190
−0
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
203d594
[AMD][AgentX] Add MI325X Qwen3.5 FP8 SGLang MTP
cquil11 6b48e18
Fix AgentX chat-template flag and changelog link
cquil11 4112d42
fix(amd): fit qwen3.5 mtp hybrid cache on tp2
cquil11 2f257a9
fix(amd): reserve tp2 hybrid and kv pools
cquil11 ada0d27
Tune MI325X Qwen3.5 AgentX sweep
cquil11 000e632
Merge current main into MI325X AgentX submission
cquil11 86e3196
Merge latest main into MI325X AgentX submission
cquil11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
151 changes: 151 additions & 0 deletions
151
benchmarks/single_node/agentic/qwen3.5_fp8_mi325x_mtp.sh
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| #!/usr/bin/env bash | ||
| set -eo pipefail | ||
| set -x | ||
|
|
||
| # AgentX trace replay for Qwen3.5-397B-A17B FP8 on MI325X with SGLang | ||
| # native EAGLE/NEXTN MTP. Throughput uses the committed golden synthetic | ||
| # acceptance length; evaluation retains real target-model verification. | ||
|
|
||
| source "$(dirname "$0")/../../benchmark_lib.sh" | ||
|
|
||
| export EVAL_FRAMEWORK="lm-eval" | ||
|
|
||
| check_env_vars \ | ||
| MODEL TP CONC EP_SIZE \ | ||
| TOTAL_CPU_DRAM_GB RESULT_DIR DURATION | ||
|
|
||
| SCHEDULER_RECV_INTERVAL=${SCHEDULER_RECV_INTERVAL:-30} | ||
|
|
||
| if [[ -n "${SLURM_JOB_ID:-}" ]]; then | ||
| echo "JOB $SLURM_JOB_ID running on ${SLURMD_NODENAME:-unknown}" | ||
| fi | ||
|
|
||
| if [[ -n "${ROCR_VISIBLE_DEVICES:-}" ]]; then | ||
| export HIP_VISIBLE_DEVICES="$ROCR_VISIBLE_DEVICES" | ||
| fi | ||
|
|
||
| if [[ -n "${MODEL_PATH:-}" ]]; then | ||
| if [[ ! -d "$MODEL_PATH" || -z "$(ls -A "$MODEL_PATH" 2>/dev/null)" ]]; then | ||
| hf download "$MODEL" --local-dir "$MODEL_PATH" | ||
| fi | ||
| else | ||
| hf download "$MODEL" | ||
| export MODEL_PATH="$MODEL" | ||
| fi | ||
|
|
||
| rocm-smi || true | ||
| amd-smi || true | ||
|
|
||
| export WEKA_LOADER_OVERRIDE=semianalysis_cc_traces_weka_062126_256k | ||
| resolve_trace_source | ||
| install_agentic_deps | ||
|
|
||
| # This is a single aggregate SGLang engine, so one logical backend metrics | ||
| # endpoint is authoritative. build_replay_cmd also discovers the public | ||
| # endpoint; AIPerf deduplicates the explicit copy. | ||
| export AIPERF_SERVER_METRICS_URLS="http://localhost:${PORT}/metrics" | ||
| export AIPERF_REQUIRED_SERVER_METRIC_PREFIX="sglang:" | ||
|
|
||
| SERVER_LOG="$RESULT_DIR/server.log" | ||
| mkdir -p "$RESULT_DIR" | ||
|
|
||
| SERVER_PID="" | ||
| cleanup_agentic_services() { | ||
| local exit_code=$? | ||
| trap - EXIT INT TERM | ||
| set +e | ||
| stop_background_process_tree "$SERVER_PID" "SGLang server" 60 | ||
| exit "$exit_code" | ||
| } | ||
| trap cleanup_agentic_services EXIT | ||
| trap 'exit 130' INT | ||
| trap 'exit 143' TERM | ||
|
|
||
| PARALLEL_ARGS=( | ||
| --tp "$TP" | ||
| --dp 1 | ||
| --ep-size "$EP_SIZE" | ||
| ) | ||
|
|
||
| TOKENIZER_ARGS=() | ||
| if [ "$TP" -ge 4 ]; then | ||
| TOKENIZER_ARGS=(--tokenizer-worker-num 6) | ||
| fi | ||
|
|
||
| # AgentX concurrency counts live session trees rather than HTTP requests. | ||
| # Keep capacity for subagent fan-out while bounding graph-capture memory. | ||
| MAX_RUNNING_REQUESTS=$((2 * CONC)) | ||
| CUDA_GRAPH_MAX_BS="$CONC" | ||
| [ "$CUDA_GRAPH_MAX_BS" -gt 64 ] && CUDA_GRAPH_MAX_BS=64 | ||
|
|
||
| # With EAGLE enabled, SGLang reserves 15% of this budget for the draft model. | ||
| # TP2 needs an effective 0.8075 target-model budget to fit Qwen3.5's weights, | ||
| # hybrid state, and KV pools; TP4/TP8 retain the established 0.68 budget. | ||
| MEM_FRACTION_STATIC=0.80 | ||
| if [ "$TP" -eq 2 ]; then | ||
| MEM_FRACTION_STATIC=0.95 | ||
| fi | ||
|
|
||
| export PYTHONNOUSERSITE=1 | ||
| export AIPERF_HTTP_TCP_USER_TIMEOUT=900000 | ||
| export SGLANG_USE_AITER=1 | ||
| export SGLANG_USE_AITER_UNIFIED_ATTN=1 | ||
| export SGLANG_TIMEOUT_KEEP_ALIVE=1800 | ||
|
|
||
| # Synthetic rejection sampling is only for performance replay. The AL is the | ||
| # committed Qwen3.5 thinking-on value for three speculative tokens. Evals use | ||
| # real target-model verification. | ||
| if [ "${EVAL_ONLY:-false}" != "true" ]; then | ||
| export SGLANG_SIMULATE_ACC_LEN=3.39 | ||
| export SGLANG_SIMULATE_ACC_METHOD=match-expected | ||
| export SGLANG_SIMULATE_ACC_TOKEN_MODE=real-draft-token | ||
| fi | ||
|
|
||
| SGLANG_CMD=( | ||
| python3 -m sglang.launch_server | ||
| --model-path "$MODEL_PATH" | ||
| --served-model-name "$MODEL" | ||
| --host 0.0.0.0 | ||
| --port "$PORT" | ||
| --trust-remote-code | ||
| "${PARALLEL_ARGS[@]}" | ||
| --attention-backend aiter | ||
| --quantization fp8 | ||
| --kv-cache-dtype fp8_e4m3 | ||
| --mamba-ssm-dtype bfloat16 | ||
| --mem-fraction-static "$MEM_FRACTION_STATIC" | ||
| --model-loader-extra-config '{"enable_multithread_load": true}' | ||
| --watchdog-timeout 1200 | ||
| --enable-aiter-allreduce-fusion | ||
| --page-size 16 | ||
| --cuda-graph-max-bs "$CUDA_GRAPH_MAX_BS" | ||
| --max-running-requests "$MAX_RUNNING_REQUESTS" | ||
| --max-prefill-tokens 32768 | ||
| --chunked-prefill-size 32768 | ||
| --scheduler-recv-interval "$SCHEDULER_RECV_INTERVAL" | ||
| --stream-interval 50 | ||
| "${TOKENIZER_ARGS[@]}" | ||
| --tokenizer-path "$MODEL" | ||
| --reasoning-parser qwen3 | ||
| --tool-call-parser qwen3_coder | ||
| --speculative-algorithm EAGLE | ||
| --speculative-num-steps 3 | ||
| --speculative-eagle-topk 1 | ||
| --speculative-num-draft-tokens 4 | ||
| --enable-metrics | ||
| --enable-cache-report | ||
| ) | ||
|
|
||
| write_command "$RESULT_DIR/sglang_command.txt" "${SGLANG_CMD[@]}" | ||
| "${SGLANG_CMD[@]}" > "$SERVER_LOG" 2>&1 & | ||
| SERVER_PID=$! | ||
|
|
||
| wait_for_server_ready --port "$PORT" --server-log "$SERVER_LOG" --server-pid "$SERVER_PID" | ||
|
|
||
| if [ "${EVAL_ONLY:-false}" = "true" ]; then | ||
| run_eval --port "$PORT" | ||
| else | ||
| build_replay_cmd "$RESULT_DIR" | ||
| REPLAY_CMD+=" --apply-chat-template" | ||
| run_agentic_replay_and_write_outputs "$RESULT_DIR" | ||
| fi | ||
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 The script appends
--use-chat-templatetoREPLAY_CMD(lines 145-147), but that flag only exists onrun_benchmark_serving's fixed-seq-len path, not on the aiperf CLI thatbuild_replay_cmdinvokes here.build_replay_cmdalready sets--endpoint /v1/chat/completionsand--endpoint-type chat, so aiperf will reject the unrecognized flag and fail the replay step for every throughput concurrency arm (62 points) in this recipe. Fix by deleting theREPLAY_CMD+=" --use-chat-template"line.Extended reasoning...
What the bug is
benchmark_lib.sh'sbuild_replay_cmdconstructsREPLAY_CMDas an invocation of$AIPERF_CLI profile --scenario inferencex-agentx-mvp ...(benchmark_lib.sh:1927), whereAIPERF_CLI="${AIPERF_VENV}/bin/aiperf"(benchmark_lib.sh:1721) — the external NVIDIAaiperfPython CLI. This is a completely different program fromrun_benchmark_serving, and--use-chat-templateis not one of its recognized arguments.--use-chat-templateis defined only insiderun_benchmark_serving's own bash arg-parsing loop (benchmark_lib.sh:520-526), which is consumed by the fixed-seq-len benchmarking path and appended tobenchmark_cmd(notREPLAY_CMD) at benchmark_lib.sh:636-638. It has no meaning toaiperf profile.The code path that triggers it
In
qwen3.5_fp8_mi325x_mtp.sh(lines 144-149):build_replay_cmdalready sets--endpoint /v1/chat/completionsand--endpoint-type chat(benchmark_lib.sh:1929-1930), which is aiperf's own mechanism for chat-formatted prompts — nothing further is needed. The extra line simply appends a bogus flag to the string that later gets executed as$REPLAY_CMDinsiderun_agentic_replay_and_write_outputs.Why nothing prevents it
There's no static validation of
REPLAY_CMDbefore it's executed — it's a plain bash string built up with+=and latereval'd/executed directly. aiperf's own argparse-based CLI is what will reject the unknown flag, but only at runtime, once the sweep is actually dispatched to a runner.Impact
Every non-
EVAL_ONLYthroughput arm in this recipe (the full 62-point discovery grid across TP2/EP2, TP4, TEP4, TP8, TEP8) takes theelsebranch that callsbuild_replay_cmd+ this bad append +run_agentic_replay_and_write_outputs. aiperf will exit non-zero on the unrecognized argument, sorun_agentic_replay_and_write_outputswill fail for every one of those 62 points. OnlyEVAL_ONLY=trueruns (which take therun_evalbranch instead) are unaffected.Root cause
This is a misapplication of the AGENTS.md rule "Every
*_mtp.shpasses--use-chat-templatetorun_benchmark_serving." That rule is scoped specifically torun_benchmark_serving(the fixed-seq-len benchmarking path). This script is an agentic recipe that never callsrun_benchmark_serving— it drivesaiperfdirectly viabuild_replay_cmd/run_agentic_replay_and_write_outputs. A repo-wide check confirms no other agentic*_mtp.shscript (e.g.qwen3.5_fp8_b300_sglang_mtp.sh,glm5.2_fp4_mi355x_sglang_mtp.sh,dsv4_fp4_mi355x_vllm_mtp.sh) appends--use-chat-templatetoREPLAY_CMD; they only append legitimate aiperf flags like--server-metrics. In fact, the siblingkimik3_fp4_b300_vllm_mtp.shcarries an explicit comment noting this exact distinction and stating there's "Nothing to add here" for agentic recipes.Step-by-step proof
elsebranch (non-EVAL_ONLY) at line 143.build_replay_cmd "$RESULT_DIR"setsREPLAY_CMD="$AIPERF_VENV/bin/aiperf profile --scenario inferencex-agentx-mvp --url http://localhost:$PORT --endpoint /v1/chat/completions --endpoint-type chat --streaming --model $MODEL --concurrency $CONC --benchmark-duration $duration --stats-interval 30 ...".REPLAY_CMD+=" --use-chat-template".run_agentic_replay_and_write_outputs "$RESULT_DIR"executes$REPLAY_CMD, i.e. runsaiperf profile ... --use-chat-template.--use-chat-templateand exits non-zero, causingrun_agentic_replay_and_write_outputsto report a failed replay for that concurrency arm.qwen3.5-fp8-mi325x-sglang-agentic-mtpgrid.Fix
Simply delete line 147 (
REPLAY_CMD+=" --use-chat-template");build_replay_cmd's existing--endpoint-type chatalready covers chat formatting for the aiperf replay.