Skip to content

Fix: Isolate hooks between multiple TorchFeatureExtractor instances - #122

Merged
y-prudent merged 3 commits into
masterfrom
fix/consistent_hooks
May 19, 2026
Merged

Fix: Isolate hooks between multiple TorchFeatureExtractor instances#122
y-prudent merged 3 commits into
masterfrom
fix/consistent_hooks

Conversation

@y-prudent

@y-prudent y-prudent commented Feb 17, 2026

Copy link
Copy Markdown
Member

Problem: Multiple TorchFeatureExtractor instances on the same model interfere with each other. For instance, calling plot_2D_features after fitting an OOD detector corrupts the detector's hooks.

Solution:

  • Each extractor now manages its own hooks via self._handles (instead of shared self.model._ood_handles)
  • Added self._active flag: hooks only execute when their extractor is active
  • Added public clean_hooks() method for explicit cleanup
  • Added new tests to make sure torch extractors do not interfere anymore

Note: I rebased on #121 to address the Black formatting issue.

@y-prudent
y-prudent force-pushed the fix/consistent_hooks branch from dde7917 to 9f6c060 Compare February 17, 2026 11:09
@y-prudent
y-prudent changed the base branch from master to feat/torchvision_lazy_import February 17, 2026 11:17

@cofri cofri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice hook hack! 💪

@y-prudent
y-prudent changed the base branch from feat/torchvision_lazy_import to master May 19, 2026 08:45
@y-prudent
y-prudent merged commit b384abe into master May 19, 2026
9 checks passed
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.

2 participants