Skip to content

Preserve BatchNorm running state in composable quantizer#21056

Merged
denizkilinc merged 1 commit into
pytorch:mainfrom
denizkilinc:export-D112989631
Jul 21, 2026
Merged

Preserve BatchNorm running state in composable quantizer#21056
denizkilinc merged 1 commit into
pytorch:mainfrom
denizkilinc:export-D112989631

Conversation

@denizkilinc

@denizkilinc denizkilinc commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary:
Quantization-aware training with the composable PatternQuantizer incorrectly observed BatchNorm affine parameters and running-state buffers as activation inputs. The inserted fake-quant nodes broke the connection between aten.batch_norm.default and the registered running_mean and running_var buffers, so training used batch statistics while evaluation consumed stale running statistics.

Keep aten.batch_norm.default arguments 1-4 directly connected to registered state by excluding them from activation observation while retaining activation and output quantization. Add Arm and Sleep/ModAI regression tests that verify the state operands remain registered and the running statistics update during QAT.

Differential Revision: D112989631

@denizkilinc
denizkilinc requested a review from digantdesai as a code owner July 21, 2026 08:52
@pytorch-bot

pytorch-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 21, 2026

Copy link
Copy Markdown

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

@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 Jul 21, 2026
@meta-codesync

meta-codesync Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@denizkilinc has exported this pull request. If you are a Meta employee, you can view the originating Diff in D112989631.

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

pytorch-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

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

@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.

@denizkilinc

Copy link
Copy Markdown
Contributor Author

/easycla

@denizkilinc
denizkilinc force-pushed the export-D112989631 branch 4 times, most recently from 7b0a3ba to b0fcdc3 Compare July 21, 2026 13:52

@rascani rascani left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, but you'll need to sign EasyCLA. Let me know if you need any help with that.

@denizkilinc

Copy link
Copy Markdown
Contributor Author

@rascani thank you for the review. I signed EasyCLA, now waiting for approval. If don't get approval today, I'll let you know.

Summary:
Quantization-aware training with the composable `PatternQuantizer` incorrectly observed BatchNorm affine parameters and running-state buffers as activation inputs. The inserted fake-quant nodes broke the connection between `aten.batch_norm.default` and the registered `running_mean` and `running_var` buffers, so training used batch statistics while evaluation consumed stale running statistics.

Keep `aten.batch_norm.default` arguments 1-4 directly connected to registered state by excluding them from activation observation while retaining activation and output quantization. Add Arm and Sleep/ModAI regression tests that verify the state operands remain registered and the running statistics update during QAT.

Differential Revision: D112989631
@meta-codesync

meta-codesync Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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

@denizkilinc

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorch-bot

pytorch-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

Mergebot is not configured for this repository. Please use the merge button provided by GitHub.

@denizkilinc
denizkilinc merged commit 6bd0355 into pytorch:main Jul 21, 2026
439 of 481 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. meta-exported module: arm Issues related to arm backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants