Fix embedding builder sub-target instantiation and flow state_dict cloning#108
Merged
Conversation
builder.py: add _instantiate_sub_targets() so constructor kwargs that are
_target_ dicts (e.g. whitener: {_target_: DiagonalWhitener, dim: 17280})
are recursively instantiated into real modules before being passed to
cls(**kwargs). Previously they arrived as raw dicts, causing the receiving
module to call dict.update(tensor) instead of module.update(tensor).
flow.py: _update_best_weights now calls load_state_dict(module.state_dict())
directly instead of {k: v.clone() ...}, matching GaussianFullCov. The
manual clone comprehension broke for modules that use get_extra_state() to
store non-tensor objects (e.g. DynamicSVD's eigenbasis dict).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #108 +/- ##
==========================================
- Coverage 10.42% 10.38% -0.04%
==========================================
Files 30 30
Lines 3896 3910 +14
==========================================
Hits 406 406
- Misses 3490 3504 +14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
builder.py: add_instantiate_sub_targets()— recursively instantiates any constructor kwarg dict that has_target_but no_input_(e.g.whitener: {_target_: DiagonalWhitener, dim: 17280}) into a real module before passing tocls(**kwargs). Previously these arrived as raw dicts, causing the receiving module to calldict.update(tensor)instead ofmodule.update(tensor).flow.py:_update_best_weightsnow callsload_state_dict(module.state_dict())directly, matchingGaussianFullCov. The prior{k: v.clone() ...}comprehension broke for modules usingget_extra_state()to store non-tensor objects (e.g.DynamicSVD's eigenbasis dict).Test plan
DynamicSVDwithwhitener: {_target_: DiagonalWhitener, ...}in YAML config instantiates correctlyDynamicSVD🤖 Generated with Claude Code