Repository navigation
Load MKL only from the environment bartorch is installed in - #155
Merged
Merged
Conversation
A virtual environment made from an interpreter that carries its own MKL (an Anaconda base, for instance) loaded that MKL even though the venv never installed it, and an old one crashes FINUFFT and BLAS calls with SIGILL or a segmentation fault. sys.base_prefix is no longer searched, and sys.prefix is searched before the install data path rather than in path-string order. Fixes #149 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MVoFBs7CDGDmiw1VFRD22
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Requested by Matteo · project thread
Before: in a venv made from an Anaconda Python, bartorch loaded the base interpreter's
libmkl_rt.so.2(oneAPI MKL 2023.1) although the venv never installed MKL, and FINUFFT/BLAS calls died with SIGILL or a segmentation fault on an AVX2-only i7-13700H. Precedence between roots followed the path string, so a venv under/workspacewould pick the base MKL even with its ownmklwheel.After:
_mkl_library()searchessys.prefix, then the install data path, in that order, and neversys.base_prefix. Without an MKL in the environment, bartorch falls back to torch's BLAS / SciPy as it does elsewhere.How: one ordered root list in
_backend._mkl_library, plus two tests that fake a base interpreter carrying MKL and an environment whose data path sorts first.The FINUFFT CPU dispatch itself was checked in an earlier thread (emulated AVX2-only CPU picks the v3 module and runs
linop.NUFFT), so no build change is needed.Fixes #149
Generated by Claude Code