[ONNX] Skip affected models on torch 2.13 (two dynamo regressions) (#48191)
* [ONNX] Skip affected models on torch >= 2.13 (two dynamo ONNX regressions)
torch 2.13.0 introduced two regressions in dynamo ONNX export:
- pytorch/pytorch#194381: aten.sub type-promotion failure for scalar - int_tensor
- pytorch/pytorch#194382: aten.mul.Scalar missing ONNX decomposition
Skip all 35 affected model classes under `EXPORT_SKIPS["onnx"]` when
torch >= 2.13, using the existing skip infrastructure. Will be removed
once the upstream PyTorch fixes land.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* Scope ONNX skip to torch == 2.13.x only (auto-runs on 2.14+)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* Add missing BigBird subclasses to torch 2.13 ONNX skip list
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* [ONNX] Clarify skip guard is torch == 2.13.x only (not >=)
Update comment and skip reason strings to say `torch == 2.13` instead of
`torch >= 2.13`, making it clear the guard auto-lifts on 2.14+.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* [ONNX] Fix the torch 2.13 scalar regressions instead of skipping the models
Both regressions are a Python float meeting an integral tensor, whose promotion
torch 2.13 mishandles: `1.0 - int_mask` crashes the decomposition pass
(pytorch/pytorch#194381) and `int_mask * 2.0` reaches translation with no
registered ONNX decomposition (pytorch/pytorch#194382). On the same torch,
`1.0 - float_tensor` and `float_tensor * 2.0` export fine — so promoting the
tensor operand up front, to the dtype the op already produces, is enough. The
op and its overload are left alone, and the inserted cast carries the op's own
`meta` because for these elementwise cases it is the same value.
Decomposition also emits `mul.Scalar` with a *symbolic* second operand (a
division result, not a literal). There is no constant to promote there, so that
one is rewritten to `mul.Tensor`, which has the two-operand translation — the
same rewrite `_fix_remainder_scalar` makes for the same reason. Reachable
because the FX fixes run again right after `run_decompositions`.
This drops the 39 skip entries: the 15 affected families export again on 2.13,
including the vision models (Sam, SamHQ, GotOcr2, GroundingDino, SegGpt,
EfficientLoFTR, DeepseekOcr2).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* Resolve the promoted-op set on first use, not at import
`exporter_onnx` is importable without torch — the CI job that imports transformers
with PIL only proved this the hard way — and naming `torch.ops.aten.*` overloads in
a module-level frozenset broke that with a `NameError` before anything ran.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* Say what the `mul.Scalar` operand is, and check it
Review raised two things. The `Node` check assumed a tensor operand: it is never one. Across the affected
families all 33 sites are an `operator.truediv` result, i.e. a `SymFloat`, which `mul.Tensor`'s translation
does take — so the rewrite stands, but the guard now names the forms that op accepts instead of trusting
the node type, and anything else keeps the `mul.Scalar` overload and fails visibly in translation.
The fixes are also deliberately not version-gated, which the docstring implied they were. Both rewrites
are semantics-preserving on any torch — a cast to the dtype the op already produces, and an overload swap
with the same meaning — so gating would only decide which torch exercises the path.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: IlyasMoutawwakil <moutawwakil.ilyas.tsi@gmail.com>
Co-authored-by: Ilyas Moutawwakil <57442720+IlyasMoutawwakil@users.noreply.github.com>