[SC-17529] Treat broken torch installs as "not a PyTorch model" - #549
Merged
panchicore merged 1 commit intoJul 29, 2026
Merged
Conversation
is_pytorch_model() only caught ImportError, but a broken torch install can raise other errors on import — e.g. OSError WinError 1114 when c10.dll fails to load on Windows — which crashed vm.init_model() even for non-torch models like sklearn LogisticRegression (ZD 741). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
PR SummaryThis pull request enhances the functionality of the Additionally, new unit tests have been introduced in
These modifications improve the robustness of the model detection logic in situations where external dependencies, like torch, might be present but not properly functional. Test Suggestions
|
cachafla
approved these changes
Jul 29, 2026
panchicore
deleted the
panchicore/sc-17529/handle-broken-torch-install-oserror
branch
July 29, 2026 18:49
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.
Pull Request Description
What and why?
SC-17529 / ZD 741: a customer on Windows could not run
vm.init_model()on a scikit-learn logistic regression becauseis_pytorch_model()crashed while probing for torch.The probe only caught
ImportError, but a broken torch install can fail with other errors — in the customer's caseOSError: [WinError 1114] A dynamic link library (DLL) initialization routine failedwhile loadingc10.dll. That error escaped theexceptand aborted model initialization for a model that doesn't even use torch.Now any failure to import torch is treated as "not a PyTorch model", matching the existing broad-catch precedent for the optional torch import in
validmind/client.py.Note for the ZD ticket: the customer's torch install is still broken (missing VC++ redistributable / mixed wheels are typical causes) — this fix makes the library robust to it so sklearn workflows are unaffected.
How to test
make test ONLY=tests.test_modelThe new
test_broken_torch_install_returns_falsesimulates the broken install by making torch's import raiseOSError(WinError 1114) via a meta-path finder; it fails without the one-line fix and passes with it.What needs special review?
Nothing — one-line exception-handling change plus tests.
Dependencies, breaking changes, and deployment notes
None.
Release notes
Fixed an error where
vm.init_model()could fail for non-PyTorch models (e.g. scikit-learn) when a broken PyTorch installation was present in the environment, such as aWinError 1114DLL initialization failure on Windows.Checklist
🤖 Generated with Claude Code