Skip to content

Arm backend: Guard argmax and argmin int32 propagation - #22144

Merged
mansnils merged 2 commits into
pytorch:mainfrom
mansnils:arm_backend_ops
Aug 27, 2026
Merged

Arm backend: Guard argmax and argmin int32 propagation#22144
mansnils merged 2 commits into
pytorch:mainfrom
mansnils:arm_backend_ops

Conversation

@mansnils

@mansnils mansnils commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Previously, once an argmax or argmin index fit int32, the pass sent every consumer through the int32 path. Later arithmetic could then overflow even though the raw index itself was safe.

Keep unsafe direct consumers on the original int64 value. When a safe int32 prefix reaches an unsafe consumer, insert an int64 boundary. This allows preceding safe operations to remain delegatable while keeping calculations correct and model output dtypes unchanged.

Cover safe and overflowing paths in both ATen and Edge graphs.

cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @Sebastian-Larsson @robell @rascani

Previously, once an argmax or argmin index fit int32, the pass sent
every consumer through the int32 path. Later arithmetic could then
overflow even though the raw index itself was safe.

Keep unsafe direct consumers on the original int64 value. When a safe
int32 prefix reaches an unsafe consumer, insert an int64 boundary.
This allows preceding safe operations to remain delegatable while
keeping calculations correct and model output dtypes unchanged.

Cover safe and overflowing paths in both ATen and Edge graphs.

Signed-off-by: Måns Nilsson <mans.nilsson@arm.com>
Change-Id: I6849f1e33e17ab9661cf25002923e180755e0a46
@mansnils
mansnils requested a review from digantdesai as a code owner August 25, 2026 12:58
@mansnils mansnils added partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm ciflow/trunk module: arm Issues related to arm backend labels Aug 25, 2026
@pytorch-bot

pytorch-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 7105b90 with merge base cbcdfc1 (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 Aug 25, 2026
@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.

@zingo

zingo commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Oh no, Ill try a re-run

FAILED backends/arm/test/models/stable_diffusion/test_CLIPTextModelWithProjection.py::test_clip_text_with_projection_tosa_FP - RuntimeError: Expected to find "executorch_exir_dialects_edge__ops_dim_order_ops__to_dim_order_copy_default" but did not find it
Searched string:
    lowered_module_0 = self.lowered_module_0
    executorch_call_delegate = torch.ops.higher_order.executorch_call_delegate(lowered_module_0);  lowered_module_0 = None
    dim_order_ops__to_dim_order_copy_default_2 = executorch_exir_dialects_edge__ops_dim_order_ops__to_dim_order_copy_default(input_ids, dtype = torch.int32);  input_ids = None
From CHECK-COUNT-2: executorch_exir_dialects_edge__ops_dim_order_ops__to_dim_order_copy_default
FAILED backends/arm/test/models/stable_diffusion/test_CLIPTextModelWithProjection.py::test_clip_text_with_projection_tosa_INT - RuntimeError: Expected to find "executorch_exir_dialects_edge__ops_dim_order_ops__to_dim_order_copy_default" but did not find it
Searched string:

def forward(self, input_ids):
    dim_order_ops__to_dim_order_copy_default = executorch_exir_dialects_edge__ops_dim_order_ops__to_dim_order_copy_default(input_ids, dtype = torch.int32, dim_order = [0, 1]);  input_ids = None
    lowered_module_0 = self.lowered_module_0
    executorch_call_delegate = torch.ops.higher_order.executorch_call_delegate(lowered_module_0, dim_order_ops__to_dim_order_copy_default);  lowered_module_0 = dim_order_ops__to_dim_order_copy_default = None
From CHECK-COUNT-2: executorch_exir_dialects_edge__ops_dim_order_ops__to_dim_order_copy_default
= 2 failed, 189 passed, 18 skipped, 7 xfailed, 903 warnings, 4 rerun in 3255.68s (0:54:15) =

Signed-off-by: Måns Nilsson <mans.nilsson@arm.com>
Change-Id: I4cafb654c315f77dab4b80a20de669cb0c161610
@mansnils
mansnils merged commit 67ee0ae into pytorch:main Aug 27, 2026
505 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: arm Issues related to arm backend partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants