Skip to content

Fix embedding builder sub-target instantiation and flow state_dict cloning#108

Merged
cweniger merged 1 commit into
mainfrom
fix/embedding-builder-and-flow
Jun 22, 2026
Merged

Fix embedding builder sub-target instantiation and flow state_dict cloning#108
cweniger merged 1 commit into
mainfrom
fix/embedding-builder-and-flow

Conversation

@cweniger

Copy link
Copy Markdown
Owner

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 to cls(**kwargs). Previously these 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, matching GaussianFullCov. The prior {k: v.clone() ...} comprehension broke for modules using get_extra_state() to store non-tensor objects (e.g. DynamicSVD's eigenbasis dict).

Test plan

  • Confirm DynamicSVD with whitener: {_target_: DiagonalWhitener, ...} in YAML config instantiates correctly
  • Confirm best-weights snapshot works when embedding contains a DynamicSVD
  • Existing embedding builder tests pass

🤖 Generated with Claude Code

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>
@cweniger cweniger merged commit a175353 into main Jun 22, 2026
4 checks passed
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 10.38%. Comparing base (d08c81c) to head (e8d8ba9).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
falcon/embeddings/builder.py 0.00% 15 Missing ⚠️
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     
Flag Coverage Δ
unit 10.38% <0.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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