Conversation
…A models Signed-off-by: psakhamo <psakhamo@amd.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
[ROCm][WIP] When fused_qkv_a_proj uses sequence-parallel mode (disable_tp=True),
the profiling run all-gathers hidden_states across TP ranks, producing tensors
with tp_size * local_tokens. Cap profiling token count to avoid shape mismatch
OOM in MoE layers during startup.
Validated: GLM-5.1-FP8 on 8x MI300X (gfx942), TP=8 — PASS (internal review only)
This PR is filed against psakhamo/vllm for internal review. The fix works but
the token cap strategy (hardcoded 64) needs discussion before upstream submission.
See "Open Questions" below.
Purpose
Fixes a cascade of OOM / shape mismatch errors during the vLLM profiling pass
(
determine_num_available_blocks) for models using MLA + DSA attention at TP > 1.Root cause:
DeepSeekV2FusedQkvAProjis initialized withdisable_tp=True(sequence-parallel mode). During the profiling pass,
fused_qkv_a_projperformsan all-gather of
hidden_statesacross all TP ranks, expanding the tokendimension from
local_tokens(e.g. 8,192) totp_size * local_tokens(e.g. 65,536 at TP=8). All surrounding tensors —
positions,k_pe,residual— remain at local token count.This mismatch triggers a cascade of errors:
Rotary embedding shape mismatch
RuntimeError: query, key and positions must have the same number of tokens
(got 65536, 8192, 8192)
MoE GEMM OOM (65536 * 64 = 4,194,304 token-expert pairs)
torch.OutOfMemoryError: HIP out of memory. Tried to allocate 6.00 GiB
MoE hidden_states unpack (3D tensor from attn_out flatten issue)
ValueError: too many values to unpack (expected 2)
Fix: Cap the token count passed to
_dummy_runduring the profiling passto 64. The profiling pass only needs to measure GPU memory and warm up code
paths — it does not need
max_num_tokens. At 64 tokens, the all-gatherproduces 512 tokens (64 × 8 GPUs), well within memory and matching no shape
constraint.
Affected models: GLM-5 (
GlmMoeDsaForCausalLM), DeepSeek-V3, DeepSeek-R1— any model using
DeepSeekV2FusedQkvAProjwithdisable_tp=Trueat TP > 1.Open Questions for Reviewers
that expects
max_num_tokensspecifically?(e.g. check
fused_qkv_a_proj.disable_tp) rather than capping globally?DeepSeekV2FusedQkvAProjitself (skip all-gather whenis_profile=True)?Test Plan
Test Result
Tested on: GLM-5.1-FP8 (
GlmMoeDsaForCausalLM, 744B MoE) on 8× AMD InstinctMI300X (gfx942), TP=8, vLLM v0.17.1 ROCm build, AITER enabled.
Before fix:
RuntimeError: query, key and positions must have the same number of tokens
(got 65536, 8192, 8192)
File ".../vllm/model_executor/layers/mla.py", line 164, in forward
Profiling pass crashes, KV cache never allocated, server exits.
After fix:
finish_reason="tool_calls"confirmedJIRA: GPUAI-6471 (P1 Cohere/OCI engagement, MI300X GLM-5 enablement)
Essential Elements of an Effective PR Description Checklist
BEFORE SUBMITTING, PLEASE READ https://docs.vllm.ai/en/latest/contributing