Repository navigation
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
stes
requested changes
Oct 23, 2026
Comment on lines
+228
to
+250
| class _DynamicsStateMixin: | ||
| """Include dynamics parameters in solver checkpoints.""" | ||
|
|
||
| def state_dict(self) -> dict: | ||
| """Save the encoder, optimizer, criterion, and dynamics model.""" | ||
| state = super().state_dict() | ||
| state["dynamics_model"] = self.dynamics_model.state_dict() | ||
| return state | ||
|
|
||
| def load_state_dict(self, state_dict: dict, strict: bool = True): | ||
| """Restore dynamics; reject incomplete legacy checkpoints in strict mode.""" | ||
| if "dynamics_model" not in state_dict: | ||
| message = ( | ||
| "Checkpoint is missing dynamics_model parameters. " | ||
| "Legacy DCL checkpoints did not save them. " | ||
| "Use strict=False only to retain the initialized dynamics.") | ||
| if strict: | ||
| raise KeyError(message) | ||
| warnings.warn(message, UserWarning, stacklevel=2) | ||
| else: | ||
| self.dynamics_model.load_state_dict(state_dict["dynamics_model"], | ||
| strict=strict) | ||
| super().load_state_dict(state_dict, strict=strict) |
Member
There was a problem hiding this comment.
This feels like a patch to an upstream bug; the dynamics model should be part of the state dict (?). Did we forget an ``nn.Module'' somewhere?
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.
A DCL estimator saved with the sklearn backend restores its encoder on load but leaves its dynamics model freshly initialized. Solver checkpoints omitted the dynamics parameters, so embeddings could match after a round trip while predicted latent transitions changed.
This patch saves and restores the dynamics state for both minibatch and full-batch DCL solvers through a shared mixin. It adds round-trip and resumed-training regression tests for linear and orthogonal-linear dynamics, plus documentation of historical checkpoint behavior.
Reproducer
The failure was independently reproduced on upstream commit
b7e4b9e.Checkpoint compatibility
Historical DCL checkpoints lack the saved dynamics weights. Strict loading raises an explanatory error for those checkpoints. Explicit low-level
solver.load_state_dict(state, strict=False)loads the available components, warns, and retains the initialized dynamics. The change is confined to the DCL solvers.Validation
I have signed the Contributor License Agreement.