Repository navigation
[Model] DeepSeek-V4/V4.1 VL: stream language-model weights instead of sorting the checkpoint - #58857
Open
gitbisector wants to merge 1 commit into
Open
gitbisector wants to merge 1 commit into
gitbisector wants to merge 1 commit into
Conversation
gitbisector
requested review from
AndreasKaratzas,
DarkLight1337,
Harry-Chen,
khluu,
ywang96 and
zyongye
as code owners
September 26, 2026 21:04
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
… sorting the checkpoint The DeepSeek-V4 VL wrapper and the NVIDIA DeepSeek-V4.1 VL wrapper sort the whole mapped weight stream so the "language_model." group reaches the child loader contiguously; the NVIDIA children finalize fused expert weights inside load_weights. sorted() materializes the iterator, so every tensor the loader yields is alive before the first copy: the whole checkpoint for loaders that yield materialized tensors (--safetensors-load-strategy eager, --load-format fastsafetensors), and a shard-hopping access order for mmap views. Contiguity only needs a non-interleaved group. Add stream_language_model_first, which yields language_model.* as it arrives and defers the rest (vision tower, aligner), cloned in case the loader reuses its buffers, and use it in both wrappers. vllm-project#58782 makes the same change to the AMD V4.1 wrapper. Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: git bisector <gitbisector@gmail.com>
gitbisector
force-pushed
the
dsv41-vl-stream-weights
branch
from
September 29, 2026 14:17
72933ae to
88754c0
Compare
6 tasks done
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
This branch has not been deployed
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.
Purpose
The DeepSeek-V4 VL wrapper and the NVIDIA DeepSeek-V4.1 VL wrapper sort the whole mapped weight stream so that the
language_model.group reaches the child loader contiguously. The NVIDIA children finalize fused expert weights insideload_weights, so the group must not be interleaved.sorted()materializes the iterator, so every tensor the loader yields is alive before the first copy:--safetensors-load-strategy eager, or--load-format fastsafetensors, which yields a separate tensor per weight): nearly the whole checkpoint is held at once (DeepSeek-V4.1-Flash is 475 GiB). [Bugfix][ROCm] DeepSeek-V4/V4.1: Hybrid FP8/MXFP4 Quant Routing Guard, Fused Shared Experts, Engram Scale Translation, and VLM Generator Streaming #58782 reports host OOM from the same sort on the AMD V4.1 wrapper.Contiguity needs only a non-interleaved group, not a total order. This PR adds
stream_language_model_first, which yieldslanguage_model.*as it arrives and defers the rest (vision tower, aligner), cloned in case the loader reuses its buffers. Both wrappers use it.Not a duplicate: #58782 applies the same idea to the AMD V4.1 wrapper as one part of a ROCm fix, and could reuse this helper. This PR covers the V4 wrapper and the NVIDIA V4.1 wrapper. #57733 keeps the in-load finalize, so the contiguity requirement stays.
Test Plan
The test is parametrized over both wrappers and uses the real
AutoWeightsLoaderwith a language model that finalizes inload_weights. It asserts that a weight is loaded before the stream is drained, that the child is called once, and that it finalizes after all of its weights. It is registered in the Basic Models (Other) CUDA step.Test Result
Both cases pass on current main (GB10, torch 2.13.0+cu130). Without the change, both cases fail at the mid-stream assertion: the stream is drained before anything loads.
DeepSeek-V4.1-Flash at TP4 on 4x DGX Spark with
--load-format auto, page cache dropped before each boot. These runs used a 0.28.1-based build with the same change minus the clone. Two nodes hadread_ahead_kb=1024and two had 128, the same in both arms, which is why reads vary by rank:With
--load-format fastsafetensors, #55985 and some fastsafetensors fixes that are not upstream yet, streaming is what lets this model load on a 121.7 GiB node at all: ~88 s, against 202–212 s forautoabove.This changes only the order in which weights reach the loader. The child's per-tensor loaders don't depend on order, and it still finalizes once, after all of its weights.
AI assistance (Claude Code) was used for the change, the tests and the measurements. I reviewed every line and ran the tests and boots.