Skip to content

[executorch][cuda] Add planned replacement to the Triton replacement pass - #25083

Open
Gasoonjia wants to merge 2 commits into
gh/Gasoonjia/109/basefrom
gh/Gasoonjia/109/head
Open

Gasoonjia wants to merge 2 commits into
gh/Gasoonjia/109/basefrom
gh/Gasoonjia/109/head

Conversation

@Gasoonjia

@Gasoonjia Gasoonjia commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

The CUDA backend's Triton replacement pass replaces every node of a listed op. Some kernels, such as the convolution kernels later in this stack, can take only some calls of an op, are worth taking only on some, and are the only lowering for others; and a failure in the middle of a rewrite could leave a partly edited graph.

triton/routing.py adds planned replacement. An op listed in replacement_pass.PLANNERS gets a pure preflight that classifies each node as OPTIONAL, REQUIRED (the regular lowering cannot compile it) or UNSUPPORTED. The rewrite is transactional: if inserting the new node, rewiring its users or erasing the old node fails, every change is undone; an OPTIONAL call then keeps the regular lowering with a warning, and a REQUIRED call raises ReplacementError with its signature. device_supports(min_capability, device) says whether a kernel can run on the GPU the model is exported and autotuned on, and is False on ROCm; newer GPUs run the package through its PTX. No op uses the planner yet, so lowering is unchanged.

test_triton_replacement.py covers kernel legality by capability and on ROCm, every route through the pass, and fault injection at each rewrite step.

This diff was authored with Claude Code.

Differential Revision: D129725797

NOTE FOR REVIEWERS: This PR has internal Meta-specific changes or comments, please review them on Phabricator!

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

⏳ 1 Pending, 1 Unrelated Failure

As of commit a670401 with merge base dea39f0 (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@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.

[ghstack-poisoned]
@Gasoonjia
Gasoonjia deployed to upload-benchmark-results November 15, 2026 14:55 — with GitHub Actions Active

This branch was successfully deployed

1 active and 1 inactive deployments
upload-benchmark-results — a670401c Deployed Nov 15, 2026 by Gasoonjia via upload-benchmark-results #22545
cadence — a670401c Deployed Nov 15, 2026 by Gasoonjia via hifi-op-test / hifi4 #38446
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. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant