Repository navigation
Conversation
A launch whose grid has a zero dimension, such as `grid = (triton.cdiv(n, BLOCK),)` with `n == 0`, set `max_workers` to `min(num_sms, 0) == 0`. `_run_grid` then took the thread-pool path, and `ThreadPoolExecutor(max_workers=0)` raised "max_workers must be greater than 0", so every client failed on such a launch. Triton runs no blocks for an empty grid, natively and under `TRITON_INTERPRET=1`; `_run_grid` now returns without running any. 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 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
A launch whose grid has a zero dimension fails under every client. For example, a test that runs a kernel on an empty tensor with
grid = (triton.cdiv(n, BLOCK),)andn == 0:_prepare_grid_launchsetsmax_workers = min(cfg.num_sms, total_blocks), which is 0 for an empty grid._run_gridruns blocks sequentially only whenmax_workers == 1, so an empty grid took the thread-pool path, andThreadPoolExecutor(max_workers=0)raised. Triton runs no blocks for an empty grid, natively and underTRITON_INTERPRET=1._run_gridnow returns before running any block whenmax_workers == 0.Tests
tests/unit/test_multithreading.py:test_empty_grid_runs_no_blocks, a launch with grid(0,)under the tracer, the sanitizer, and the race detector, each with 1 and 2 emulated SMs. It checks that the launch completes and stores nothing. All 6 cases fail on main with the error above.pytest tests/: 366 passed, 6 skipped on main; 372 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
https://claude.ai/code/session_016HMpCLXdUVNfMbJTj8aHE2