Fix orthogonal parameterization save/load for training continuation#179
Open
aryamanarora wants to merge 1 commit intomainfrom
Open
Fix orthogonal parameterization save/load for training continuation#179aryamanarora wants to merge 1 commit intomainfrom
aryamanarora wants to merge 1 commit intomainfrom
Conversation
Collaborator
Author
|
@codex review |
Collaborator
Author
|
looks like codex is not working. have to call my other agent. @frankaging review |
Member
|
LGTM! |
The orthogonal parameterization in LoreftIntervention now correctly preserves internal state during checkpoint save/load. Previously, only the computed orthogonal weight was saved, which broke orthogonality during training continuation (causing loss spikes). Changes: - state_dict now saves rotate_layer_original and rotate_layer_base - load_state_dict restores full parametrization state when available - Backwards compatible: legacy checkpoints still work for inference - Add optional debug flag for metrics logging (off by default) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
fe2cfc5 to
d09c5bd
Compare
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
debugflag for metrics logging (off by default)Problem
The orthogonal parameterization in
LoreftInterventionuses PyTorch'storch.nn.utils.parametrizations.orthogonal, which stores an internal "original" tensor and computes the orthogonal weight via Cayley/Householder transform.Previously,
state_dict()only saved the computed orthogonal weight, not the internal parametrization state. When loading and continuing training:.base.originalwas freshly initializedThis caused loss spikes when continuing training from checkpoints.
Solution
state_dict()now savesrotate_layer_originalandrotate_layer_baseload_state_dict()restores full parametrization state when availableTest plan
🤖 Generated with Claude Code