Skip to content

Fix: Isolate hooks between multiple TorchFeatureExtractor instances#122

Open
y-prudent wants to merge 3 commits intofeat/torchvision_lazy_importfrom
fix/consistent_hooks
Open

Fix: Isolate hooks between multiple TorchFeatureExtractor instances#122
y-prudent wants to merge 3 commits intofeat/torchvision_lazy_importfrom
fix/consistent_hooks

Conversation

@y-prudent
Copy link
Copy Markdown
Member

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

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
Copy link
Copy Markdown
Contributor

@cofri cofri left a comment

Choose a reason for hiding this comment

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

Very nice hook hack! 💪

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