Skip to content

Fold batch norms into aten.convolution in prepare_pt2e (#5102) - #5102

Merged
vkuzo merged 1 commit into
mainfrom
export-D131429944
Nov 17, 2026
Merged

vkuzo merged 1 commit into
mainfrom
export-D131429944

Conversation

@mcremon-meta

@mcremon-meta mcremon-meta commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

prepare_pt2e folds a batch norm into the conv before it, but only recognizes
conv1d, conv2d, conv3d and conv_transpose*. A model decomposed to core
ATen before prepare_pt2e has aten.convolution there instead, which they
decompose to, so its batch norms are left unfolded.

_get_conv_bn_fusion_nodes now uses _is_aten_or_core_aten_bn_foldable_conv_node,
which also accepts a non-transposed aten.convolution, directly or through the
same contiguous/clone and non-channel slice it already handles. A transposed one
is left alone: fold_bn_weights_into_conv_node tells a transposed conv by its
op, so it would scale its weight along the wrong dim.

The change is limited to the PTQ fold. _is_conv_node is unchanged: quantizers
use it to pick the convs they annotate (e.g. XNNPACK's _do_annotate_conv),
and the QAT conv-bn fusion uses it too, which doesn't support core ATen.

The QAT fusion matches patterns traced from F.conv*, so it never matched a
decomposed conv, and prepare_qat_pt2e silently left its batch norm unfused.
_fuse_conv_bn_qat now warns when an aten.convolution feeds a batch norm.
After run_decompositions() a batch norm is _native_batch_norm_legit_functional
in train mode, _native_batch_norm_legit_no_training in eval mode and
_native_batch_norm_legit.no_stats with track_running_stats=False, and the
warning covers all three. A decomposed conv without a batch norm doesn't warn.

Reviewed By: ethansfng

Differential Revision: D131429944

@pytorch-bot

pytorch-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/5102

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 ff814ee with merge base 4ab9d61 (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.

@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 12, 2026
@meta-codesync

meta-codesync Bot commented Nov 12, 2026

Copy link
Copy Markdown

@mcremon-meta has exported this pull request. If you are a Meta employee, you can view the originating Diff in D131429944.

@vkuzo

vkuzo commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

@claude review and also explain

@claude

claude Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Claude finished @vkuzo's task in 1m 26s —— View job


PR #5102 review: fold batch norms into aten.convolution in prepare_pt2e

  • Read the diff and the code around it (fold_bn_weights_into_conv_node, _fuse_conv_bn_, get_arg)
  • Explain the change
  • Review for correctness and edge cases
  • Run tests: not done. The sandbox denied permission to run pytest, so the findings below come from reading the code only.

What the PR does

prepare_pt2e calls _fuse_conv_bn_ (quantize_pt2e.py:128). It looks for each batch norm node, finds the conv that feeds it, and folds the BN statistics into that conv's weight and bias. It then deletes the BN node.

Before this PR, the conv was only recognized if its target was one of the ops in _is_conv_node or _is_conv_transpose_node: aten.conv{1,2,3}d.* and aten.conv_transpose{1,2,3}d.*. Those are what torch.export produces by default. If a model is lowered further, e.g. with ep.run_decompositions() to core ATen, all of those become a single op, aten.convolution.default(input, weight, bias, stride, padding, dilation, transposed, output_padding, groups). The matcher didn't recognize that op, so the BN stayed in the graph unfolded. This happens in ExecuTorch-style flows that decompose before quantizing.

The fix:

  1. New predicate _is_bn_foldable_conv_node (utils.py:698-711). It accepts what was accepted before, plus aten.convolution.default when transposed=False.
  2. _get_conv_bn_fusion_nodes now uses that predicate in both places it checks for a conv:
    • the direct conv -> bn case (:991);
    • the conv -> slice(non-channel dim) -> [contiguous|clone] -> bn case (:1008), which covers patterns like trimming causal-conv padding.
  3. _is_conv_node is deliberately unchanged. Quantizers call it to decide which convs to annotate. If it matched aten.convolution, it would also match transposed convs and change annotation behavior. That would be a much wider change than this PR intends.

The rest of the fold already works for aten.convolution:

  • Bias: in aten.convolution the bias is always at positional index 2 (it can be None). So conv_node.args[2] at :1035 and conv_args[2] = get_bias_node at :805 are correct, including when bias is None (the test's conv2d_without_bias case).
  • Weight scaling: transpose = _is_conv_transpose_node(conv_node) returns False for aten.convolution. That is the right value, because only non-transposed convs get through. fuse_conv_bn_weights then scales weight dim 0 (output channels), which is also correct for grouped convs.

Review

Overall the change is small and well scoped, and the reasoning in the PR summary about leaving _is_conv_node alone is sound. A few points:

1. get_arg(..., bool) can raise inside a predicate (minor robustness issue). utils.py:710
get_arg raises RuntimeError if the arguments can't be normalized, and TypeError if transposed isn't a Python bool. Before this PR, an odd node like that was simply not matched. Now it would crash prepare_pt2e. Realistically transposed is always a literal bool after export, so this is low risk. Still, a matcher should return False rather than throw. transposed is a required positional argument (index 6) in aten.convolution, so a cheaper, non-throwing version would be:

return (
    n.op == "call_function"
    and n.target == torch.ops.aten.convolution.default
    and n.args[6] is False
)

(Use get_arg with a try/except if you want to be safe against kwargs.)

2. Transposed aten.convolution isn't folded, unlike aten.conv_transpose*d (asymmetry, fine for now).
A non-decomposed ConvTranspose2d -> BN gets folded; the same model after decomposition does not. Supporting it would mainly need fold_bn_weights_into_conv_node (:746) to read transposed from the node instead of relying on _is_conv_transpose_node. I think leaving it out is the safer choice. With transpose=True, fuse_conv_bn_weights reshapes the scale along weight dim 1. For groups > 1 that dim is out_channels / groups, so I don't think it broadcasts correctly. If so, extending this path would expose that grouped-transpose problem in a new place. The new test (test_conv_transpose_bn_fusion_after_decomposition_is_skipped) pins the current behavior, which is good. A short comment saying why transposed is skipped would help the next reader.

3. The tests use XNNPACKQuantizer, which won't annotate the decomposed conv.
Because _is_conv_node is unchanged, XNNPACK leaves aten.convolution unannotated. The tests therefore check the fold (BN gone, outputs match) and say nothing about quantization. That is fine for what's being tested. A no-op quantizer would make the intent clearer and keep the test independent of XNNPACK's annotation rules. Optional.

4. Test quality is good.

  • running_mean and running_var are set to non-trivial values, so a no-op fold would fail assert_close.
  • The test asserts aten.convolution is actually present after run_decompositions(), so the test can't silently pass on the old op.
  • It covers 1d, 2d and 3d, no bias, and the spatial-slice path.

One small gap: the slice test only covers a negative dim ([..., :-4] → dim=-1). The positive-dim branch of _is_non_channel_slice_node already has coverage elsewhere, so this isn't blocking.

5. Docstring nit. utils.py:699-704: "an aten conv or conv transpose op, or the non-transposed aten.convolution that conv1d, conv2d and conv3d decompose to…" is a bit hard to parse. Something like "conv{1,2,3}d / conv_transpose{1,2,3}d, or a non-transposed aten.convolution (what conv{1,2,3}d become after core-ATen decomposition)" reads better.

CI

The only failure not explained by trunk is PR Label Check: the PR needs a module:* label (probably module: pt2e_quant or similar). The other failures also fail on the merge base.

Verdict

The approach is correct, and I found no bugs in the new path. Item 1 is a small robustness improvement worth making. Items 2 to 5 are optional.

@jerryzh168

jerryzh168 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

when do you run decomposition before prepare_pt2e? we expect quantizer to use non decomposed aten IR I think: https://docs.pytorch.org/ao/stable/pt2e_quantization/pt2e_quantizer.html#a-note-on-ir-for-pt2e-quantization-flow

@mcremon-meta

Copy link
Copy Markdown
Contributor Author

when do you run decomposition before prepare_pt2e? we expect quantizer to use non decomposed aten IR I think: https://docs.pytorch.org/ao/stable/pt2e_quantization/pt2e_quantizer.html#a-note-on-ir-for-pt2e-quantization-flow

we run decompositions at the export stage in a few of our flows, and keep some operators from being decomposed. That's very useful for the quantizer, it allows to cap the number of ops we can see to core aten + whatever we decide to retain

@jerryzh168

Copy link
Copy Markdown
Contributor

OK, @claude is it better to implement this in pt2e core flow or backend specific quantizer through

def transform_for_annotation(
?

@claude

claude Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Claude finished @jerryzh168's task in 46s —— View job


Core pt2e flow or Quantizer.transform_for_annotation?

  • Read prepare_pt2e, prepare_qat_pt2e, Quantizer.transform_for_annotation and the PR's changes to utils.py
  • Compare the two options

Recommendation: keep it in core, as this PR does. If maintainers would rather not support core-ATen input in core, transform_for_annotation does work as a fallback. Reasons below.

How the flow is ordered today

In prepare_pt2e (quantize_pt2e.py:128-130) the steps run in this order:

_fuse_conv_bn_(model)          # core fold
_fuse_linear_bn_(model)
model = quantizer.transform_for_annotation(model)
quantizer.annotate(model)

The BN fold already runs in core, for every backend, before the quantizer gets the graph. So the question isn't really "core or backend". It's whether the existing core fold should accept one more spelling of conv.

Reasons to keep it in core

  1. It isn't backend-specific. Folding BN into the conv before it is the same math for every backend, and it doesn't change numerics. It doesn't depend on which ops a backend can quantize, which is what transform_for_annotation is meant for (its docstring gives decomposing SDPA and turning scalars into tensors as examples).
  2. A backend version would copy core code. _get_conv_bn_fusion_nodes, the slice/contiguous/clone handling, and fold_bn_weights_into_conv_node would all need to be copied, or reached through private _-prefixed helpers. Every quantizer that decomposes before quantizing (Cadence, other ExecuTorch backends, ...) would then need its own copy.
  3. The change is small. It only widens a matcher. _is_conv_node, and so how quantizers annotate, is unchanged. For graphs that use conv{1,2,3}d, nothing changes.

Reasons for the backend route

  1. The documented IR contract. The IR note says pt2e expects non-decomposed ATen. Accepting aten.convolution in one core pass is a step toward supporting core ATen, and that support would be partial:
    • QAT is still not covered. prepare_qat_pt2e calls _fuse_conv_bn_qat (quantize_pt2e.py:236), which matches patterns traced from F.conv2d/F.conv_transpose2d (qat_utils.py:664,670). A decomposed graph won't match them, so after this PR, PTQ folds BN for decomposed models but QAT does not.
    • _is_conv_node and the built-in quantizers' annotators still only recognize conv{1,2,3}d.
  2. It can be done without core changes. transform_for_annotation runs after the core fold, so a quantizer can fold BN itself there. For decomposed graphs the core fold doesn't match anything, so the two can't conflict.

Summary

Core (this PR) transform_for_annotation
Duplicated code none each decomposing backend copies the fold or calls private helpers
IR contract slightly widens what core accepts unchanged
QAT parity PTQ only, QAT still misses it the backend does whatever it needs
Risk to existing users ~none (only adds a match) none

Core is the better place, for two reasons: the fold is backend-agnostic, and core already does it. Decomposing before prepare_pt2e is a real pattern in ExecuTorch flows, as @mcremon-meta described. If this lands in core, I'd suggest two follow-ups:

  • Add a short note to the docstring or the IR docs saying that aten.convolution is accepted by the BN fold only, so nobody reads it as full core-ATen support.
  • Either open an issue for the QAT gap (_fuse_conv_bn_qat) or state in the PR that only PTQ is covered.

If maintainers want to keep core strictly on pre-dispatch ATen, the fallback is to move this into the decomposing backend's transform_for_annotation. Ideally _fuse_conv_bn_ would also gain a public way to pass in a conv predicate, so backends don't have to copy the matching code.

@mcremon-meta

Copy link
Copy Markdown
Contributor Author

@jerryzh168 yes I opened this PR trying to avoid putting it in transform_for_annotation everywhere, exactly because we know there is already a conv bn folding before that and it runs unconditionally

@jerryzh168

Copy link
Copy Markdown
Contributor

@mcremon-meta running conv bn folding by default is not what we want in core I think, but we didn't give a lot of thought to this at the time and there doesn't seem to be a strong enough motivation to separate it out. I also have seen people complaining about it but don't remember what is the resolution for that.

But given the PR seems low risk I think it's fine to land. it's easy to change in the future as well if we want a different design. For QAT I think it does not support decomposed ops anyways, so it is better to not support convolution, maybe we should make sure there is a check for that in fold conv bn for QAT and error out is convolution op is detected. cc @claude can you double check that?

@claude

claude Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Claude finished @jerryzh168's task in 1m 16s —— View job


Does QAT conv-BN fusion reject aten.convolution?

  • Read _fuse_conv_bn_qat / _fold_conv_bn_qat in qat_utils.py and prepare_qat_pt2e / convert_pt2e
  • Check what a decomposed graph (aten.convolution) does in the QAT path
  • Run it: not done. The sandbox wouldn't let me write or run a repro script, so all of this comes from reading the code.

Short answer: No. Nothing checks for this today, so a decomposed graph doesn't raise an error in QAT. The conv-BN fuse is silently skipped, BN stays a separate op during training, and BN is not folded at convert. This PR doesn't change that, because the QAT path never calls the function the PR edits.

Details

1. This PR doesn't touch QAT.
_get_conv_bn_fusion_nodes / _is_bn_foldable_conv_node are only reached through _fuse_conv_bn_, and only prepare_pt2e calls that (quantize_pt2e.py:128). prepare_qat_pt2e calls _fuse_conv_bn_qat (:236), and convert_pt2e calls _fold_conv_bn_qat (:515). Neither of those uses the PR's predicate.

2. QAT matching is pattern-based, so aten.convolution never matches.
_fuse_conv_bn_qat and _fold_conv_bn_qat build their match patterns by exporting F.conv1d/conv2d/conv_transpose1d/conv_transpose2d with torch.export.export(...).module(). They do not run decompositions on them (utils.py:1137). The patterns therefore contain aten.conv2d + aten.batch_norm. In a core-ATen graph:

  • replace_pattern_with_filters finds no matches in _fuse_conv_bn_qat_helper (qat_utils.py:711,728), so the step does nothing.
  • _fold_conv_bn_qat gets _has_pattern(m, conv_pattern) == False for every conv type and continues (qat_utils.py:954).

3. In train mode it skips even earlier.
A model in training mode, decomposed to core ATen, has aten._native_batch_norm_legit_functional as its BN op. That op isn't in _is_bn_node / _is_supported_batch_norm_for_training (utils.py:647-660, 727-731). So has_bn is False and both QAT functions return before trying to match anything (qat_utils.py:655-657, 935-937).

The result: a user who decomposes before prepare_qat_pt2e gets fake-quant on the conv weight, a BN that is never folded, and no warning. That fits your view that QAT doesn't support decomposed ops, but nothing enforces it today.

Suggested check (not implemented, since you asked me to verify only)

Add an explicit error in _fuse_conv_bn_qat, before the has_bn early return. It should look for decomposed BN ops as well, because of point 3. To avoid breaking QAT models that use aten.convolution with no BN after it, only raise when a BN actually follows the conv:

# qat_utils.py, at the top of _fuse_conv_bn_qat
_DECOMPOSED_BN_OPS = (
    torch.ops.aten._native_batch_norm_legit_functional.default,
    torch.ops.aten._native_batch_norm_legit_no_training.default,
)
for n in m.graph.nodes:
    if (
        n.op == "call_function"
        and n.target == torch.ops.aten.convolution.default
        and any(_is_bn_node(u) or u.target in _DECOMPOSED_BN_OPS for u in n.users)
    ):
        raise ValueError(
            "prepare_qat_pt2e does not support conv-bn fusion on graphs decomposed "
            "to core ATen (found aten.convolution followed by batch norm). Run "
            "prepare_qat_pt2e on the graph before run_decompositions()."
        )

Notes on this sketch:

  • It covers the direct conv -> bn case. If you also want to catch the slice/contiguous/clone variants the PTQ fold handles, walk through those ops the same way _get_conv_bn_fusion_nodes does.
  • Putting it in _fuse_conv_bn_qat (prepare time) is enough. _fold_conv_bn_qat only runs on graphs that went through prepare_qat_pt2e, so it doesn't need its own check.
  • This would ideally ship with a small test: export, run_decompositions(), then prepare_qat_pt2e with assertRaises. That test could go in this PR or a follow-up.

Fix this →

@mcremon-meta mcremon-meta added the module: pt2e_quant pt2 export quantization (prepare_pt2e, convert_pt2e, quantizer) label Nov 13, 2026


def _is_bn_foldable_conv_node(n: Node) -> bool:
"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a comment to explain why we don't extend _is_conv_node is because _is_conv_or_conv_transpose_node is used by qat path

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also current naming is not very descriptive of the situation I feel, maybe:

_is_aten_or_core_aten_bn_foldable_conv_node

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

core aten is aten, right? I'm not against doing that, but it feels like it's a bit much. Up to you!

@jerryzh168 jerryzh168 Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

core aten IR and aten IR are two different IRs I think, only aten IR support training I believe

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, in the end I don't have a preference on the name. Whatever will get this landed is fine with me :)

@meta-codesync meta-codesync Bot changed the title Fold batch norms into aten.convolution in prepare_pt2e Fold batch norms into aten.convolution in prepare_pt2e (#5102) Nov 13, 2026
meta-codesync Bot pushed a commit that referenced this pull request Nov 13, 2026
Summary:

`prepare_pt2e` folds a batch norm into the conv before it, but only recognizes
`conv1d`, `conv2d`, `conv3d` and `conv_transpose*`. A model decomposed to core
ATen before `prepare_pt2e` has `aten.convolution` there instead, which they
decompose to, so its batch norms are left unfolded.

`_get_conv_bn_fusion_nodes` now also accepts a non-transposed
`aten.convolution`, directly or through the same contiguous/clone and
non-channel slice it already handles. A transposed one is left alone.

The change is limited to the fold. `_is_conv_node` is unchanged: quantizers
use it to pick the convs they annotate (e.g. XNNPACK's `_do_annotate_conv`),
and matching `aten.convolution` there would include transposed ones.

Reviewed By: ethansfng

Differential Revision: D131429944
Comment thread torchao/quantization/pt2e/qat_utils.py Outdated
)

# The patterns below can't match a decomposed conv and would leave its BN unfused.
functional_bn = torch.ops.aten._native_batch_norm_legit_functional.default

@jerryzh168 jerryzh168 Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to confirm, is this only the bn op in core aten IR (after run_decomposition)? cc @claude please confirm

Comment thread torchao/quantization/pt2e/qat_utils.py Outdated
):
for user in conv_node.users:
if _is_bn_node(user) or user.target == functional_bn:
raise ValueError(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think warning is enough

meta-codesync Bot pushed a commit that referenced this pull request Nov 16, 2026
Summary:

`prepare_pt2e` folds a batch norm into the conv before it, but only recognizes
`conv1d`, `conv2d`, `conv3d` and `conv_transpose*`. A model decomposed to core
ATen before `prepare_pt2e` has `aten.convolution` there instead, which they
decompose to, so its batch norms are left unfolded.

`_get_conv_bn_fusion_nodes` now uses `_is_aten_or_core_aten_bn_foldable_conv_node`,
which also accepts a non-transposed `aten.convolution`, directly or through the
same contiguous/clone and non-channel slice it already handles. A transposed one
is left alone: `fold_bn_weights_into_conv_node` tells a transposed conv by its
op, so it would scale its weight along the wrong dim.

The change is limited to the PTQ fold. `_is_conv_node` is unchanged: quantizers
use it to pick the convs they annotate (e.g. XNNPACK's `_do_annotate_conv`),
and the QAT conv-bn fusion uses it too, which doesn't support core ATen.

The QAT fusion matches patterns traced from `F.conv*`, so it never matched a
decomposed conv, and `prepare_qat_pt2e` silently left its batch norm unfused.
`_fuse_conv_bn_qat` now warns when an `aten.convolution` feeds a batch norm.
After `run_decompositions()` a batch norm is `_native_batch_norm_legit_functional`
in train mode, `_native_batch_norm_legit_no_training` in eval mode and
`_native_batch_norm_legit.no_stats` with `track_running_stats=False`, and the
warning covers all three. A decomposed conv without a batch norm doesn't warn.

Reviewed By: ethansfng

Differential Revision: D131429944
Summary:

`prepare_pt2e` folds a batch norm into the conv before it, but only recognizes
`conv1d`, `conv2d`, `conv3d` and `conv_transpose*`. A model decomposed to core
ATen before `prepare_pt2e` has `aten.convolution` there instead, which they
decompose to, so its batch norms are left unfolded.

`_get_conv_bn_fusion_nodes` now uses `_is_aten_or_core_aten_bn_foldable_conv_node`,
which also accepts a non-transposed `aten.convolution`, directly or through the
same contiguous/clone and non-channel slice it already handles. A transposed one
is left alone: `fold_bn_weights_into_conv_node` tells a transposed conv by its
op, so it would scale its weight along the wrong dim.

The change is limited to the PTQ fold. `_is_conv_node` is unchanged: quantizers
use it to pick the convs they annotate (e.g. XNNPACK's `_do_annotate_conv`),
and the QAT conv-bn fusion uses it too, which doesn't support core ATen.

The QAT fusion matches patterns traced from `F.conv*`, so it never matched a
decomposed conv, and `prepare_qat_pt2e` silently left its batch norm unfused.
`_fuse_conv_bn_qat` now warns when an `aten.convolution` feeds a batch norm.
After `run_decompositions()` a batch norm is `_native_batch_norm_legit_functional`
in train mode, `_native_batch_norm_legit_no_training` in eval mode and
`_native_batch_norm_legit.no_stats` with `track_running_stats=False`, and the
warning covers all three. A decomposed conv without a batch norm doesn't warn.

Reviewed By: ethansfng

Differential Revision: D131429944
@mcremon-meta

Copy link
Copy Markdown
Contributor Author

@jerryzh168 just pushed a new version, let me know if it looks good to you!

@jerryzh168 jerryzh168 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! lgtm

@vkuzo
vkuzo merged commit 3f5febc into main Nov 17, 2026
meta-codesync Bot pushed a commit to pytorch/executorch that referenced this pull request Nov 18, 2026
Summary:
Advance `TORCHAO_NIGHTLY_VERSION` and `CU134_TORCHAO_NIGHTLY_VERSION` from `0.19.0.dev20261103` to `0.19.0.dev20261118` and align `third-party/ao` with the nightly's source commit, `3f5febc5c6c0cd87e606c26fd41dade1a963d967`. This includes pytorch/ao#5102, allowing `prepare_pt2e` to fold batch norms into `aten.convolution` after decomposition to core ATen. The existing `setup.py` dependency bound derives from these constants and advances automatically to `torchao>=0.19.0.dev20261118,<0.20`.

The selected nightly is published for CPU, CUDA 13.2 and CUDA 13.4. CUDA 13.0's newest published nightly remains `0.19.0.dev20261103`, so fresh CUDA 13.0 installs cannot resolve this new pin from that channel. This limitation needs resolution before landing.

This change was authored with Claude Code.

Differential Revision: D132976839

Pull Request resolved: #25223
Gasoonjia added a commit to pytorch/executorch that referenced this pull request Nov 18, 2026
#25223 (164233d) advanced `TORCHAO_NIGHTLY_VERSION` to
`0.19.0.dev20261118`, but the newest TorchAO nightly on the `cu130`
channel is `0.19.0.dev20261103`. Every CUDA 13.0 job has failed to
install since then:

```
ERROR: No matching distribution found for torchao==0.19.0.dev20261118
```

(CUDA 13.4 jobs, e.g. `test-executorch-cuda-build-13.4`, still pass.)

This adds `CU130_TORCHAO_NIGHTLY_VERSION = "0.19.0.dev20261103"` and
returns it from `get_torchao_version` for the `/cu130` URL, unless
torchao is built from source. `setup.py` gets the torchao bound from
`get_torchao_version`, so the wheel metadata changes with it. CPU, CUDA
13.2 and CUDA 13.4 stay on `dev20261118`. `update_pytorch_pin.py`
already matches `CU\d+_TORCHAO_NIGHTLY_VERSION`, so later pin bumps
update the new constant too.

Note: CUDA 13.0 won't get pytorch/ao#5102 (batch norm folding into
`aten.convolution`) until the cu130 channel publishes again.

## Test plan
`python -m pytest .ci/scripts/tests/test_cu134_dependencies.py
.ci/scripts/tests/test_cuda_workflow.py` passed (23 tests). Both tests
now cover CUDA 13.0 explicitly. CUDA CI on this PR is the real check.
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 module: pt2e_quant pt2 export quantization (prepare_pt2e, convert_pt2e, quantizer)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants