Fix precomputed embeddings not being wired through to the model - #27
Merged
Conversation
precomp_embs_key was never passed to ContrastiveModel when constructing or loading it in api.py, so the model always fell back to computing embeddings from scratch instead of using precomputed ones. Also fixes AnnDataModule passing obsm_keys as a bare string instead of a list (as expected by the underlying dataset class), and skips cell_embs normalization in predict_step when precomp_embs_key is set, matching the non-normalized distance-based logic used in _step. Co-Authored-By: Claude <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #27 +/- ##
==========================================
+ Coverage 66.99% 67.03% +0.03%
==========================================
Files 22 22
Lines 3003 3006 +3
==========================================
+ Hits 2012 2015 +3
Misses 991 991
🚀 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
api.pynever passedprecomp_embs_keyintoContrastiveModelwhen constructing or loading the model, soself.precomp_embs_keystayedNoneand the model always fell back to computing embeddings from scratch instead of using precomputed ones.AnnDataModulepassedobsm_keys=precomp_embs_key(a bare string) instead of wrapping it in a list, which is what the underlying dataset class expects.predict_stepunconditionally normalizedcell_embs, even whenprecomp_embs_keyis set, which is inconsistent with_step's distance-based (unnormalized) logic for precomputed embeddings.Test plan
python -m py_compileon the changed files🤖 Generated with Claude Code