Skip to content

Allow non-tensor kwargs in prepare_pt2e#3642

Merged
jerryzh168 merged 5 commits intopytorch:mainfrom
Erik-Lundell:permit-kwargs
Jan 23, 2026
Merged

Allow non-tensor kwargs in prepare_pt2e#3642
jerryzh168 merged 5 commits intopytorch:mainfrom
Erik-Lundell:permit-kwargs

Conversation

@Erik-Lundell
Copy link
Copy Markdown
Contributor

Add a list of permitted kwargs in
_maybe_insert_input_observers_for_node:
device, pin_memory, and memory_format.

Some ops are already permitted, showing that
the assert is not a hard limit. The kwargs
in question should not affect or be affected
by quantization, and there is no clear reason
for why all kwargs should be disallowed.

There has been at least two discussions on this issue #2146
pytorch/pytorch#146621,

and it has caused a follow-up bug in Executorch:
pytorch/executorch#16541

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Jan 15, 2026

🔗 Helpful Links

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

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

❌ 1 New Failure

As of commit 6075f90 with merge base 23143f5 (image):

NEW FAILURE - The following job has failed:

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 Jan 15, 2026
Some ops were already permitted, and what the assert
actually was trying to guard was not silently
skipping quantizing kwargs. This is only relevant
for Tensor kwargs.

There has been at least two discussions on this issue
pytorch#2146
pytorch/pytorch#146621,

and it has caused a follow-up bug in Executorch:
pytorch/executorch#16541

Signed-off-by: Erik Lundell <erik.lundell@arm.com>
@Erik-Lundell Erik-Lundell changed the title Allow certain kwargs in prepare_pt2e Allow non-tensor kwargs in prepare_pt2e Jan 16, 2026
Signed-off-by: Erik Lundell <erik.lundell@arm.com>
@jerryzh168 jerryzh168 added the topic: improvement Use this tag if this PR is an improvement (doesn't fit into any of the other categories) label Jan 20, 2026
- Sequence triggered for strings, causing
infinite recursion as each element in a string
of length 1 is also a string of length 1.
- Add case for dict kwargs.

Signed-off-by: Erik Lundell <erik.lundell@arm.com>
Copy link
Copy Markdown
Contributor

@jerryzh168 jerryzh168 left a comment

Choose a reason for hiding this comment

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

thanks, LGTM

@jerryzh168
Copy link
Copy Markdown
Contributor

@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Jan 21, 2026

@JacobSzwejbka has imported this pull request. If you are a Meta employee, you can view this in D91152284.

Remove unused import of Sequence from collections.abc
Attempting to quantize empty_like caused flaky failures due to attempting to calculate qparams for only 0's
@Erik-Lundell
Copy link
Copy Markdown
Contributor Author

please fix ruff: https://github.com/pytorch/ao/actions/runs/21207774639/job/61049126964?pr=3642

That's an annoying thing to miss, fixed it. Also addressed an issue causing flakiness. Slowly getting there :)

@jerryzh168 jerryzh168 merged commit 79d1eca into pytorch:main Jan 23, 2026
20 of 22 checks passed
JacobSzwejbka pushed a commit to pytorch/executorch that referenced this pull request Jan 26, 2026
To include
pytorch/ao#3642

cc @freddan80 @per @zingo @oscarandersson8218 @digantdesai

Signed-off-by: Erik Lundell <erik.lundell@arm.com>
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. topic: improvement Use this tag if this PR is an improvement (doesn't fit into any of the other categories)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants