Repository navigation
Fix update_ckpt() failing on legacy checkpoints with torch >= 2.6 - #194
Merged
avantikalal merged 2 commits intoOct 2, 2026
Merged
Conversation
PyTorch 2.6 changed the default of torch.load's weights_only argument from False to True. Legacy gReLU checkpoints store numpy metric values in the "performance" entry (written by LightningModel.on_save_checkpoint), which the weights_only=True unpickler refuses, so update_ckpt() raised UnpicklingError on exactly the files it exists to migrate. Load the checkpoint with an explicit weights_only=False, matching the default already used for checkpoint loading in grelu.resources.wandb. Fixes Genentech#193
musharna
marked this pull request as ready for review
September 20, 2026 03:55
avantikalal
approved these changes
Sep 30, 2026
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.
Fixes #193.
update_ckpt()is the documented migration path for checkpoints saved with gReLU v0.4 or lower, but on PyTorch 2.6+ it raisesUnpicklingErroron exactly those files: PyTorch 2.6 flipped the default oftorch.load'sweights_onlyargument toTrue, and legacy gReLU checkpoints carry numpy metric values inperformance(written byLightningModel.on_save_checkpoint), which the safe unpickler refuses.The fix loads the checkpoint with an explicit
weights_only=False, matching the defaultgrelu.resources.wandb.load_model_from_wandbalready uses for checkpoint loading.update_ckptreads files the user is explicitly asking to migrate, the same trust model as before PyTorch 2.6.Added a regression test that builds a checkpoint the way gReLU writes them, injects numpy
performancevalues and the legacydepthhyperparameter, and runsupdate_ckptend to end. Verified with torch 2.13.0 / lightning 2.6.5 / numpy 2.5.2:main, the test fails withUnpicklingError: Weights only load failed ... GLOBAL numpy._core.multiarray.scalar was not an allowed global;tests/test_io.pystill passes.The other
torch.loadcalls in the codebase (grelu/model/models.py) load plain tensor state dicts, which theweights_only=Truedefault handles fine, so they are left unchanged.