Skip to content

Load checkpoints with weights_only=True and drop unused Normalizer usage - #165

Open
jcwang587 wants to merge 1 commit into
perf/scatter-poolingfrom
chore/safe-checkpoint-loading
Open

Load checkpoints with weights_only=True and drop unused Normalizer usage#165
jcwang587 wants to merge 1 commit into
perf/scatter-poolingfrom
chore/safe-checkpoint-loading

Conversation

@jcwang587

Copy link
Copy Markdown
Owner

Summary

  • All torch.load calls now use weights_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.
  • The Normalizer was computed, saved into every checkpoint, and reloaded - but never applied to targets in any training or inference path. This removes that dead usage from cgcnn_tr, cgcnn_ft, and cgcnn_pred (the Normalizer class stays in utils as public API). Side effect: cgcnn_tr no longer eagerly materializes the entire dataset at startup, which existed solely to sample normalizer statistics.
  • Fix the usage docs, which incorrectly stated weights_only=False is required for CGCNN checkpoints.

Compatibility

  • The bundled legacy pretrained models load fine under the restricted unpickler (verified).
  • Old checkpoints containing the extra normalizer key still load; unused keys are ignored.

Part 3/4, stacked on #164 (perf/scatter-pooling).

🤖 Generated with Claude Code

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>
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 827331d6-2e7c-447b-9d50-07988c9dcf76

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant