[Bugfix][multi_modal] Fix pos_ids being unitialized for minicpmv2.6 in hf runner - #51432
Merged
DarkLight1337 merged 1 commit intoAug 8, 2026
Conversation
Signed-off-by: Dino Music <Dino.Music@amd.com>
music-dino
requested review from
AndreasKaratzas,
DarkLight1337 and
ywang96
as code owners
August 7, 2026 18:43
Member
|
/ci run |
|
✅ Triggered Buildkite CI #82912 for commit |
Member
|
cc @tc-mb |
Member
|
Let's fix CI first and revert once the issue has been fixed upstream |
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
#48413 introduced two separate failures in the Multi-Modal Models (Extended Generation 3) TG. - CI
The two types of failures are:
The second one has two parts; this PR addresses the second part of the second failure:
Either [Bugfix][CI/Build] Fix InternViT load crash on transformers v5 (missing all_tied_weights_keys) #49679 should be merged before this, or this PR can absorb its change (or something similar).
The flakiness in the 6 minicpmv_26 presents itself in two different ways:
Temporary instrumentation was added to HfRunner that scanned every tensor in the loaded model for non-finite values and registered per-module forward hooks to locate where NaN first appeared. The post-load scan flagged resampler.pos_embed as non-finite before any forward pass had run, which ruled out the forward pass and pointed directly at model loading.
That was confirmed with a standalone script that loads the same checkpoint under both runners and dumps the buffer. Under vLLM it holds the expected sin/cos table; under HuggingFace it is all zeros; and re-running the model's own _set_2d_pos_cache on the HuggingFace model reproduces the vLLM values exactly.
pos_embed_check.py
The script was run with
VLLM_ALLOW_INSECURE_SERIALIZATION=1 python pos_embed_check.py, the output being:Both are caused by the same hf defect - Resampler.pos_embed in MiniCPM-V's remote code.
MiniCPM-V's Resampler ends init by calling _set_2d_pos_cache, which computes a 2D sin/cos position table and registers it with persistent=False.
Transformers destroys them during load finalization. _move_missing_keys_from_meta_to_device ends with an unconditional
loop over named_non_persistent_buffers that replaces every entry with torch.empty_like. The _initialize_missing_keys
pass that follows does not restore it either, since _init_weights only rebuilds rotary embedding buffers.
Fix
minicpmv_26_patch_hf_runner now calls a small helper that walks the loaded model, finds modules exposing _set_2d_pos_cache, and re-runs it on the buffer's current device — restoring exactly what init computed. This is a test-only change
Test Plan
Test Result
Previously failures like:
Now all tests pass. The 6 tests were run in a loop for 20 iterations (120 test executions in total) to verify that the flakiness no longer occurs.