Skip to content

Use foreach SGD in QAT example to fix static-analysis lint (#21031)#21031

Open
psiddh wants to merge 1 commit into
pytorch:mainfrom
psiddh:export-D112638593
Open

Use foreach SGD in QAT example to fix static-analysis lint (#21031)#21031
psiddh wants to merge 1 commit into
pytorch:mainfrom
psiddh:export-D112638593

Conversation

@psiddh

@psiddh psiddh commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary:

Follow-up to D112514521. That diff (a diff-train import of the Practical-RIFE
PTQ/QAT accuracy flow) tripped the missing_for_each_optimizer CITRINE
static-analysis lint at qat_loop.py:689: the QAT training loop constructed
torch.optim.SGD without the foreach multi-tensor implementation.

Add foreach=True to the torch.optim.SGD constructor in build_qat_model
so the optimizer uses the multi-tensor path (estimated ~3.3% training speedup
per the lint guidance). Applied to both the fbcode and xplat copies.

Reviewed By: rascani

Differential Revision: D112638593

Copilot AI review requested due to automatic review settings July 17, 2026 23:37
@psiddh
psiddh requested a review from digantdesai as a code owner July 17, 2026 23:37
@pytorch-bot

pytorch-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit b49057d with merge base 44539fd (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 Jul 17, 2026
@meta-codesync

meta-codesync Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

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

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

Copilot AI 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.

Pull request overview

Updates the Arm QAT example training loop to satisfy the missing_for_each_optimizer static-analysis lint by ensuring SGD uses the multi-tensor (foreach) implementation, aligning the example with recommended optimizer configuration.

Changes:

  • Switch torch.optim.SGD(...) construction in build_qat_model to pass foreach=True.
  • Reformat the optimizer constructor into a multi-line call for readability.

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

@meta-codesync meta-codesync Bot changed the title Use foreach SGD in QAT example to fix static-analysis lint Use foreach SGD in QAT example to fix static-analysis lint (#21031) Jul 18, 2026
psiddh added a commit to psiddh/executorch that referenced this pull request Jul 18, 2026
…1031)

Summary:

Follow-up to D112514521. That diff (a diff-train import of the Practical-RIFE
PTQ/QAT accuracy flow) tripped the `missing_for_each_optimizer` CITRINE
static-analysis lint at `qat_loop.py:689`: the QAT training loop constructed
`torch.optim.SGD` without the foreach multi-tensor implementation.

Add `foreach=True` to the `torch.optim.SGD` constructor in `build_qat_model`
so the optimizer uses the multi-tensor path (estimated ~3.3% training speedup
per the lint guidance). Applied to both the `fbcode` and `xplat` copies.

Reviewed By: rascani

Differential Revision: D112638593
Copilot AI review requested due to automatic review settings July 18, 2026 05:41
@psiddh
psiddh force-pushed the export-D112638593 branch from 15b8795 to 9cc01e5 Compare July 18, 2026 05:41

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

…1031)

Summary:

Follow-up to D112514521. That diff (a diff-train import of the Practical-RIFE
PTQ/QAT accuracy flow) tripped the `missing_for_each_optimizer` CITRINE
static-analysis lint at `qat_loop.py:689`: the QAT training loop constructed
`torch.optim.SGD` without the foreach multi-tensor implementation.

Add `foreach=True` to the `torch.optim.SGD` constructor in `build_qat_model`
so the optimizer uses the multi-tensor path (estimated ~3.3% training speedup
per the lint guidance). Applied to both the `fbcode` and `xplat` copies.

Reviewed By: rascani

Differential Revision: D112638593
@psiddh
psiddh force-pushed the export-D112638593 branch from 9cc01e5 to b49057d Compare July 18, 2026 06:07
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.

3 participants