Fix DeepSeek V4 loading with RunAI Model Streamer. - #30240
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces streaming dequantization for FP8 weights in the DeepSeek-V4 model via the new _dequant_fp8_wo_a_streaming function, replacing the previous non-streaming implementation. It also adds a helper to clone RunAI streamed tensors to prevent issues during streaming. Comprehensive unit tests have been added to verify weight and scale pairing, correctness against the legacy implementation, cloning behavior, and error handling. There are no review comments, and the changes look solid.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
JustinTong0323
left a comment
There was a problem hiding this comment.
Rebase onto the latest main and cover the DeepSeek V4 DSpark loader before merging.
| @@ -2175,13 +2178,7 @@ def load_weights(self, weights: Iterable[Tuple[str, torch.Tensor]], is_nextn=Fal | |||
| raise ValueError("num_nextn_predict_layers is not in the config") | |||
There was a problem hiding this comment.
Rebase onto the latest main and use this streaming path in DeepseekV4ForCausalLMDSpark.load_weights too. PR #30261 added deepseek_v4_dspark.py with weights = list(weights), and DSPARK draft models inherit --load-format runai_streamer by default, so that path can still consume RunAI's reused buffers and load corrupted weights.
There was a problem hiding this comment.
Thanks, @JustinTong0323, I have updated it.
2442a04 to
f67b35c
Compare
|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
Motivation
Fix DeepSeek V4 loading with RunAI Model Streamer.
DeepSeek V4 performs a special FP8 dequantization pass for
.wo_a.weightusing the corresponding.wo_a.scale. The previous implementation first materialized the entireweightsiterable withlist(weights)and then dequantized from a dictionary. That is safe for normal local loading, but it breaks the streaming-loading contract used byrunai_streamer.In cluster validation with DeepSeek-V4-Flash on NVIDIA H20, the model could stream all tensors successfully, but the first decode failed with CUTLASS mixed dtype grouped GEMM / TMA descriptor initialization errors. Local loading of the same model did not reproduce the issue.
Fixes #30239
Modifications
wo_adequant path instead of materializing the full weight iterator..wo_a.scaletensors exist, pass.wo_a.weightthrough unchanged; if any.wo_a.scaleexists, unmatched.wo_a.weightstill raises.Accuracy Tests
No model-output accuracy change is expected. The patch only changes how DeepSeek V4 FP8
wo_atensors are paired and dequantized during weight loading; the resulting tensor dtype remainsbfloat16, matching the existing non-streaming path.The streaming helper can yield a dequantized
.wo_a.weightlater than the legacy dict-based helper when.wo_a.weightappears before its.wo_a.scale. This does not change the model state because DeepSeek V4 loads tensors by parameter name. The unit tests compare legacy and streaming results by name and assert the tensor values match even when the yield order differs.Speed Tests and Profiling
No throughput benchmark was run. This change avoids materializing the RunAI streamer weight iterator for DeepSeek V4
wo_adequantization, so it should preserve the intended streaming-loading behavior and not affect steady-state inference speed.Checklist
CI States
Latest PR Test (Base): ✅ Run #30328605916
Latest PR Test (Extra): ❌ Run #30328605785