Skip to content

[executorch][cuda] Choose among a call's implementations by measuring them on the export GPU - #25245

Merged
Gasoonjia merged 1 commit into
gh/Gasoonjia/128/basefrom
gh/Gasoonjia/128/head
Nov 19, 2026
Merged

Gasoonjia merged 1 commit into
gh/Gasoonjia/128/basefrom
gh/Gasoonjia/128/head

Conversation

@Gasoonjia

@Gasoonjia Gasoonjia commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

When both the regular lowering (Inductor) and a Triton replacement can run a call, a static shape-class predicate per family picks one. Such predicates are approximate off the GPU they were tuned on, and every family maintains its own.

This diff adds measured routing for families that opt in (ReplacementPlan.measure), on by default (measured_routing compile spec). A worker process inside the backend's AOTI context compiles each opted-in call's legal implementations, Inductor's with the C++ wrapper (one that cannot run drops out), and times them with CUDA graphs. A replacement wins only if it is faster by measured_routing_margin (default 0.15) with its p90 below Inductor's p10. Deterministic outcomes are cached (measured_routing_cache_dir). Otherwise, including in a process that cannot load C++-wrapper modules (one warning per export), the static choice is taken. A worker that writes no result and no output for 30 minutes is killed as hung. No family opts in yet.

Tests cover the decision protocol, the watchdog, availability and caching, the settings, the opt-in, a process that cannot measure, both lowering APIs, and a real export probed in the worker.

This diff was authored with Claude Code.

Differential Revision: D130871444

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 18, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 4 New Failures, 1 Cancelled Job, 38 Unrelated Failures

As of commit 71e6f59 with merge base 164233d (image):

NEW FAILURES - The following jobs have failed:

CANCELLED JOB - The following job was cancelled. Please retry:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs 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.

@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 18, 2026
@Gasoonjia
Gasoonjia had a problem deploying to upload-benchmark-results November 18, 2026 22:32 — with GitHub Actions Failure
Gasoonjia added a commit that referenced this pull request Nov 19, 2026
…nnot call (#25236)

Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0)
(oldest at bottom):
* #25248
* #25247
* #25246
* #25245
* #25244
* #25243
* #25242
* #25241
* #25240
* #25239
* #25238
* #25237
* __->__ #25236

With layout optimization off, which Inductor decides for a graph with
few convolutions (fewer than one per 300 nodes), a stride-1 1x1
convolution is lowered as a convolution, and Inductor's autotuning
offers `conv1x1_via_mm`: a Python function with no C++ shim.
AOTInductor's C++ wrapper cannot emit it, so whenever it is the fastest
choice the compile fails in wrapper codegen with "Expected name is not
None". A single strict-FP32 512-to-32 1x1 convolution on a 5x512x3x3
input reproduces it. In a full model it appears once enough convolutions
are routed to `triton::convolution` that the remaining ones fall below
Inductor's threshold.

The CUDA backend gains one more scoped compile patch, like its existing
Inductor workarounds: during its AOTI compile, the convolution
lowering's autotuning drops extern choices without a C++ kernel or a
fallback kernel when the C++ wrapper is in use. Only threads inside the
backend's compile get the change, and the patch is removed when the last
one leaves. Inductor offering such Python-only choices under the C++
wrapper is filed upstream as
pytorch/pytorch#204342; the patch goes once
the pinned PyTorch has the fix.

`test_cuda_export.py` checks that the patch drops only those choices and
only for the C++ wrapper, and lowers the reproducing 1x1 convolution
with layout optimization off, which failed before.

This diff was authored with Claude Code.

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

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or
comments, please review them on
[Phabricator](https://our.internmc.facebook.com/intern/diff/D130038817/)!
Gasoonjia added a commit that referenced this pull request Nov 19, 2026
…ring AOTInductor compiles (#25237)

Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0)
(oldest at bottom):
* #25248
* #25247
* #25246
* #25245
* #25244
* #25243
* #25242
* #25241
* #25240
* #25239
* #25238
* __->__ #25237
* #25236

Inductor's mm and bmm templates hint that each block of `BLOCK_M` row
indices `rm % M` is contiguous, which is false in the last block when
`BLOCK_M` does not divide M: the indices wrap to 0. The template's own
loads never vectorize along M, so the false hint is harmless there. A
fused prologue, though, can read the first operand from a buffer
contiguous along M, such as a LayerNorm of channel-first features seen
as tokens. Triton then vectorizes those loads across the wrap and the
kernel faults with "CUDA error: misaligned address", which is sticky and
fails the whole compile. A strict-FP32 graph with 147 tokens per stage
hit it after convolution routing to `triton::convolution` changed
Inductor's fusion choices.

The CUDA backend gains one more scoped compile patch: during its AOTI
compile, the matmul templates hint contiguous rows (and columns) only
when the block size divides M (or N), where the hint holds.

`test_cuda_export.py` compiles the LayerNorm-then-linear pattern with
147 rows, which faulted before, checks the result and both rewritten
hint conditions, and that the template keeps its hint outside the patch.

This diff was authored with Claude Code.

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

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or
comments, please review them on
[Phabricator](https://our.internmc.facebook.com/intern/diff/D130269530/)!
Gasoonjia added a commit that referenced this pull request Nov 19, 2026
…tions with few output tiles (#25238)

Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0)
(oldest at bottom):
* #25248
* #25247
* #25246
* #25245
* #25244
* #25243
* #25242
* #25241
* #25240
* #25239
* __->__ #25238
* #25237
* #25236

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/)!
Gasoonjia added a commit that referenced this pull request Nov 19, 2026
…-1 convolutions (#25239)

Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0)
(oldest at bottom):
* #25248
* #25247
* #25246
* #25245
* #25244
* #25243
* #25242
* #25241
* #25240
* __->__ #25239
* #25238
* #25237
* #25236

In strict FP32 (TF32 off), dense 3x3 stride-1 convolutions with many
output tiles are bound by FMA throughput: the FMA schedules and
Inductor's template pay 9 multiply-adds per output and channel pair, and
split-K only helps outputs too small to fill the GPU, so larger layers
stayed with Inductor.

The implicit-GEMM template gains `winograd_f4`, one more compile-time
candidate for strict-FP32 dense 3x3 stride-1 padding-1 2-D calls. It
computes each 4x4 output tile from a 6x6 input tile with 36 products
instead of 144 per channel pair: weight and input transforms, 36 batched
IEEE-FP32 GEMMs with autotuned tiles, and an output transform that adds
the bias and stores through the output strides. Balanced transform
points keep the error close to a direct convolution. `worth_routing`
gains a Winograd range: 64 to 512 input and output channels within the
stage batch, extent and input-pixel limits, contiguous layouts, any
output size. The new `winograd_boundary` suite measures its 28 corners:
all are significantly faster than Inductor on an A100 (1.79-8.9x),
per-call weight transform included.

`test_conv_implicit_gemm.py` runs `winograd_f4` with every config
wherever it is legal, on odd sizes, deep and shallow reductions, both
input layouts, with and without bias and in three output layouts.
`test_conv_routing.py` routes every Winograd corner and keeps one step
past each limit.

This diff was authored with Claude Code.

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

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or
comments, please review them on
[Phabricator](https://our.internmc.facebook.com/intern/diff/D129890349/)!
Gasoonjia added a commit that referenced this pull request Nov 19, 2026
…nvolutions (#25240)

Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0)
(oldest at bottom):
* #25248
* #25247
* #25246
* #25245
* #25244
* #25243
* #25242
* #25241
* __->__ #25240
* #25239
* #25238
* #25237
* #25236

On FP16/BF16 3x3x3 convolutions with a channel-first input, Inductor's
Triton conv template runs 2.7-7x behind cuDNN, and the implicit-GEMM
tensor-core schedule was slower still: the native weight layout `[C_out,
C_in, 3, 3, 3]` strides both dims of each tap's weight tile by 27, so
every element is a separate load.

The implicit-GEMM template gains `igemm_tc_packed`, a compile-time
candidate that copies the input to channels-last (unless it already is)
and the weight to `[taps, C_in, C_out]`, then runs the same kernel on
tiles contiguous along K and the output channels. Tensor-core tiles with
64-deep K blocks are added for it. `worth_routing` gains a 3-D range:
FP16/BF16 3x3x3 stride-1 convolutions with padding 0 or 1, 64 to 1024
input and output channels, at least 64 output pixels and any larger
extent, contiguous layouts. The new `conv3d_boundary` benchmark suite
measures its 32 corners: all are significantly faster than Inductor on
an A100 in both dtypes (1.44-13.5x), including the operand copies, which
run at every call; copying the constant weight once at export would be
its own diff.

`test_conv_implicit_gemm.py` runs the packed schedule on every geometry
with 16 or more input channels and on already-packed 3-D operands.
`test_conv_routing.py` routes every 3-D corner in both dtypes and keeps
one step past each limit, other layouts and (3,1,1) convolutions.

This diff was authored with Claude Code.

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

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or
comments, please review them on
[Phabricator](https://our.internmc.facebook.com/intern/diff/D130017632/)!
Gasoonjia added a commit that referenced this pull request Nov 19, 2026
… rows to the implicit-GEMM template (#25241)

Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0)
(oldest at bottom):
* #25248
* #25247
* #25246
* #25245
* #25244
* #25243
* #25242
* __->__ #25241
* #25240
* #25239
* #25238
* #25237
* #25236

Strict-FP32 1-D convolutions over short sequences with many channels
read each weight for only a few outputs, so their cost is streaming the
weights. Inductor's template, given the 2-D form the backend lowers them
to, has a handful of output tiles for such a call and leaves most of the
GPU idle: a 2048-channel kernel-5 convolution over 4 positions takes 690
us for 84 MB of weights.

`worth_routing` gains a 1-D range for the existing schedules, whose
split-K spreads the weight reads over the GPU: strict FP32, kernel 5 or
3 with stride 1 and "same" padding, kernel 3 with stride 2 and padding
1, and transposed kernel 4 with stride 2 and padding 1, with 512 to 4096
input and 64 to 2048 output channels, 4 to 64 output rows (batch times
output length) and contiguous layouts. Kernel-1 convolutions keep the
regular lowering. The new `conv1d_boundary` suite measures its 64
corners: all are significantly faster than Inductor on an A100
(1.42-28.6x), reading the weights in their native layout.

`test_conv_routing.py` routes every corner and keeps one step past each
limit, other geometries, TF32, BF16 and sliced inputs, and checks the
1-D and transposed 1-D rows through both lowering APIs.

This diff was authored with Claude Code.

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

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or
comments, please review them on
[Phabricator](https://our.internmc.facebook.com/intern/diff/D130068466/)!
Gasoonjia added a commit that referenced this pull request Nov 19, 2026
…h few output rows (#25242)

Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0)
(oldest at bottom):
* #25248
* #25247
* #25246
* #25245
* #25244
* #25243
* __->__ #25242
* #25241
* #25240
* #25239
* #25238
* #25237
* #25236

Strict-FP32 1-D convolutions with few output rows are bound by reading
their weights, but the implicit-GEMM schedules read them at 110-250 GB/s
on an A100: `tl.dot` needs at least 16 rows per tile, and an FMA tile
spends its time staging operands rather than streaming weights. A
2048-channel kernel-5 convolution over 4 positions took 502 us for 84 MB
of weights.

The implicit-GEMM template gains `stream_ffma`, one more compile-time
candidate for forward 1-D convolutions with at most 64 output rows and a
contiguous weight. Each program reads blocks of the native `[C_out, C_in
* taps]` weight along its contiguous axis, multiplies them in FP32 with
the im2col block of all rows held in registers, and accumulates without
`tl.dot`; K is split over a second grid axis and a reduction kernel adds
the partial sums in split order before adding the bias and storing.
Block sizes and the split count are autotune configs. The 2048-channel
convolution now takes 96 us. With it, the 1-D range also takes 2049 to
4096 output channels: the `conv1d_boundary` suite's 64 corners are all
significantly faster than Inductor (1.70-51.6x).

`test_conv_implicit_gemm.py` runs `stream_ffma` wherever it is legal,
with every config, deep and shallow reductions, the most rows, strided
inputs and output layouts, and checks the calls it refuses.

This diff was authored with Claude Code.

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

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or
comments, please review them on
[Phabricator](https://our.internmc.facebook.com/intern/diff/D130148517/)!
Gasoonjia added a commit that referenced this pull request Nov 19, 2026
…d shape classes (#25243)

Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0)
(oldest at bottom):
* #25248
* #25247
* #25246
* #25245
* #25244
* __->__ #25243
* #25242
* #25241
* #25240
* #25239
* #25238
* #25237
* #25236

Several convolution shapes keep Inductor's template although the
implicit-GEMM schedules run them significantly faster. Winograd stopped
at the split-K stage caps though it does a quarter of the multiplies at
any size; the stage range stopped at 160K outputs and 256 input
channels; unpadded stride-2 encoder layers and deep 1x1 convolutions had
no class; and (3,1,1) stride-(2,1,1) 3-D convolutions were not routed.

`worth_routing` gains classes set inside the edges of explore sweeps:
Winograd without batch or extent limits (its 32-bit indexing bounds it);
stage convolutions from 512 to 240K outputs, stride 2 up to 1024 input
channels, plus unpadded stride-2 3x3 with 64 channels and 5x5 with 32 to
64 (32-channel 3x3 stays out: its corners came within 1.3x); strict-FP32
1x1 stride-1 with 512 to 2048 input and 32 to 256 output channels and
32K to 128K outputs; and FP16/BF16 (3,1,1) stride-(2,1,1) with 256 to
1024 input and 128 to 1024 output channels and 64 to 2048 output pixels.
3-D ranges become one table. The benchmark gains a `pointwise_boundary`
suite and a flag for Inductor without layout optimization.

Every corner is significantly faster than Inductor on an A100: stage
45/45 (1.40-6.5x), Winograd 16/16 (1.87-8.5x), 3-D 96/96 (1.43-13.7x),
1x1 16/16 with layout optimization (1.36-3.2x) and without (1.74-5.3x).

`test_conv_routing.py` routes every corner and keeps one step past each
limit.

This diff was authored with Claude Code.

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

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or
comments, please review them on
[Phabricator](https://our.internmc.facebook.com/intern/diff/D130297467/)!
Gasoonjia added a commit that referenced this pull request Nov 19, 2026
…t can run it (#25244)

Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0)
(oldest at bottom):
* #25248
* #25247
* #25246
* #25245
* __->__ #25244
* #25243
* #25242
* #25241
* #25240
* #25239
* #25238
* #25237
* #25236

A planner of the Triton replacement pass classified each call as
required, optional or unsupported. The three routes encode one question
indirectly: which implementations, the regular lowering (Inductor) or
the family's replacement, can run the call, and which one is preferred.
The next change needs that list explicitly, to pick among
implementations by measuring them.

This diff replaces the routes with candidates. A planner returns a
`ReplacementPlan` listing the regular lowering and the replacement, each
with the reason it cannot run the call (None if it can), plus its static
choice and the reason for it. The pass fails the export with every
reason when no candidate can run the call, uses the only one that can,
and otherwise takes the static choice. A failed rewrite keeps the node
if the regular lowering can run it and raises otherwise, as before. A
plan is validated when built: it lists the regular lowering and one
differently named replacement, a replacement that can run the call
carries its kernel and arguments, and the static choice must be a legal
candidate. The conv planner is converted with its decisions unchanged
(`regular_lowering_gap` marks the regular lowering unavailable;
`worth_routing` makes the static choice), except that a convolution
nothing can run now fails at the replacement pass with both reasons
instead of later in the AOTI compile.

Tests cover each candidate combination, plan validation and the failure
contract; the conv routing tests now assert the candidates.

This diff was authored with Claude Code.

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

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or
comments, please review them on
[Phabricator](https://our.internmc.facebook.com/intern/diff/D130871520/)!
@Gasoonjia
Gasoonjia merged commit 1ad391b into gh/Gasoonjia/128/base Nov 19, 2026
@Gasoonjia
Gasoonjia deleted the gh/Gasoonjia/128/head branch November 19, 2026 06:42
Gasoonjia added a commit that referenced this pull request Nov 19, 2026
…ating them by the static range (#25246)

Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0)
(oldest at bottom):
* #25248
* #25247
* __->__ #25246
* #25245
* #25244
* #25243
* #25242
* #25241
* #25240
* #25239
* #25238
* #25237
* #25236

A convolution that both Inductor and a `triton::convolution` template
can run is routed to our kernel only where a template's `worth_routing`
accepts it. Those ranges were benchmarked on one GPU and are approximate
on the GPU a model is exported on: they miss calls our kernels win and
keep some they lose.

With this diff the conv planner opts in to measured routing
(`measure=True`). With the `measured_routing` compile spec at its
default (ON), every convolution both can run is measured on the export
GPU and our kernel is kept only where it is faster by the margin;
`worth_routing` remains the static choice, which decides with
measurement OFF (the previous routing), for an unmeasurable call, or in
a process that cannot load modules compiled with Inductor's C++ wrapper.
`regular_lowering_gap` keeps marking the calls Inductor cannot compile,
which use our kernel without measurement, and the measurement's probe
catches a gap the rule misses. A conv1d is measured as the 2-D
convolution the backend hands Inductor.

Tests that export convolutions to check numerics or static routing now
use a shared helper that turns measurement OFF. New tests cover the
planner's candidates with measurement on, and the measured-routing
test's real export now goes through the conv family's own plans with the
static gap rule turned off: its convolution is a conv1d, measured
through its 2-D decomposition, and the probe finds the gap of the
same-padded one.

This diff was authored with Claude Code.

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

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or
comments, please review them on
[Phabricator](https://our.internmc.facebook.com/intern/diff/D130891424/)!
Gasoonjia added a commit that referenced this pull request Nov 19, 2026
…asuring them (#25247)

Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0)
(oldest at bottom):
* #25248
* __->__ #25247
* #25246
* #25245
* #25244
* #25243
* #25242
* #25241
* #25240
* #25239
* #25238
* #25237
* #25236

Measured routing measures each uncached call in a worker process, one at
a time, and most of that time is compiling: Inductor's template choices
and every config the replacement's autotune tries. For a model with many
distinct convolutions this adds up to tens of minutes.

With this diff the worker first compiles the calls in parallel
processes, largest first (`measured_routing_workers` compile spec,
default 8, 0 to skip). Each runs one call's replacement once and
compiles its regular lowering with the C++ wrapper, under the export's
precision settings. These processes only fill the Triton and Inductor
compile caches: they publish no result and write no autotune timings.
They start alongside the worker's check that it can measure and are
killed if it cannot. A warm-up process that fails or cannot start only
costs time, and each is watched for progress like the worker. The
measurement then runs exactly as before and finds the kernels compiled.

Tests cover the order and process count, skipping, the precision state,
a worker that cannot measure, a warm-up that cannot start, no autotune
timings written, identical results with and without the warm-up, and
real warm-ups in the probe test.

This diff was authored with Claude Code.

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

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or
comments, please review them on
[Phabricator](https://our.internmc.facebook.com/intern/diff/D131005737/)!
Gasoonjia added a commit that referenced this pull request Nov 19, 2026
… table (#25248)

Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0)
(oldest at bottom):
* __->__ #25248
* #25247
* #25246
* #25245
* #25244
* #25243
* #25242
* #25241
* #25240
* #25239
* #25238
* #25237
* #25236

The convolution overloads the CUDA backend routes were listed twice:
`CONV_OVERLOADS` (schema name and overload to spatial rank), which
`bind_conv` binds, and `CONV_TARGETS` in the replacement pass, the edge
ops the pass hands to the conv planner. An overload added to one but not
the other would be planned but not bindable, or bindable but never
planned.

This diff keeps the table as the only definition and derives the edge
ops from it in the conv planner's module; the replacement pass registers
those. Behavior is unchanged: the derived ops are the same ten, in the
same order.

A test checks that the planned ops are exactly the table's overloads and
that each goes to the conv planner.

This diff was authored with Claude Code.

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

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

This branch had an error being deployed

1 failed and 2 inactive deployments
cherry-pick-bot — 71e6f597 Deployed Nov 19, 2026 by Gasoonjia
upload-benchmark-results — 71e6f597 Deployed Nov 18, 2026 by Gasoonjia
cadence — 71e6f597 Deployed Nov 18, 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. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants