adding F-contig layout support + other cleanups#108
Open
SwayamInSync wants to merge 3 commits into
Open
Conversation
Member
Author
|
Ahh the fix to run older-cpu workflows is done in #104 , once that will merge we can update here. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect matmul results for non-row-major (notably F-contiguous and transposed-view) QuadPrecision inputs by making the QBLAS dispatch stride-aware (mirroring NumPy’s layout/BLAS-ability checks) and expanding test coverage to exercise the full layout matrix and copy-fallback paths.
Changes:
- Update the
matmulstrided loop to detect BLAS-able 2D operands in either orientation and pass the appropriatetransa/transb+lda/ldb/ldc, copying only when required. - Remove the prior
xfails for Fortran-order/transposed batched cases and add new tests covering layout combinations, output layout, empty-core behavior, and copy-fallback scenarios. - Adjust QBLAS interface edge handling for empty GEMV/GEMM calls.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
tests/test_dot.py |
Removes xfails for issue #89 and adds comprehensive layout/copy-path tests for matmul. |
src/csrc/umath/matmul.cpp |
Implements stride-derived BLAS dispatch (incl. transpose flags) plus gather/scatter copy fallback and size/empty guards. |
src/csrc/quadblas_interface.cpp |
Tweaks empty-dimension behavior for qblas_gemv and qblas_gemm. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
closes #89
This PR improves the BLAS integration very parallel to the NumPy's own logic.
@TYPE@_matmuldispatch. NumPy hands the inner loop raw strides and expects the loop itself to dispatch, so we do the same instead of assuming row-major.is_blasable2dcheck: an operand is BLAS-able iff its fast axis is contiguous and the slow axis is a valid leading dimension; each operand is tested in both orientations (C- and F-blasable).'N'/'T') andldaderived from strides, so F-contiguous/transposed inputs need no copy (QBLAS already supportstransa/transbcorrectly).dim > INT_MAX) or empty cores fall back to the naive strided loop, matching NumPy'stoo_big_for_blasguard.I think this is a good base to integrate dot operations efficiently in follow-up PRs