Skip to content

[Fix][ROCm] MXFP4 MoE round-up inflates TP-sharded expert weights on CDNA3, starving KV cache - #56359

Merged
tjtanaa merged 6 commits into
vllm-project:mainfrom
EmbeddedLLM:bugfix-rocm-mxfp4-moe-roundup
Sep 17, 2026
Merged

tjtanaa merged 6 commits into
vllm-project:mainfrom
EmbeddedLLM:bugfix-rocm-mxfp4-moe-roundup

Conversation

@vllmellm

@vllmellm vllmellm commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Fixes #53961

While testing #53961, I found that the per-GPU VRAM used for weight loading is 135.35 GiB (without EP) vs 103.54 GiB (with EP). Upon closer investigation, it is caused by the rocm's branch of mxfp4_round_up_hidden_size_and_intermediate_size which rounds the intermediate moe size to 256 which inflated the expert weights usage. Before this PR, an existing special case for Kimi-K3 (AITER+SiLU/SiTU) already aligns to 128 instead of 256.

Concretely, for DeepSeek-V4-Pro (moe_intermediate_size=3072, TP=8, no EP):

EP wasn't affected because each GPU holds whole experts, so the intermediate dimension stays at its native 3072 (already aligned); without EP, TP slices it to 384 per GPU, which is not aligned and gets padded.

Change

I extended the existing 128-alignment exception to also cover TRITON_UNFUSED with SiLU/SiTU activation. The pre-existing AITER arm is unchanged: K3's AITER kernel (gfx950-only) handles its native intermediate size (moe_intermediate 3072; e.g. 384/partition at TP8), so K3 keeps 128 on CDNA4.

For the new TRITON_UNFUSED arm, the 128-alignment is gated to CDNA != 4, because opt_flags_amd sets matmul_ogs's block_k=128 whenever weight scales are present on CDNA != 4 (always the case for mxfp4 W4A16 checkpoints) — the unpadded 384-element shard already satisfies the kernel's even-K requirement. gpt-oss (SWIGLUOAI, tuned in #38043) keeps 256.

In essence, the checks keeps the pre-existing Kimi-K3, gpt-oss handling while letting DeepSeek-V4 Pro (TRITON_UNFUSED + SiLU/SiTU on CDNA3) keeps the 128 size without rounding up to 256.

Test Plan

Tested the before/after using this serve command:

# max batched tokens: 16384 will failed before this PR
VLLM_ROCM_USE_AITER=1 vllm serve deepseek-ai/DeepSeek-V4-Pro-0813 \
  --trust-remote-code \
  --kv-cache-dtype fp8 \
  --block-size 256 \
  --tensor-parallel-size 8 \
  --distributed-executor-backend mp \
  --gpu-memory-utilization 0.9 \
  --max-num-seqs 512 \
  --max-num-batched-tokens 16384 \
  --compilation-config '{"mode": 3, "cudagraph_mode": "FULL_DECODE_ONLY"}' \
  --tokenizer-mode deepseek_v4 \
  --tool-call-parser deepseek_v4 \
  --enable-auto-tool-choice \
  --reasoning-parser deepseek_v4 \
  --no-enable-prefix-caching

Test Result

check before after
Model loading took (TP8, no EP) 135.35 GiB 103.54 GiB
1M-ctx serving @ util 0.9 + 16384 failed to start successfully started
greedy outputs, 5 prompts, top-1 logprobs baseline 240/240 tokens identical, 5/5 exact text
round-up unit check (5 backend/activation/cdna combos) — all match expected values
GSM8K (20-shot, limit 200, conc 32) 0.960 flex / 0.685 strict 0.955 flex / 0.700 strict
serving bench 8k-in/1k-out, conc 32, 128 prompts 369 out-tok/s 421 out-tok/s (+14%) — likely due to the unpadded K removes dead weight traffic

Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify mergify Bot added the rocm Related to AMD ROCm label Sep 11, 2026
@github-project-automation github-project-automation Bot moved this to Todo in AMD Sep 11, 2026
@vllmellm
vllmellm force-pushed the bugfix-rocm-mxfp4-moe-roundup branch from 5b31ca6 to fb28983 Compare September 15, 2026 03:35

@Rohan138 Rohan138 left a comment

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.

LGTM, nice catch!

@Rohan138 Rohan138 added the ready ONLY add when PR is ready to merge/full CI is needed label Sep 15, 2026
@github-actions

Copy link
Copy Markdown

✅ @vllmellm, CI is now available for this PR.

  • /ci run starts upstream CI; /amd-ci run starts AMD CI only.
  • Your branch must contain every commit currently on its upstream target branch. Merge or rebase onto the latest target branch, then rerun the command. Append --allow-stale to a run command to test an outdated branch at your own risk.
  • /ci retry retries failed jobs in the CI build for the current PR head. If the current head has no CI build, it starts a new CI build for the current head containing only jobs that failed in the latest earlier CI build for this PR.
  • /amd-ci retry retries failed jobs in AMD CI for the current PR head. Use /amd-ci run when the current head has no AMD CI build.
  • /ci cancel cancels scheduled or running CI builds for this PR branch; /amd-ci cancel does the same for AMD CI only.

@Rohan138

Copy link
Copy Markdown
Collaborator

/ci run

@github-actions

Copy link
Copy Markdown

❌ @Rohan138, Only reviewers with write access can use CI commands before CI is delegated to the PR author.

@AndreasKaratzas

Copy link
Copy Markdown
Member

/ci run

@github-actions

Copy link
Copy Markdown

❌ This PR is 250 commits behind upstream main. Your branch must contain every commit currently on upstream main. No new CI build was started. Merge or rebase onto the latest main, then rerun /ci run. To test this branch at your own risk, use /ci run --allow-stale.

@Rohan138

Copy link
Copy Markdown
Collaborator

@vllmellm can you rebase and run ci?

…ghts on CDNA3

Signed-off-by: vllmellm <vllm.ellm@embeddedllm.com>
@vllmellm
vllmellm force-pushed the bugfix-rocm-mxfp4-moe-roundup branch from 63d4d57 to c7798c2 Compare September 17, 2026 02:17
@vllmellm

Copy link
Copy Markdown
Contributor Author

/ci run

@github-actions

Copy link
Copy Markdown

❌ This PR is 1 commit behind upstream main. Your branch must contain every commit currently on upstream main. No new CI build was started. Merge or rebase onto the latest main, then rerun /ci run. To test this branch at your own risk, use /ci run --allow-stale.

@vllmellm

Copy link
Copy Markdown
Contributor Author

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #89518 for commit ec07102e4d31.

@mergify

mergify Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Hi @vllmellm, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Signed-off-by: vllmellm <vllm.ellm@embeddedllm.com>
Signed-off-by: vllmellm <vllm.ellm@embeddedllm.com>
@vllmellm

Copy link
Copy Markdown
Contributor Author

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #89526 for commit 57bd71ef21bc.

@vllmellm

Copy link
Copy Markdown
Contributor Author

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #89622 for commit b0157f762115.

@tjtanaa

tjtanaa commented Sep 17, 2026

Copy link
Copy Markdown
Member

/ci run

@tjtanaa

tjtanaa commented Sep 17, 2026

Copy link
Copy Markdown
Member

/amd-ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #89626 for commit 87dafb76e680.

@github-actions

Copy link
Copy Markdown

❌ This PR is 1 commit behind upstream main. Your branch must contain every commit currently on upstream main. No new CI build was started. Merge or rebase onto the latest main, then rerun /amd-ci run. To test this branch at your own risk, use /amd-ci run --allow-stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed rocm Related to AMD ROCm

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: PR #51726's >=160GiB tier captures MI300X (191.98 GiB), doubling max_num_batched_tokens and breaking KV cache init for DeepSeek-V4-Pro at 1M

4 participants