Skip to content

Arm backend: Fix quantized constant-folding for aten.cat lists (#18971)#19064

Merged
perheld merged 1 commit intopytorch:mainfrom
perheld:change-1242954
Apr 23, 2026
Merged

Arm backend: Fix quantized constant-folding for aten.cat lists (#18971)#19064
perheld merged 1 commit intopytorch:mainfrom
perheld:change-1242954

Conversation

@perheld
Copy link
Copy Markdown
Collaborator

@perheld perheld commented Apr 23, 2026

FuseConstantArgsPass resolved input_qparams by flattened input-node index, while FoldAndAnnotateQParamsPass stores them by top-level argument index. For aten.cat with a list-valued tensor argument, this caused only the first tensor to be dequantized before folding, which corrupted the fused constant.

Resolve qparams by top-level argument index and propagate that qparam through nested list and tuple arguments. Add a regression test for quantized aten.cat constant folding with list-valued tensor inputs.

Change-Id: I6e1a012d82a5dbeecb403c440a2944953dd5cba7

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

…ch#18971)

FuseConstantArgsPass resolved input_qparams by flattened input-node
index, while FoldAndAnnotateQParamsPass stores them by top-level
argument index. For aten.cat with a list-valued tensor argument, this
caused only the first tensor to be dequantized before folding, which
corrupted the fused constant.

Resolve qparams by top-level argument index and propagate that qparam
through nested list and tuple arguments. Add a regression test for
quantized aten.cat constant folding with list-valued tensor inputs.

Signed-off-by: Per Held <per.held@arm.com>
Change-Id: I6e1a012d82a5dbeecb403c440a2944953dd5cba7
Copilot AI review requested due to automatic review settings April 23, 2026 11:28
@perheld perheld requested a review from digantdesai as a code owner April 23, 2026 11:28
@perheld perheld added partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm ciflow/trunk release notes: arm Changes to the ARM backend delegate labels Apr 23, 2026
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Apr 23, 2026

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 1 New Failure, 2 Cancelled Jobs, 3 Unrelated Failures

As of commit ca01b3e with merge base c48ea12 (image):

NEW FAILURE - The following job has failed:

CANCELLED JOBS - The following jobs were cancelled. Please retry:

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

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 Apr 23, 2026
@github-actions github-actions Bot added the module: arm Issues related to arm backend label Apr 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes Arm backend constant-folding for quantized ops by aligning how input_qparams are resolved with how they’re produced, specifically for ops like aten.cat where tensor inputs can be nested inside list/tuple arguments.

Changes:

  • Update FuseConstantArgsPass to resolve input_qparams by top-level positional argument index (and propagate that qparam through nested list/tuple args).
  • Add a regression test that constant-folds a quantized aten.cat whose tensor inputs are passed via a list/tuple.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
backends/arm/_passes/fuse_constant_ops_pass.py Fix qparam lookup to use top-level arg index and apply it to nested list/tuple tensor args during constant folding.
backends/arm/test/passes/test_fuse_constant_ops_pass.py Add a regression test ensuring quantized constant-folding for aten.cat with list/tuple tensor inputs produces the correct fused constant.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

cat_node = next(
node
for node in exported_program.graph_module.graph.nodes
if node.op == "call_function"
exported_program.graph_module
)

assert list(exported_program.state_dict) == ["aten_cat_default_fused_const"]
@perheld perheld merged commit 2d995bc into pytorch:main Apr 23, 2026
436 of 454 checks passed
@perheld perheld deleted the change-1242954 branch April 23, 2026 19:46
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 release notes: arm Changes to the ARM backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Arm backend: Quantized aten.cat constant-fold bug with list-valued tensor inputs

3 participants