Fix torch-incompatible assertions in TestViewCudaArrayInterfaceGPU#1999
Merged
leofang merged 6 commits intoNVIDIA:mainfrom May 1, 2026
Merged
Fix torch-incompatible assertions in TestViewCudaArrayInterfaceGPU#1999leofang merged 6 commits intoNVIDIA:mainfrom
leofang merged 6 commits intoNVIDIA:mainfrom
Conversation
The _check_view method in TestViewCudaArrayInterfaceGPU was missed during the tensor bridge refactor (NVIDIA#1894) and still used raw numpy attributes (in_arr.size, in_arr.strides, in_arr.flags, etc.) that don't work with torch tensors. Use the _arr_* helpers that NVIDIA#1894 added for torch/numpy compatibility. Caught by the nightly optional-dependency CI (NVIDIA#1987). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Member
Author
|
/ok to test 24fc3aa |
This comment has been minimized.
This comment has been minimized.
torch's __cuda_array_interface__ always reports strides, even for C-contiguous tensors. Use the same assertion pattern as the other _check_view methods: allow strides to equal the C-contiguous values instead of requiring None. Verified locally: 7/7 torch CAI tests pass. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use the same if/else pattern with `in (None, strides_in_counts)` in all three _check_view methods for consistency. Previously TestViewCPU and TestViewCudaArrayInterfaceGPU used a one-liner that was harder to read and behaved slightly differently. Verified locally: 66/66 tests pass across TestViewCPU, TestViewGPU, and TestViewCudaArrayInterfaceGPU (including all torch variants). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
Author
|
/ok to test dacfec9 |
rwgk
reviewed
May 1, 2026
Andy-Jost
approved these changes
May 1, 2026
Per @rwgk's review: - Flip strides check to branch on view.strides (all 3 _check_view) - Add _arr_dtype helper using __cuda_array_interface__["typestr"] for torch tensors, restore dtype assertion in CAI _check_view - Merge main to pick up NVIDIA#1998 (numba flags fix) Verified locally: 76/76 tests pass across all three test classes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
Author
|
/ok to test 6b017b7 |
rwgk
approved these changes
May 1, 2026
Andy-Jost
approved these changes
May 1, 2026
|
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.
The
_check_viewmethod inTestViewCudaArrayInterfaceGPUwas missed during the tensor bridge refactor (#1894) and still used raw numpy attributes that don't work withtorch.Tensor:in_arr.size— torch's.sizeis a method (returns shape), not a property (returns element count)in_arr.strides/in_arr.dtype.itemsize— torch tensors don't have numpy-style.stridesin_arr.flags["C_CONTIGUOUS"]— torch tensors don't have.flagsgpu_array_ptr(in_arr)— didn't handle torch tensorsin_arr.dtype— torch dtype != numpy dtypeChanges
_arr_*helpers (_arr_ptr,_arr_size,_arr_strides_in_counts,_arr_is_c_contiguous)_arr_dtypehelper: uses__cuda_array_interface__["typestr"]for torch tensors to get a numpy-compatible dtypeview.strides is None(per review) — clearer semantics, consistent across all three_check_viewmethods_arr_dtypeTesting
Verified locally: 76/76 tests pass across
TestViewCPU,TestViewGPU, andTestViewCudaArrayInterfaceGPU(including all torch and cupy variants).Caught by the nightly optional-dependency CI (#1987).
-- Leo's bot