Skip to content

[Bugfix][Model][CPU] Fix Mamba2 quantized in_proj weight and scale loading for TP >1 - #58083

Merged
bigPYJ1151 merged 2 commits into
vllm-project:mainfrom
Akashcodes732:fix/mamba-quant-tp-sharding
Sep 30, 2026
Merged

bigPYJ1151 merged 2 commits into
vllm-project:mainfrom
Akashcodes732:fix/mamba-quant-tp-sharding

Conversation

@Akashcodes732

@Akashcodes732 Akashcodes732 commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Fix RuntimeError: start (...) + length (...) exceeds dimension size (...) when serving quantized Mamba-2 models (e.g. granite-4.0-h-tiny-quantized.w8a8) with TP > 1.

  • Cause: In MambaMixer2, self.in_proj groups B and C are replicated when ngroups < tp_size. While weight used mamba_loader, quantized parameters (weight_scale, input_scale) used default linear slicing, causing out-of-bounds indexing on Rank 1+.
  • Fix: Apply mamba_loader to all parameters of self.in_proj and align sliced scale dimensions with target_slice.

Test Plan

# Serve model with TP=2
vllm serve fedora-copr/granite-4.0-h-tiny-quantized.w8a8 --tensor-parallel-size 2

# Test completion
curl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" \
  -d '{"model": "fedora-copr/granite-4.0-h-tiny-quantized.w8a8", "messages": [{"role": "user", "content": "What is 2+2?"}]}'


## Test Result
- **Before**: Crashed on Rank 1 at startup: `RuntimeError: start (3352) + length (3352) exceeds dimension size (6448)`
- **After**: Server starts cleanly on TP=2 and successfully responds with `"2 + 2 = 4"`.

… for TP > 1

In Mamba2 (MambaMixer2), in_proj concatenates gate, up, B, C, and dt
projections into an asymmetric dimension. When tensor_parallel_size > 1,
groups B and C are replicated across ranks, handled by the custom
mamba_v2_sharded_weight_loader.

However, mamba_loader was only assigned to in_proj.weight, leaving
in_proj.weight_scale (created by compressed-tensors and other quantizers)
with the default ColumnParallelLinear loader. This caused Rank 1 to
slice past the checkpoint dimension size, crashing with:
RuntimeError: start (3352) + length (3352) exceeds dimension size (6448).

This fix:
1. Applies mamba_loader to weight, weight_scale, and input_scale.
2. Uses view_as in mamba_v2_sharded_weight_loader to ensure 1D and 2D
   scale slices copy seamlessly into parameter data.

Co-authored-by: Antigravity <antigravity@google.com>
Signed-off-by: Akash kaothalkar <akash.kaothalkar@ibm.com>

@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.

@Akashcodes732 Akashcodes732 changed the title [Bugfix][Model] Fix Mamba2 quantized in_proj weight and scale loading… [Bugfix][Model] Fix Mamba2 quantized in_proj weight and scale loading for TP >1 Sep 22, 2026
@mergify mergify Bot added quantization bug Something isn't working labels Sep 22, 2026
@Akashcodes732 Akashcodes732 changed the title [Bugfix][Model] Fix Mamba2 quantized in_proj weight and scale loading for TP >1 [Bugfix][Model][CPU] Fix Mamba2 quantized in_proj weight and scale loading for TP >1 Sep 22, 2026
@Akashcodes732

Copy link
Copy Markdown
Contributor Author

Hi @bigPYJ1151
Can you please take a look at this PR ?

@Akashcodes732

Copy link
Copy Markdown
Contributor Author

Hi @bigPYJ1151
Can you please take a look at the changes made in this PR ?

@Akashcodes732

Copy link
Copy Markdown
Contributor Author

Hi @bigPYJ1151

Can you please take a look at the changes made in this PR ?

@bigPYJ1151

Copy link
Copy Markdown
Member

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #92082 for commit 9b0971193338.

@bigPYJ1151
bigPYJ1151 merged commit d71f662 into vllm-project:main Sep 30, 2026
166 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working quantization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants