Fix torch-incompatible assertions in TestViewCudaArrayInterfaceGPU#1999
Open
leofang wants to merge 4 commits intoNVIDIA:mainfrom
Open
Fix torch-incompatible assertions in TestViewCudaArrayInterfaceGPU#1999leofang wants to merge 4 commits intoNVIDIA:mainfrom
leofang wants to merge 4 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 |
|
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 |
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 tensorsReplaced with the
_arr_*helpers that #1894 added for torch/numpy compatibility:_arr_ptr,_arr_size,_arr_strides_in_counts,_arr_is_c_contiguous.Also unified the strides assertion pattern across all three
_check_viewmethods to use the sameif/elsewithin (None, strides_in_counts)for C-contiguous arrays (torch's__cuda_array_interface__always reports strides, even for C-contiguous tensors).Verified locally: 66/66 tests pass across
TestViewCPU,TestViewGPU, andTestViewCudaArrayInterfaceGPU(including all torch variants).Caught by the nightly optional-dependency CI (#1987).
-- Leo's bot