Repository navigation
One BLAS thread while the runtime runs, LAPACK no longer serialized by size - #6
Merged
Merged
Conversation
…y size numpy2x sets OpenBLAS's process-wide thread count to 1 when its runtime starts and restores the previous count at shutdown (_blas.py, as viproc): the workers parallelize across ops instead of OpenBLAS's own threads. LAPACK calls of >= 64 x 64 are serialized (NX_GUFUNC_SERIAL) only when numpy2x has no control over the BLAS threads (no OpenBLAS found). Results are bit-identical to NumPy with OPENBLAS_NUM_THREADS=1; large products may differ in the last bits from NumPy's default thread count (docs/testing.md, known differences). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JT2yHjSFdbWf5ym7Dc5MAU
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.
What
Same change as viproc (hokb/viproc#67): numpy2x runs BLAS (OpenBLAS) on one thread while its runtime runs; its two workers parallelize across ops instead.
_blas.py(new, from viproc):apply()at runtime start sets OpenBLAS's process-wide count to 1,restore()atshutdown()gives back the previous count;single()tells whether it is in effect._linalg._call: LAPACK calls of >= 64 x 64 are serialized (NX_GUFUNC_SERIAL) only without control over the BLAS threads (no OpenBLAS found). Before, they were always serialized by size.python/tests/test_blas.py: one thread and restored, no serialization, serialization without BLAS control.docs/testing.md, known differences: results are bit-identical to NumPy withOPENBLAS_NUM_THREADS=1; large products may differ in the last bits from NumPy's default thread count; a single large product is slower.Measured
viproc's
opt_levels.pyadapted to numpy2x, 4 vCPUs (cloud VM), p = 8, speedup vs. NumPy with its default BLAS threads, two full runs (ranges):invinvsolvesolveFPE solver rebuild (71 × 71 complex solves and products, i7-8550U): numpy2x 3018 ms → 1829 ms (NumPy 3394 ms).
With its fixed two workers numpy2x uses fewer cores than OpenBLAS's default on large matrices: many small or medium linalg calls gain, large products and inverses lose. The per-op C path is unchanged; the Python side adds one
_blas.single()call per linalg call.Tests
pytest python/tests: 6950 passed, 6 skipped, 6 xfailed (Linux, Release).Generated by Claude Code