Skip to content

Allow non-strict decoder checkpoint loading#62

Merged
mkofler96 merged 2 commits into
mainfrom
copilot/ftstrict-false-load-state-dict
Jun 1, 2026
Merged

Allow non-strict decoder checkpoint loading#62
mkofler96 merged 2 commits into
mainfrom
copilot/ftstrict-false-load-state-dict

Conversation

Copilot AI commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Checkpoint loading previously required an exact state-dict key match, causing failures when extra/unexpected keys were present. This change makes decoder checkpoint loading tolerant to such keys in both direct and fallback load paths.

  • Decoder load behavior

    • Updated decoder.load_state_dict(...) to pass strict=False in:
      • load_model_parameters()
      • load_trained_model() primary load
      • load_trained_model() RuntimeError fallback load (after module. prefix normalization)
  • Scope

    • Minimal, surgical diff in DeepSDFStruct/deep_sdf/workspace.py
    • No refactors or unrelated logic changes
decoder.load_state_dict(data["model_state_dict"], strict=False)
...
decoder.load_state_dict(state_dict, strict=False)
Original prompt

Repo: mkofler96/DeepSDFStruct.

Goal: allow unexpected keys when loading the decoder model by setting strict=False on BOTH occurrences of decoder.load_state_dict.

Requirements:

  • Create a new feature branch (name it something like ft/strict-false-load-state-dict or similar).
  • Update the code so that both decoder.load_state_dict(...) calls include strict=False.
    • One is in DeepSDFStruct/deep_sdf/workspace.py inside load_trained_model().
    • Ensure BOTH the initial decoder.load_state_dict(...) and the fallback decoder.load_state_dict(...) in the RuntimeError handler pass strict=False.
    • Also update load_model_parameters() where decoder.load_state_dict(...) is called, if applicable, but the primary request is specifically the two occurrences on the decoder.
  • Open a pull request from the feature branch to the repository’s default branch.
  • Keep the diff minimal (only add strict=False flags; no refactors).

Acceptance criteria:

  • The repo builds/runs as before.
  • Loading a checkpoint with extra/unexpected keys does not raise due to strict loading.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: can you add the flag strict=false to

decoder.load_state_dict

such that unexpected keys can be handled? jus add this flag on both occurances of the load state dict

Assistant: I’ve queued the change to add strict=False to both decoder.load_state_dict(...) occurrences, and I’m just waiting for you to confirm/approve the update so I can apply it to the repository.

User: not on the default branch create a ft branch and a pull reqeuest

Assistant: I’m waiting for you to approve the pending pull-request creation request; once you confirm, I’ll create a feature branch, apply the strict=False changes to both decoder.load_state_dict(...) calls, and open the PR.

This pull request was created from Copilot chat.

@deepsource-io

deepsource-io Bot commented Jun 1, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 03dc6e1...955e839 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Python Jun 1, 2026 10:56a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Co-authored-by: mkofler96 <18218171+mkofler96@users.noreply.github.com>
Copilot AI changed the title [WIP] Update decoder load_state_dict calls to allow unexpected keys Allow non-strict decoder checkpoint loading Jun 1, 2026
@mkofler96 mkofler96 marked this pull request as ready for review June 1, 2026 10:56
Copilot AI review requested due to automatic review settings June 1, 2026 10:56
Copilot AI requested a review from mkofler96 June 1, 2026 10:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes decoder checkpoint loading tolerant to extra/unexpected keys by passing strict=False to decoder.load_state_dict(...), aiming to prevent load failures when checkpoints contain additional entries.

Changes:

  • Set strict=False when loading decoder parameters in load_model_parameters().
  • Set strict=False on the primary decoder load path in load_trained_model().
  • Set strict=False on the fallback decoder load path in load_trained_model().

data = torch.load(filename, map_location=device, weights_only=True)

decoder.load_state_dict(data["model_state_dict"])
decoder.load_state_dict(data["model_state_dict"], strict=False)
Comment on lines 319 to 323
try:
decoder.load_state_dict(data["model_state_dict"])
decoder.load_state_dict(data["model_state_dict"], strict=False)
except RuntimeError:
state_dict = {}
for k, v in data["model_state_dict"].items():
@mkofler96 mkofler96 merged commit 15981f8 into main Jun 1, 2026
14 of 15 checks passed
@mkofler96 mkofler96 deleted the copilot/ftstrict-false-load-state-dict branch June 1, 2026 11:16
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.

3 participants