Repository navigation
Conversation
A tensor-descriptor load or store (and, on Triton 3.7, a block-pointer one) reaches the masked load/store with its bounds mask as a plain NumPy array rather than a TensorHandle. The profiler read `mask.data.size`, and an array's `.data` is a memoryview, so every such access raised AttributeError: 'memoryview' object has no attribute 'size'. `_mask_data` now returns the array itself, and both the mask statistics and the byte counts use it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Performance Benchmark
Iterations: 1 warmup + 20 measured |
This branch has not been deployed
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.
Summary
The profiler crashes on every tensor-descriptor load or store:
Triton's interpreter implements
create_descriptor_load/create_descriptor_storeby calling the masked load/store with the bounds mask fromTensorDescHandle.materialize_pointers, which is a plain NumPy array, not aTensorHandle. The profiler's load/store callbacks readmask.data; for a NumPy array that is a memoryview, which has no.size. On Triton 3.7,tl.make_block_ptrloads and stores reach the same path throughcreate_tensor_pointer_load/create_tensor_pointer_store, so block-pointer kernels crashed there too; on Triton 3.8 they pass aTensorHandleand are unaffected.This PR adds
_mask_data, which returns a NumPy-array mask as is and aTensorHandle's.dataotherwise, and uses it in_get_mask_statsand_report_load_store_bytes. (np.count_nonzerohappened to accept the memoryview, so only.sizefailed.)Tests
tests/end_to_end/test_profiler.py:test_mask_percentage_of_tensor_descriptor_accessescopies a 100-element tensor through descriptors in 4 blocks of 32 and checks the mask counts (128 total, 28 masked, for loads and stores) and the byte counts. It fails on main with the error above.pytest tests/: 366 passed, 6 skipped on main; 367 passed, 6 skipped with this PR (Python 3.12, Triton 3.8.0).ruff checkandruff format --check(v0.1.9) pass on the changed files.🤖 Generated with Claude Code