Repository navigation
Conversation
…eted tensors With SANITIZER_ENABLE_FAKE_TENSOR=1, kernel arguments become FakeTensors, which carry the original tensor's address but no storage. Two things broke on them: - The profiler skips loads, stores, and dots, but atomics still ran in Triton's interpreter, which dereferenced the original address on the host: a GPU tensor's address segfaults the process, and a CPU tensor is written. Under fake tensors the profiler now overrides create_atomic_rmw and create_atomic_cas like loads, returning zeros without touching memory. With real tensors, atomics still run. - An argument wrapped by triton.reinterpret is rewrapped around its FakeTensor, and TensorWrapper.__init__ reads base.data, which FakeTensor lacked. FakeTensor.data now returns the FakeTensor itself. Tests: test_fake_tensor_atomics_do_not_touch_memory and test_fake_tensor_accepts_reinterpreted_tensor in tests/end_to_end/test_profiler.py (both fail without the fix). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0169QRxKtsivkLDCS5f7rrsm
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
With fake tensors (
SANITIZER_ENABLE_FAKE_TENSOR=1), the profiler fails on two kinds of kernels.Atomics. The profiler skips loads, stores, and dots, but
tl.atomic_add/tl.atomic_casand the other atomics still run in Triton's interpreter. AFakeTensorcarries the original tensor's address but no storage, so the atomic dereferences that address on the host: for a GPU tensor the process segfaults (exit -11), and for a CPU tensor the caller's tensor is written.Reinterpreted tensors.
triton.reinterpret(x, tl.float8e5)gives aTensorWrapper. The interpreter unwraps it, turns the base into aFakeTensor, and rewraps it;TensorWrapper.__init__readsbase.data, whichFakeTensordoes not have:Changes
Profiler.register_op_callback: under fake tensors (cfg.virtual_memory),AtomicRMWandAtomicCasget an overrider that returns zeros of the pointer's element type without touching memory, as the load overrider does. With real tensors atomics still run, sotest_block_sampling, which counts executed blocks withtl.atomic_add, is unchanged.FakeTensor.datareturns theFakeTensoritself.Tests
tests/end_to_end/test_profiler.py:test_fake_tensor_atomics_do_not_touch_memory(a kernel withatomic_addandatomic_cason CPU tensors under fake tensors; before the fix the caller's counter became 4.0) andtest_fake_tensor_accepts_reinterpreted_tensor(atriton.reinterpreted float8 argument; before the fixAttributeError). Both fail without the fix. Full suite on Triton 3.8.0: 368 passed, 6 skipped (366 passed before the two new tests).Found on TritonBench scripts that the profiler could not run with fake tensors:
int4_matmul,int8_matmul_quantization, andbgmv_shrink_kernel(atomics) andf8_conversion_utils(reinterpret).🤖 Generated with Claude Code
https://claude.ai/code/session_0169QRxKtsivkLDCS5f7rrsm