Repository navigation
Conversation
The sanitizer's module-level `_fn_symbolic_cache_set` skipped block (0, 0, 0) of a launch whose kernel, grid, and argument shapes matched an earlier launch. Tensor contents were not part of the key, so an out-of-bounds access that depends on loaded values was missed when it fell in block 0, and missed for the whole launch when the grid had one block. Remove the cache; keep `grid_callback` and `pre_run_callback` as forwarders to `SymbolicClient`. Fixes #517. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016HMpCLXdUVNfMbJTj8aHE2
Performance Benchmark
Iterations: 1 warmup + 20 measured |
This was referenced Nov 1, 2026
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
SymbolicSanitizer.pre_run_callbackkept a module-level cache (_fn_symbolic_cache_set) keyed on the kernel, the grid, the tensor shapes, strides, and dtypes, and the scalar arguments. On a cache hit it returnedFalsefor block (0, 0, 0). Tensor contents are not part of the key, but the sanitizer concretizes loaded values that feed addresses, masks, or branches. So when a later launch had different data:This PR removes the cache.
grid_callbackandpre_run_callbackstay as plain forwarders toSymbolicClient, because theSanitizerfactory's stubs would otherwise shadow them.Removing the cache costs little. After block 0 is skipped,
cache_gridis already cleared, so block 1 goes throughSymbolicClient.pre_run_callbackand runs the same symbolic analysis that block 0 would have run. Only one-block launches, and block 0 of launches that need the full grid, are now analyzed where they used to be skipped.benchmarks/bench_sanitizer.pyno longer imports or clears the cache.Fixes #517.
Tests
test_relaunch_with_new_loaded_indices_is_checked[1|2]intests/end_to_end/test_sanitizer.py. The test runs a gather kernel twice with the same shapes, first with in-bounds indices and then with an out-of-bounds index in block 0, for grids of 1 and 2 blocks. Both cases fail on main and pass with this PR.tests/unit/test_sanitizer.py: the two cache-hit/miss tests are replaced bytest_pre_run_callback_runs_replayed_launch, which fails on main. The post-run lifecycle tests no longer set or checkcache_args/cache_grid.pytest tests/: 366 passed, 6 skipped on main; 367 passed, 6 skipped with this PR (Python 3.12, Triton 3.8.0,tilelensinstalled in editable mode with its CLIs onPATH).ruff checkandruff format --check(v0.1.9, as pinned in.pre-commit-config.yaml) pass on all four changed files.Note on #516
The test added in #516 imports
_fn_symbolic_cache_setand calls.clear()on it. Whichever of the two PRs merges second needs to drop that import and call.🤖 Generated with Claude Code
https://claude.ai/code/session_016HMpCLXdUVNfMbJTj8aHE2