Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/195544
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit 22e9eab with merge base bf00e9b ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@minjang has exported this pull request. If you are a Meta employee, you can view the originating Diff in D118188207. |
has_triton accelerator-only by defaulthas_triton accelerator-only by default (#195544)
784faad to
a74a635
Compare
Summary: - `has_triton()` historically meant that a usable GPU/accelerator Triton backend was available, because Triton did not ship a CPU backend. - The latest Triton (3.8) adds a CPU backend whose device interface is available on every host. Without this change, `has_triton()` would become true on CPU-only machines and silently change existing accelerator gates. - Preserve the historical default by ignoring CPU unless a CPU-aware caller explicitly passes `include_cpu=True`. - No safety gate is weakened: package presence, device-detection configuration, availability, Triton capability, and backend availability are still checked. GPU-only remote caching also rejects a selected CPU target. Test Plan: - Reviewed the detection path: `include_cpu=True` only adds CPU to the candidate devices; all existing package, configuration, availability, capability, and backend checks remain in force. - `buck test fbcode//caffe2/test/inductor:utils -- TestHasTriton` — 23 passed. - `buck test fbcode//unified_mapping/utils/tests:test_inductor_remote_cache` — 5 passed. - `buck test fbcode//sigmoid/inference/test:test_passes -- test_triton_hop_cpu` — 2 passed. Differential Revision: D118188207
Summary: - `has_triton()` historically meant that a usable GPU/accelerator Triton backend was available, because Triton did not ship a CPU backend. - The latest Triton (3.8) adds a CPU backend whose device interface is available on every host. Without this change, `has_triton()` would become true on CPU-only machines and silently change existing accelerator gates. - Preserve the historical default by ignoring CPU unless a CPU-aware caller explicitly passes `include_cpu=True`. - No safety gate is weakened: package presence, device-detection configuration, availability, Triton capability, and backend availability are still checked. GPU-only remote caching also rejects a selected CPU target. Test Plan: - Reviewed the detection path: `include_cpu=True` only adds CPU to the candidate devices; all existing package, configuration, availability, capability, and backend checks remain in force. - `buck test fbcode//caffe2/test/inductor:utils -- TestHasTriton` — 23 passed. - `buck test fbcode//unified_mapping/utils/tests:test_inductor_remote_cache` — 5 passed. - `buck test fbcode//sigmoid/inference/test:test_passes -- test_triton_hop_cpu` — 2 passed. Differential Revision: D118188207
a74a635 to
072a635
Compare
Summary: - `has_triton()` historically meant that a usable GPU/accelerator Triton backend was available, because Triton did not ship a CPU backend. - The latest Triton (3.8) adds a CPU backend whose device interface is available on every host. Without this change, `has_triton()` would become true on CPU-only machines and silently change existing accelerator gates. - Preserve the historical default by ignoring CPU unless a CPU-aware caller explicitly passes `include_cpu=True`. - No safety gate is weakened: package presence, device-detection configuration, availability, Triton capability, and backend availability are still checked. GPU-only remote caching also rejects a selected CPU target. Test Plan: - Reviewed the detection path: `include_cpu=True` only adds CPU to the candidate devices; all existing package, configuration, availability, capability, and backend checks remain in force. - `buck test fbcode//caffe2/test/inductor:utils -- TestHasTriton` — 23 passed. - `buck test fbcode//unified_mapping/utils/tests:test_inductor_remote_cache` — 5 passed. - `buck test fbcode//sigmoid/inference/test:test_passes -- test_triton_hop_cpu` — 2 passed. Differential Revision: D118188207
072a635 to
49468b6
Compare
Summary: - `has_triton()` historically meant that a usable GPU/accelerator Triton backend was available, because Triton did not ship a CPU backend. - The latest Triton (3.8) adds a CPU backend whose device interface is available on every host. Without this change, `has_triton()` would become true on CPU-only machines and silently change existing accelerator gates. - Preserve the historical default by ignoring CPU unless a CPU-aware caller explicitly passes `include_cpu=True`. - No safety gate is weakened: package presence, device-detection configuration, availability, Triton capability, and backend availability are still checked. GPU-only remote caching also rejects a selected CPU target. Test Plan: - Reviewed the detection path: `include_cpu=True` only adds CPU to the candidate devices; all existing package, configuration, availability, capability, and backend checks remain in force. - `buck test fbcode//caffe2/test/inductor:utils -- TestHasTriton` — 23 passed. - `buck test fbcode//unified_mapping/utils/tests:test_inductor_remote_cache` — 5 passed. - `buck test fbcode//sigmoid/inference/test:test_passes -- test_triton_hop_cpu` — 2 passed. Differential Revision: D118188207
49468b6 to
b7a77bd
Compare
Summary: - `has_triton()` historically meant that a usable GPU/accelerator Triton backend was available, because Triton did not ship a CPU backend. - The latest Triton (3.8) adds a CPU backend whose device interface is available on every host. Without this change, `has_triton()` would become true on CPU-only machines and silently change existing accelerator gates. - Preserve the historical default by ignoring CPU unless a CPU-aware caller explicitly passes `include_cpu=True`. - No safety gate is weakened: package presence, device-detection configuration, availability, Triton capability, and backend availability are still checked. GPU-only remote caching also rejects a selected CPU target. Test Plan: - Reviewed the detection path: `include_cpu=True` only adds CPU to the candidate devices; all existing package, configuration, availability, capability, and backend checks remain in force. - `buck test fbcode//caffe2/test/inductor:utils -- TestHasTriton` — 23 passed. - `buck test fbcode//unified_mapping/utils/tests:test_inductor_remote_cache` — 5 passed. - `buck test fbcode//sigmoid/inference/test:test_passes -- test_triton_hop_cpu` — 2 passed. Differential Revision: D118188207
b7a77bd to
4a7e52b
Compare
jeanschmidt
left a comment
There was a problem hiding this comment.
Slightly concerned about the TRITON_HAS_CPU change, I assume it is intentional, but worth considering the blast radius
Review summary
🟠 1 major · 🟡 2 minor · ⚪ 1 nit
- 🟠 TRITON_HAS_CPU can now be True while has_triton() is False, so test_triton_kernels' CPU-Triton test references undefined kernels —
torch/testing/_internal/inductor_utils.py:65 - 🟡 The
_runhelper always passesinclude_cpuexplicitly, so no test exerciseshas_triton's default and a flipped default stays green —test/inductor/test_utils.py:1203 - 🟡 has_triton() flips from True to False on the existing inductor-triton-cpu CI job today, which the description presents as a future Triton 3.8 concern —
torch/utils/_triton.py:248 - ⚪
has_tritondocstring claims CPU exclusion preserves historical behavior, buthas_triton()returned True on the triton-cpu CI runner before this change —torch/utils/_triton.py:228
Extended analysis (ai-generated section)
What this changes
has_triton() gains a keyword-only include_cpu parameter defaulting to False, and its detection loop now skips the registered cpu device interface unless a caller opts in (torch/utils/_triton.py:225-248). Four call sites that need any Triton backend rather than an accelerator pass include_cpu=True: the two Triton runtime imports in torch/_dynamo/variables/builder.py, the kernel serialization guard in torch/_export/serde/serialize.py, and the backend hash key in torch/_inductor/runtime/autotune_cache.py. TRITON_HAS_CPU in torch/testing/_internal/inductor_utils.py is retargeted from HAS_TRITON and "cpu" in triton.backends.backends to a direct has_triton_cpu_backend() call. The description frames this as preparation for Triton 3.8 shipping a CPU backend; the repository already builds the triton-cpu fork and runs it on a CPU-only runner, so has_triton() changes value in an existing configuration at merge time, not in the future.
What it gets right
The four migrated call sites are the ones that genuinely need any backend rather than an accelerator, and each carries a one-line comment saying why. The parameter is keyword-only, so no positional call site can drift into the new argument. has_triton_cpu_backend() already existed, so the CPU probe is reused rather than reinvented. The new unit test extends the existing mock-based TestHasTriton harness instead of duplicating it, and asserts both directions of the flag.
Where the risk is
Almost everything concentrates on one statement, torch/testing/_internal/inductor_utils.py:65, and on the has_triton() semantics behind it. Several independent passes converged on the same producer/consumer split there: TRITON_HAS_CPU no longer implies HAS_TRITON, while torch/testing/_internal/triton_utils.py:26 still gates every shared @triton.jit test kernel on a bare has_triton(). On a CPU-only host with a Triton CPU backend the gate that registers CPU-Triton tests stays on while the module that defines their kernels goes off. Those findings share a cluster and one line fixes all of them. A second cluster on the same anchor observes that routing TRITON_HAS_CPU through has_triton_cpu_backend() drops the triton_disable_device_detection gate the old if HAS_TRITON: wrapper carried. A third cluster is the docstring's claim that CPU exclusion preserves historical behavior, which does not hold for triton-cpu builds.
The recurring class of mistake is a half-completed migration: production call sites were audited, the test-support one was not, and the TRITON_HAS_CPU replacement is wider than the expression it replaces. These compound. The missed kernel gate is latent only because the triton-cpu CI job runs two files, neither of which reaches a shared kernel, and that job does not appear in the test plan. Meanwhile _run always forwards include_cpu explicitly, so nothing asserts the accelerator-only default this change exists to establish.
Before merge, and after
Fix the missed gate reported as "TRITON_HAS_CPU can now be True while has_triton() is False" and "leaves its kernels undefined" in torch/testing/_internal/triton_utils.py. Fold in "TRITON_HAS_CPU no longer respects triton_disable_device_detection" in torch/testing/_internal/inductor_utils.py, since has_triton(include_cpu=True) and has_triton_cpu_backend() is one edit on the anchor line both clusters point at. Take "the _run helper always passes include_cpu explicitly" in test/inductor/test_utils.py now too, despite its label: it is two lines and it is what pins the invariant.
Reasonable as follow-up: the docstring wording in torch/utils/_triton.py and the description's tense, flagged as "claims a historical accelerator-only behavior that never held" and "flips from True to False on the existing inductor-triton-cpu CI job today". Both are prose and cheap, but nothing depends on them. The item that is not a one-liner is the decision underneath — whether a triton-cpu-only host should report has_triton() False at all. Running the inductor-triton-cpu job against this branch is the way to settle it.
has_triton accelerator-only by default (#195544)has_triton accelerator-only by default
4a7e52b to
163aa59
Compare
Summary: Triton 3.8 ships a CPU backend that is available on every host. Counting it in bare `has_triton()` would silently change existing GPU and accelerator gates on CPU-only machines. Keep `has_triton()` accelerator-only by default, and let backend-neutral or explicitly CPU-Triton paths opt in with `include_cpu=True`. Existing package, device-detection, capability, and backend-availability checks remain in force. Test Plan: `buck test fbcode//caffe2/test/inductor:utils -- TestHasTriton` — 12 passed `buck test fbcode//unified_mapping/utils/tests:test_inductor_remote_cache` — 5 passed `buck test fbcode//sigmoid/inference/test:test_passes -- test_triton_hop_cpu` — 2 passed Reviewed By: jeanschmidt Differential Revision: D118188207
has_triton accelerator-only by defaulthas_triton accelerator-only by default (#195544)
163aa59 to
22e9eab
Compare
|
@pytorchbot merge (Initiating merge automatically since Phabricator Diff has merged) |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…) (pytorch#195544) Summary: The next Meta's internal triton release (version 3.8) ships a CPU backend that is available on every host. Counting it in bare `has_triton()` would silently change existing GPU and accelerator gates on CPU-only machines. Keep `has_triton()` accelerator-only by default, and let backend-neutral or explicitly CPU-Triton paths opt in with `include_cpu=True`. Existing package, device-detection, capability, and backend-availability checks remain in force. Test Plan: `buck test fbcode//caffe2/test/inductor:utils -- TestHasTriton` — 12 passed `buck test fbcode//unified_mapping/utils/tests:test_inductor_remote_cache` — 5 passed `buck test fbcode//sigmoid/inference/test:test_passes -- test_triton_hop_cpu` — 2 passed Reviewed By: jeanschmidt Differential Revision: D118188207 Pull Request resolved: pytorch#195544 Approved by: https://github.com/jeanschmidt
Summary:
The next Meta's internal triton release (version 3.8) ships a CPU backend that is available on every host. Counting it in bare
has_triton()would silently change existing GPU and accelerator gates on CPU-only machines.Keep
has_triton()accelerator-only by default, and let backend-neutral or explicitly CPU-Triton paths opt in withinclude_cpu=True. Existing package, device-detection, capability, and backend-availability checks remain in force.Test Plan:
buck test fbcode//caffe2/test/inductor:utils -- TestHasTriton— 12 passedbuck test fbcode//unified_mapping/utils/tests:test_inductor_remote_cache— 5 passedbuck test fbcode//sigmoid/inference/test:test_passes -- test_triton_hop_cpu— 2 passedReviewed By: jeanschmidt
Differential Revision: D118188207
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo @azahed98