Skip to content

[release/2.12] Backport Inductor warp-size handling#3380

Open
naromero77amd wants to merge 2 commits into
release/2.12from
release_/2.12_warp_size_upstream_backport
Open

[release/2.12] Backport Inductor warp-size handling#3380
naromero77amd wants to merge 2 commits into
release/2.12from
release_/2.12_warp_size_upstream_backport

Conversation

@naromero77amd

Copy link
Copy Markdown

Summary

Test plan

  • python -m py_compile on all changed Python files
  • git diff --check origin/release/2.12...HEAD
  • IDE lints: no errors
  • Not run: focused runtime unit tests, because the checkout is not built/generated enough for local torch.version

desertfire and others added 2 commits June 29, 2026 23:03
)

Route threads-per-wave through a single source of truth
(DeviceProperties.warp_size, from torch.cuda.get_device_properties) and
thread it through the config-generation helpers, replacing _NUM_THREADS_PER_WARP,
cc_warp_size, and scattered `warp_size or 32` / `torch.version.hip` branches.

Behavior change: _num_warps halves num_warps only when warp_size == 64
(AMD CDNA/gfx9), not on every HIP device; AMD RDNA (wave32) now follows
the NVIDIA path.

Authored with: Claude

Pull Request resolved: pytorch#181112
Approved by: https://github.com/jansel

(cherry picked from commit 521f9d7)
…h#183014)

Upstream PR pytorch#181112 (`[inductor] Unify threads-per-wave (warp_size) extraction`) has now landed and did much of the original broad warp-size plumbing for this PR: it centralized `DeviceProperties.warp_size`, threaded `warp_size` through Inductor's Triton config helpers, and made HIP wave32 devices follow the non-wave64 path.

After rebasing on top of that work, this PR is now focused on the remaining stricter ROCm-safe behavior:

- Preserve missing `DeviceProperties.warp_size` as `None` instead of synthesizing `32` for CUDA/HIP devices.
- Make `DeviceProperties.warp_size_or_default` raise for missing CUDA/HIP warp-size metadata, while preserving the explicit non-GPU fallback.
- Skip optional autotune/rblock/fusion/split-reduction heuristics when required warp-size metadata is unavailable instead of guessing.
- Keep CUDA launcher generation on the fast `32` path, but use the device warp size for HIP launcher block dimensions.
- Use queried device warp size in template register-spill pruning, with graceful fallback on non-CUDA/XPU builds.
- Update the relevant Inductor tests for the stricter missing CUDA/HIP metadata behavior.

- Rebased cleaned stack onto `upstream/main` at `19791183fec`.
- Rebuilt PyTorch from scratch with `/home/niromero/docker_workspace/framework_scripts/pytorch/build.sh`.
- Ran impacted UTs:
  - `python test/inductor/test_triton_heuristics.py TestWarpSizeUnification TestTritonHeuristics.test_autotune_hints_to_configs TestFastLauncherDeviceSupport`
  - `python test/inductor/test_max_autotune.py TestMaxAutotune.test_max_autotune_includes_max_autotune_pointwise_configs`
  - `python test/inductor/test_torchinductor_dynamic_shapes.py -k test_embedding_backward_dynamic_shapes_large_grid`
  - `python test/inductor/test_torchinductor.py -k test_reduction_config_limit`

Made with [Cursor](https://cursor.com)

Pull Request resolved: pytorch#183014
Approved by: https://github.com/jansel, https://github.com/glen-amd, https://github.com/jeffdaily, https://github.com/eellison

(cherry picked from commit 9183299)
@rocm-repo-management-api

rocm-repo-management-api Bot commented Jun 29, 2026

Copy link
Copy Markdown

Jenkins build for 0cc2280e44da48851d2b7aaf85d9e87fa2a3c796 commit finished as FAILURE
Links: Pipeline Overview / Build artifacts / Test Results

@naromero77amd

Copy link
Copy Markdown
Author

Update on the distributed CI failures:

I tried to reproduce the failing distributed tests locally against a clean release/2.12 baseline build and was not able to reproduce the failures.

Failures observed in CI on this PR:

  • test/distributed/test_distributed_spawn.py::TestDistBackendWithSpawn::test_ddp_apply_optim_in_backward_grad_as_bucket_view_false
  • test/distributed/test_distributed_spawn.py::TestDistBackendWithSpawn::test_ddp_apply_optim_in_backward

Local checks performed:

  • Rebuilt clean origin/release/2.12 without the backport commits.
  • Reran the failing distributed tests via the PyTorch distributed test harness.
  • Also copied the backported Python-only Inductor files into the installed /opt/conda torch package and reran the Jenkins-style repro commands.

Both targeted repro attempts passed locally, including the Python-files-over-baseline run. I was not able to reproduce the tensor mismatch failures from Jenkins.

@naromero77amd naromero77amd marked this pull request as ready for review July 1, 2026 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants