Skip to content

Fix MiDashengLM TP>1 crash in audio encoder attention#44408

Merged
jikunshang merged 3 commits into
vllm-project:mainfrom
mganczarenko:fix/xpu-midashenglm-tp-reshape
Jun 9, 2026
Merged

Fix MiDashengLM TP>1 crash in audio encoder attention#44408
jikunshang merged 3 commits into
vllm-project:mainfrom
mganczarenko:fix/xpu-midashenglm-tp-reshape

Conversation

@mganczarenko

@mganczarenko mganczarenko commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Purpose

Fix TP>1 crash in mispeech/midashenglm-7b audio encoder.

DashengAttention.forward() uses full embed_dim (C) in tensor reshapes instead of TP-aware self.head_dim and self.q_size, causing shape mismatch runtime errors when tensor_parallel_size > 1.

Test Plan

# Set up environment
uv venv --python 3.12
source .venv/bin/activate
uv pip install -r requirements/lint.txt
VLLM_USE_PRECOMPILED=1 uv pip install -e . --torch-backend=auto

# Test TP=2 (previously crashed, now works)
vllm serve mispeech/midashenglm-7b \
  --dtype bfloat16 \
  --tensor-parallel-size 2 \
  --max-model-len 8192 \
  --gpu-memory-utilization 0.85 \
  --trust-remote-code \
  --limit-mm-per-prompt '{"image": 1}'

# Test inference
 curl http://localhost:8000/v1/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mispeech/midashenglm-7b",
    "prompt": "Hello",
    "max_tokens": 10
  }'

Test Result

Before fix (TP=2):
RuntimeError: shape '[1, 1568, 3, 8, 64]' is invalid for input of size 602112
Server crashes during first inference request.

After fix (TP=2):
✓ Server starts successfully
✓ Health check passes
✓ Inference completes (generates audio tokens 151872 as expected for audio model)
✓ Clean shutdown

TP=1 (unchanged): Works before and after — fix is no-op when not sharded.

serve_succeed.log
serve_failed.log


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.
Signed-off-by: Michał Ganczarenko <michal.ganczarenko@intel.com>
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

PRs do not trigger a full CI run by default. Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

Agent Guidelines

IMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban.

🚀

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a tensor-parallelism (TP>1) shape mismatch crash in the MiDashengLM audio encoder attention by making the attention tensor reshapes use TP-aware dimensions instead of the full (unsharded) embedding dimension.

Changes:

  • Update DashengAttention.forward() to reshape QKV using self.head_dim (per-head dim) rather than C // self.num_heads.
  • Update the post-attention reshape to use self.q_size (per-partition Q hidden size) rather than the full C.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jikunshang jikunshang added the verified Run pre-commit for new contributors without triggering other tests label Jun 9, 2026
@jikunshang jikunshang added the ready ONLY add when PR is ready to merge/full CI is needed label Jun 9, 2026
@mergify

mergify Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Hi @mganczarenko, 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.

@jikunshang jikunshang enabled auto-merge (squash) June 9, 2026 15:03
@jikunshang jikunshang merged commit 766ce2b into vllm-project:main Jun 9, 2026
71 of 73 checks passed
ekagra-ranjan pushed a commit to ekagra-ranjan/vllm that referenced this pull request Jun 9, 2026
…4408)

Signed-off-by: Michał Ganczarenko <michal.ganczarenko@intel.com>
Co-authored-by: Kunshang Ji <kunshang.ji@intel.com>
Signed-off-by: Ekagra Ranjan <3116519+ekagra-ranjan@users.noreply.github.com>
waqahmed-amd-fi pushed a commit to waqahmed-amd-fi/vllm that referenced this pull request Jun 10, 2026
…4408)

Signed-off-by: Michał Ganczarenko <michal.ganczarenko@intel.com>
Co-authored-by: Kunshang Ji <kunshang.ji@intel.com>
Signed-off-by: Waqar Ahmed <waqar.ahmed@amd.com>
Saddss pushed a commit to Saddss/vllm that referenced this pull request Jun 14, 2026
…4408)

Signed-off-by: Michał Ganczarenko <michal.ganczarenko@intel.com>
Co-authored-by: Kunshang Ji <kunshang.ji@intel.com>
vivek8123 pushed a commit to odh-on-pz/vllm-upstream that referenced this pull request Jun 18, 2026
…4408)

Signed-off-by: Michał Ganczarenko <michal.ganczarenko@intel.com>
Co-authored-by: Kunshang Ji <kunshang.ji@intel.com>
divineearthly pushed a commit to divineearthly/vllm that referenced this pull request Jun 19, 2026
…4408)

Signed-off-by: Michał Ganczarenko <michal.ganczarenko@intel.com>
Co-authored-by: Kunshang Ji <kunshang.ji@intel.com>
Signed-off-by: divineearthly <divineearthly@gmail.com>
tunglinwood pushed a commit to tunglinwood/vllm that referenced this pull request Jun 22, 2026
…4408)

Signed-off-by: Michał Ganczarenko <michal.ganczarenko@intel.com>
Co-authored-by: Kunshang Ji <kunshang.ji@intel.com>
nkzhenhua pushed a commit to nkzhenhua/vllm that referenced this pull request Jun 24, 2026
…4408)

Signed-off-by: Michał Ganczarenko <michal.ganczarenko@intel.com>
Co-authored-by: Kunshang Ji <kunshang.ji@intel.com>
ohsono pushed a commit to ohsono/vllm that referenced this pull request Jul 3, 2026
…4408)

Signed-off-by: Michał Ganczarenko <michal.ganczarenko@intel.com>
Co-authored-by: Kunshang Ji <kunshang.ji@intel.com>
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 verified Run pre-commit for new contributors without triggering other tests

3 participants