Skip to content

Fix: Extract some methods from FCLayers for easier inheritance#3880

Merged
ori-kron-wis merged 3 commits into
scverse:mainfrom
moinfar:extract_methods_from_fclayers_for_easier_inheritance
Jun 30, 2026
Merged

Fix: Extract some methods from FCLayers for easier inheritance#3880
ori-kron-wis merged 3 commits into
scverse:mainfrom
moinfar:extract_methods_from_fclayers_for_easier_inheritance

Conversation

@moinfar

@moinfar moinfar commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Add _build_layer, _is_linear_layer, _apply_batch_norm, and _apply_layer as overridable hooks so subclasses (e.g. SplitFCLayers in DRVI) can customise layer construction and dispatch without duplicating the forward loop and scArches logic. Store constructor args as instance attributes so _build_layer can reference them.

Also, fix set_online_update_hooks to use [..., dims_to_update] instead of [:, dims_to_update] so the gradient mask works on 3-D weight tensors (as in DRVI decoder).

Add _build_layer, _is_linear_layer, _apply_batch_norm, and _apply_layer
as overridable hooks so subclasses (e.g. SplitFCLayers in DRVI) can
customise layer construction and dispatch without duplicating the forward
loop. Store constructor args as instance attributes so _build_layer can
reference them.

Also fix set_online_update_hooks to use [...] instead of [:, ...] so the
gradient mask works on 3-D weight tensors (injected-covariate case with
sampling).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@moinfar moinfar mentioned this pull request Jun 24, 2026
@ori-kron-wis ori-kron-wis added the on-merge: backport to 1.4.x on-merge: backport to 1.4.x label Jun 24, 2026
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.54%. Comparing base (ed5485f) to head (99cd0ac).

Files with missing lines Patch % Lines
src/scvi/nn/_base_components.py 96.29% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3880   +/-   ##
=======================================
  Coverage   88.54%   88.54%           
=======================================
  Files         231      231           
  Lines       23050    23064   +14     
=======================================
+ Hits        20409    20423   +14     
  Misses       2641     2641           
Flag Coverage Δ
cuda 74.28% <96.29%> (+0.04%) ⬆️
integration 74.25% <96.29%> (+0.01%) ⬆️

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

Files with missing lines Coverage Δ
src/scvi/nn/_base_components.py 94.79% <96.29%> (+0.26%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ori-kron-wis ori-kron-wis changed the title Extract seam methods from FCLayers for easier inheritance Fix: Extract some methods from FCLayers for easier inheritance Jun 30, 2026
@ori-kron-wis ori-kron-wis added the cuda tests Run test suite on CUDA label Jun 30, 2026
@ori-kron-wis ori-kron-wis merged commit 937568a into scverse:main Jun 30, 2026
20 checks passed
ori-kron-wis pushed a commit that referenced this pull request Jun 30, 2026
…ayers for easier inheritance) (#3898)

Backport PR #3880: Fix: Extract some methods from FCLayers for easier
inheritance

Co-authored-by: Amir Ali Moinfar <moinfar.amirali@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda tests Run test suite on CUDA on-merge: backport to 1.4.x on-merge: backport to 1.4.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants