[Bugfix] Match WeightsMapper stacked remaps on path components#48564
[Bugfix] Match WeightsMapper stacked remaps on path components#48564vdabholkar-together wants to merge 2 commits into
Conversation
orig_to_new_stacked did a raw substring replace and kept scanning, so q_proj -> qkv_proj was then rewritten by the v_proj entry into qkqkv_proj, and the q/k shard ids were overwritten with v. This broke weight loading for MiniCPM-V-4.6 on v0.25.0. Match stacked keys as dotted path components and stop after the first hit, preferring longer (qualified) keys over short aliases. Fixes vllm-project#48423 Fixes vllm-project#48449 Signed-off-by: vdabholkar-together <245015005+vdabholkar-together@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: <>
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in PRs do not trigger a full CI run by default. Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add If you have any questions, please reach out to us on Slack at https://slack.vllm.ai. Agent GuidelinesIMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban. 🚀 |
Purpose
Fixes #48423
Fixes #48449
WeightsMapper._map_name_with_shardmatchesorig_to_new_stackedkeys as raw substrings and keeps scanning after a hit. With mappings like MiniCPM-V-4.6's ViT attention (q_proj/k_proj/v_proj->qkv_proj), a name such as...self_attn.q_proj.weightis first rewritten to...qkv_proj.weight, and then thev_projentry matches inside the freshly writtenqkv_proj, producing...qkqkv_proj.weightand overwriting theq/kshard id withv. This breaks weight loading for MiniCPM-V-4.6 on v0.25.0 (KeyError/garbage output depending on path).This PR changes stacked remapping to:
v_projno longer matches insideqkv_proj),No behavior change for existing dotted-style mappings (
.q_projetc.); already-fused names likeqkv_proj.weightnow pass through untouched.Not duplicating existing work: no open PR addresses #48423/#48449 (checked open PRs referencing the issues and
WeightsMapper).Test Plan
Added regression tests in
tests/model_executor/test_weight_utils.py::TestWeightsMapperStackedcovering:q/k/v_proj->qkv_projwith correct shard ids, andqkv_proj/out_projleft untouched,gate_proj/up_proj->gate_up_proj,Test Result
All tests in
tests/model_executor/test_weight_utils.pypass locally (CPU), including the newTestWeightsMapperStackedcases.pre-commit(ruff, mypy, etc.) passes on the changed files.