Skip to content

[executorch][cuda] Split-K schedule for strict-FP32 dense 3x3 convolutions with few output tiles - #25270

Merged
Gasoonjia merged 1 commit into
mainfrom
gh/Gasoonjia/121/orig
Nov 19, 2026
Merged

Gasoonjia merged 1 commit into
mainfrom
gh/Gasoonjia/121/orig

Conversation

@pytorchbot

Copy link
Copy Markdown
Collaborator

@pytorch-bot

pytorch-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/25270

Note: Links to docs will display an error until the docs builds have been completed.

⏳ No Failures, 74 Pending

As of commit 6d10d2b with merge base fe24cf5 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 19, 2026
@Gasoonjia
Gasoonjia added this pull request to stack #25281 November 19, 2026 06:45
Base automatically changed from gh/Gasoonjia/120/orig to main November 19, 2026 06:48
…tions with few output tiles

Dense 3x3 convolutions at low resolution leave most of the GPU idle: at batch 5 and 3x3 pixels, a 512-channel layer gives eight 64x64 output tiles for a 4608-long reduction. In strict FP32, Inductor's template and the FMA schedule both run such layers below 1 TFLOPS.

The implicit-GEMM template gains `igemm_ffma_splitk`, a compile-time candidate next to `igemm_ffma`: the kernel splits the reduction over a second grid axis into FP32 partial sums, sized for two waves of 64x64 tiles, and a reduction kernel adds them in a fixed order before the usual epilogue. Three narrow FMA tiles are added (256x32 and 128x32 for tall outputs, 64x32 for 512 channels at 15x20). `worth_routing` gains a strict-FP32 range: 3x3 stride 1 keeping 64 to 512 channels and stride 2 doubling 64 to 256, with bounded batch, extent, input pixels and output elements, contiguous layouts only. The new `stage_boundary` benchmark suite measures every corner: all 26 are significantly faster than Inductor on an A100 (1.71-5.4x).

`test_conv_implicit_gemm.py` runs split-K on few-tile geometries in every dtype, input layout and config. `test_conv_routing.py` routes every corner and keeps one step past each limit and other layouts.

This diff was authored with Claude Code.

Differential Revision: [D129852465](https://our.internmc.facebook.com/intern/diff/D129852465/)

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D129852465/)!


ghstack-source-id: 477683774
Pull-Request: #25238
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@Gasoonjia
Gasoonjia merged commit 0a5e60c into main Nov 19, 2026
@Gasoonjia
Gasoonjia deleted the gh/Gasoonjia/121/orig branch November 19, 2026 07:26
@Gasoonjia
Gasoonjia temporarily deployed to upload-benchmark-results November 19, 2026 08:48 — with GitHub Actions Inactive
Gasoonjia added a commit that referenced this pull request Nov 21, 2026
…a timeout (#25392)

Fix the two CUDA jobs that fail on every `main` run since the
#25270–#25280 stack landed: `unittest-cuda (kernel)` and
`test-models-cuda`. That stack landed between `fe24cf5777` (both jobs
green, 2026-11-19 06:48Z) and `6b82a162e7` (both red, 07:26Z). Every
`main` run since then has failed the same way, most recently
`e7f6aefd09`.

### `unittest-cuda (kernel)`: 5 `test_conv_implicit_gemm` failures

All 5 failures are `OutOfResources: shared memory, Required: 131072,
Hardware limit: 101376`:
- `test_every_config_of_every_schedule`
- `test_split_k`
- `test_transposed`
- `test_weight_stream`
- `test_winograd`

**The config that doesn't fit.** I compiled every
`implicit_gemm.CONFIGS` entry for sm_86. Only one is too large for the
A10G's 99 KiB:
- It's the `igemm_tc_packed` tile `(128, 128, 64)` with 8 warps and 3
stages, in FP32 (TF32). That needs (3 − 1) × (128×64 + 64×128) × 4 B =
128 KiB.
- It was added in `_TC_PACKED_TILES` by #25272.
- The same tile in FP16/BF16 needs 64 KiB.

**Why only the test fails.**
- `check(every_config=True)` forces each config through
`force_conv_candidate` and launches the raw JIT kernel, which bypasses
the autotuner.
- Each of the 5 tests has an FP32 every-config subtest with at least 16
input channels, which adds the packed schedule.
- In production, Triton's autotuner times an `OutOfResources` config as
`inf`, and Inductor's precompile drops it. So exports never select it.

**Fix: the test, not the kernel.**
- The test now skips a config that raises `OutOfResources` and emits a
warning. This follows the existing pattern in
`test_int8_quantized_gemm.py`.
- It still fails if no config of a schedule fits.
- Shrinking the tile to 2 stages would also change the FP16/BF16 tile
that was tuned for A100/H100.

### `test-models-cuda`: cancelled at its 90-minute timeout

Before the stack, the job took 64–70 minutes; since then it has been
cancelled at 90.2 minutes on 11 runs in a row. Almost all of the extra
time is in the conv-heavy exports:

| step | `fe24cf5777` (good) | `6b82a162e7` (first bad) |
|---|---|---|
| resnet18 export | 27.9 min | 39.5 min |
| mv2 export | 9.7 min | 22.3 min |
| mv3 export | 9.2 min | cancelled after 9.6 min |

**Why it got slower.**
- #25278 turned on measured routing for the conv family.
- Measured routing (#25277, #25279) is on by default.
- So every convolution in resnet18, mv2 and mv3 is now compiled and
timed in a worker process on a cold cache, against both Inductor and
`triton::convolution`.

This is the expected cost of that feature, and the job's job is to cover
it, so I'm keeping it and raising the timeout to 120 minutes.
`unittest-cuda` already uses the same limit. The projected runtime is
about 100 minutes.

### Test plan
- **Shared memory:** compiled every `implicit_gemm.CONFIGS` entry for
sm_86 offline (triton 3.9). Only the FP32 `igemm_tc_packed (128, 128,
64, 8, 3)` needs more than 101376 B.
- **New test logic, run without a GPU (with mocks):**
- one oversized config: the test passes and warns `igemm_tc_packed big:
shared memory`;
- every config oversized: the test fails with `no igemm_tc_packed config
fits this device`;
  - any other exception still propagates.
- **Lint:** `black` 24.4.2 and `flake8` are clean, and `cuda.yml`
parses.
- **CI on this PR:** I'll confirm that `unittest-cuda (kernel)` has no
`test_conv_implicit_gemm` failures and that `test-models-cuda` finishes
within the new limit.

This branch was previously deployed

2 inactive deployments
upload-benchmark-results — 6d10d2b9 Deployed Nov 19, 2026 by Gasoonjia
cadence — 6d10d2b9 Deployed Nov 19, 2026 by Gasoonjia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants