Skip to content

Arm backend: Quantize argmax input so float logits lower to TOSA ARGMAX - #24394

Open
pcwilk wants to merge 1 commit into
pytorch:mainfrom
pcwilk:arm-quantize-argmax-input
Open

pcwilk wants to merge 1 commit into
pytorch:mainfrom
pcwilk:arm-quantize-argmax-input

Conversation

@pcwilk

@pcwilk pcwilk commented Oct 31, 2026 •

Copy link
Copy Markdown

Summary

The Arm quantizer never annotated aten.argmax, so an argmax fed by a float tensor, or by a dequantized producer such as a quantized linear head, stayed in fp32 and the INT-profile partitioner rejected it with "TOSA ARGMAX requires PRO-FP for torch.float32 input". In a logits → argmax → embedding chain this left the argmax on the CPU between two NPU delegates.

This change annotates only the argmax input (the TOSA ARGMAX output is int32 and carries no quantization) and lets the argmax support check look through a leading dequantize node, so it judges the dtype the folded graph will actually present. A Linear(64, 4096) → argmax → Embedding(4096, 64) model now lowers to a single Ethos-U85 command stream: NPU_OP_CONV, an ARGMAX_X pool over the 4096 logits, and a gather DMA, with zero CPU operators reported by Vela.

Suggested label: Release notes: arm.

Test plan

Two tests are added to backends/arm/test/ops/test_argmax.py: float input on the TOSA INT pipeline (asserting exactly one ARGMAX op), and the same through the Ethos-U85 flow up to the Vela compile.

lintrunner backends/arm/quantizer/quantizer_support.py backends/arm/operator_support/tosa_supported_operators.py backends/arm/test/ops/test_argmax.py
pytest -c backends/arm/test/pytest.ini backends/arm/test/ops/test_argmax.py

On an editable build of main at 05092c1 (torch 2.14.0+cpu, Vela 5.2.0): lint clean; 24 passed, 12 skipped (no model-converter for VGF), 3 xfailed (no Corstone-300 runner), 0 failed. The U85 subset was additionally run on the Corstone-320 FVP with the semihosting runner: 9 passed.

🤖 Generated with Claude Code

cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani @nil-is-all

The Arm quantizer never annotated aten.argmax, so an argmax fed by a
float tensor or by a dequantized producer stayed in fp32 and the INT
profile partitioner rejected it with "TOSA ARGMAX requires PRO-FP for
torch.float32 input". In a logits -> argmax -> embedding chain this
left the argmax on the CPU between two NPU delegates.

Annotate only the argmax input, since the TOSA ARGMAX output is int32
and carries no quantization, and let the argmax support check look
through a leading dequantize node so it judges the dtype the folded
graph will present. A Linear -> argmax -> Embedding model now lowers
to a single Ethos-U85 command stream: conv, ARGMAX_X pool, gather DMA.

Tests cover float input on the TOSA INT pipeline and on the Ethos-U85
flow up to the Vela compile.

Authored with assistance from Claude Code (Claude Fable 5.1).

Signed-off-by: Paul Wilk <paul@randomproc.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@pytorch-bot

pytorch-bot Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

⚠️ 1 Awaiting Approval, 6 Unrelated Failures

As of commit b5348f5 with merge base 05092c1 (image):

AWAITING APPROVAL - The following workflow needs approval before CI can run:

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.

@meta-cla

meta-cla Bot commented Oct 31, 2026

Copy link
Copy Markdown

Hi @pcwilk!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

One or more co-authors of this pull request were not found. You must specify co-authors in commit message trailer via:

Co-authored-by: name <email>

Supported Co-authored-by: formats include:

  1. Anything <id+login@users.noreply.github.com> - it will locate your GitHub user by id part.
  2. Anything <login@users.noreply.github.com> - it will locate your GitHub user by login part.
  3. Anything <public-email> - it will locate your GitHub user by public-email part. Note that this email must be made public on Github.
  4. Anything <other-email> - it will locate your GitHub user by other-email part but only if that email was used before for any other CLA as a main commit author.
  5. login <any-valid-email> - it will locate your GitHub user by login part, note that login part must be at least 3 characters long.

Alternatively, if the co-author should not be included, remove the Co-authored-by: line from the commit message.

Please update your commit message(s) by doing git commit --amend and then git push [--force] and then request re-running CLA check via commenting on this pull request:

/easycla

@github-actions github-actions Bot added ciflow/trunk module: arm Issues related to arm backend labels Oct 31, 2026
@pytorch-bot

pytorch-bot Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@pcwilk

pcwilk commented Oct 31, 2026

Copy link
Copy Markdown
Author

@pytorchbot label "release notes: arm"

@pytorch-bot pytorch-bot Bot added the release notes: arm Changes to the ARM backend delegate label Oct 31, 2026
@meta-cla

meta-cla Bot commented Oct 31, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@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 Oct 31, 2026
@executorch-triage executorch-triage Bot added the community: contribution PRs coming from community (excluding hardware partners) label Nov 1, 2026

This branch has not been deployed

No deployments
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. community: contribution PRs coming from community (excluding hardware partners) module: arm Issues related to arm backend release notes: arm Changes to the ARM backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant