vllm - 💡(How to fix) Fix [Feature]: Support DeepSeek-V4-Flash-Base model [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vllm-project/vllm#41104Fetched 2026-04-29 06:12:23
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Participants
Timeline (top)
closed ×1commented ×1labeled ×1

Error Message

expert_data.copy_(loaded_weight)

RuntimeError: The size of tensor a (2048) must match the size of tensor b (16)

Code Example

expert_data.copy_(loaded_weight)
# RuntimeError: The size of tensor a (2048) must match the size of tensor b (16)
RAW_BUFFERClick to expand / collapse

🚀 The feature, motivation and pitch

Currently vLLM can only run with the DSV4 instruct models. Base models are not supported. Supporting base model is important for RL which normally runs with the Base.

When trying to run with the Base model, the RuntimeError will occur in fused_moe/layer.py:

expert_data.copy_(loaded_weight)
# RuntimeError: The size of tensor a (2048) must match the size of tensor b (16)

Why this happens:

  1. The vLLM deepseek_v4.py loader are built for the Instruct format, where the MoE experts are quantized to FP4 (highly packed/compressed).
  2. The Base model uses pure FP8 weights. The tensor shapes, packing, and quantization scales are completely different.
  3. When the weight loader tries to copy FP8-shaped data into an FP4-expecting buffer (or applies an FP4 dequantization view to an FP8 tensor), the dimensions don't align, producing the 2048 vs. 16 mismatch.

Alternatives

No response

Additional context

No response

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

extent analysis

TL;DR

Modify the deepseek_v4.py loader to support the Base model's FP8 weights by adjusting the tensor shapes, packing, and quantization scales.

Guidance

  • Identify the specific lines of code in fused_moe/layer.py where the RuntimeError occurs and adjust the tensor copy operation to accommodate the FP8 weights.
  • Update the weight loader in deepseek_v4.py to handle the differences in tensor shapes and quantization scales between the Instruct and Base models.
  • Consider adding a model-type check to use the correct weight loading logic based on the model being used.
  • Verify that the modified loader correctly loads the Base model weights and resolves the RuntimeError.

Example

# Example of modified weight loading logic
if model_type == "Base":
    # Load FP8 weights with correct tensor shape and quantization scale
    expert_data.copy_(loaded_weight_fp8)
else:
    # Load FP4 weights with correct tensor shape and quantization scale
    expert_data.copy_(loaded_weight_fp4)

Notes

The solution requires modifying the existing code to support the Base model's FP8 weights. The exact changes will depend on the specific implementation details of the deepseek_v4.py loader and the fused_moe/layer.py module.

Recommendation

Apply workaround: Modify the deepseek_v4.py loader to support the Base model's FP8 weights, as this will allow the Base model to be used with the vLLM.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING