[Fix] Load memdecode router checkpoints with weights_only - #4820
Open
zcxGGmu wants to merge 1 commit into
Open
Conversation
Signed-off-by: zq <zhouquan1511@163.com>
lvhan028
reviewed
Aug 4, 2026
| ) | ||
|
|
||
|
|
||
| def test_router_checkpoint_torch_load_uses_weights_only(monkeypatch, tmp_path): |
Collaborator
There was a problem hiding this comment.
I don't think we need TC for this. The change is a single parameter addition to torch.load; there's no business logic to regress.
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.
Motivation
Issue #3255 reports unsafe
torch.load(...)usage for.ptcheckpoint loading. The originalload_weight_ckpthelper no longer exists on currentmain, but the memdecode adaptive-router path still loads user-provided.ptrouter checkpoints without explicitly settingweights_only=True.Refs #3255
Modification
torch.load(..., weights_only=True).torch.load(..., weights_only=True).weights_only=Trueexplicitly.BC-breaking (Optional)
No. Supported router checkpoints using tensors and primitive dict metadata continue to load; unsafe pickle globals are rejected earlier by PyTorch's weights-only loader.
Use cases (Optional)
N/A
Checklist
python -m pre_commit run --files lmdeploy/pytorch/memdecode/fusion.py tests/pytorch/memdecode/test_fusion.pypython -m pytest tests/pytorch/memdecode/test_fusion.py -q