Load checkpoints with weights_only=True and drop unused Normalizer usage - #165
Open
jcwang587 wants to merge 1 commit into
Open
Load checkpoints with weights_only=True and drop unused Normalizer usage#165jcwang587 wants to merge 1 commit into
jcwang587 wants to merge 1 commit into
Conversation
cgcnn2 checkpoints contain only tensors and plain Python values, so all torch.load calls now use weights_only=True (the secure default since PyTorch 2.6), which prevents checkpoint files from executing arbitrary code on load. The bundled legacy pretrained models load fine under the restricted unpickler (verified), and old checkpoints with the extra "normalizer" key still load since unused keys are ignored. The Normalizer was computed, saved into every checkpoint, and reloaded, but never applied to targets in any training or inference path - remove that dead usage from cgcnn_tr, cgcnn_ft, and cgcnn_pred (the Normalizer class itself stays in utils as public API). As a side effect, cgcnn_tr no longer eagerly materializes the entire dataset at startup, which existed solely to sample normalizer statistics. Also update the usage docs, which incorrectly stated that weights_only=False is required for CGCNN checkpoints. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Summary
torch.loadcalls now useweights_only=True(the secure default since PyTorch 2.6): cgcnn2 checkpoints contain only tensors and plain Python values, so nothing needed the unsafe mode, and this prevents checkpoint files from executing arbitrary code on load.Normalizerwas computed, saved into every checkpoint, and reloaded - but never applied to targets in any training or inference path. This removes that dead usage fromcgcnn_tr,cgcnn_ft, andcgcnn_pred(theNormalizerclass stays inutilsas public API). Side effect:cgcnn_trno longer eagerly materializes the entire dataset at startup, which existed solely to sample normalizer statistics.weights_only=Falseis required for CGCNN checkpoints.Compatibility
normalizerkey still load; unused keys are ignored.Part 3/4, stacked on #164 (
perf/scatter-pooling).🤖 Generated with Claude Code