fix(drift): make ABCD usable without PyTorch, and default to PCA - #384
Merged
hmgomes merged 1 commit intoAug 7, 2026
Merged
Conversation
ABCD reconstructs instances with one of three encoder-decoder models. Only the autoencoder needs PyTorch; PCAModel and KernelPCAModel use scikit-learn, which is a core dependency. All three lived in feature_extraction.py, whose module-level `import torch.nn` forced the whole detector behind the torch gate, so `pip install capymoa` lost the only multivariate drift detector even for configurations that never touch PyTorch. Move AutoEncoder to its own module. It subclasses nn.Module, so the import cannot be deferred into a method; a separate file is what lets abcd.py load it lazily, and only when model_id="ae" is actually requested. Asking for that model without the extra now raises OptionalDependencyError naming the model rather than the detector, since the other two remain available. Switch the default from "ae" to "pca" so a plain ABCD() works in a default install. This changes the model an existing caller gets from the default, and belongs in the release notes; on the univariate stream in the drift detection notebook both models behave identically, so its stored output is unchanged. Also give the unknown-model_id branch a message instead of a bare ValueError.
hmgomes
force-pushed
the
fix/abcd-torch-gating
branch
from
August 7, 2026 10:54
79d4749 to
467943d
Compare
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.
ABCD reconstructs instances with one of three encoder-decoder models, but only the autoencoder needs PyTorch.
PCAModelandKernelPCAModeluse scikit-learn, which is a core dependency. All three shared a module whose top-levelimport torch.nnput the whole detector behind the torch gate, so a default install lost CapyMOA's only multivariate drift detector even for configurations that never touch PyTorch.AutoEncodermoves to its own module. It subclassesnn.Module, so the import cannot be deferred into a method; a separate file is what letsabcd.pyload it lazily and only whenmodel_id="ae"is requested. Asking for that model without the extra raises an error naming the model rather than the detector:The default changes from
"ae"to"pca", so a plainABCD()works in a default install. That alters which model an existing caller gets and belongs in the release notes. On the univariate stream in the drift detection notebook the two behave identically (1 detection, 2 warnings, first at 1011), so its stored output is unchanged.Verified in a real torch-free virtualenv, not only with the
sys.meta_pathsimulation: ABCD imports, stays in__all__, andpca/kpca/default all run with torch never enteringsys.modules.Closes the follow-up left open by #370, which supplies
capymoa._optionalandOptionalDependencyError.