Skip to content

refactor common used toy model #2729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

namgyu-youn
Copy link
Contributor

@namgyu-youn namgyu-youn commented Aug 11, 2025

Summary:
Integrate commonly used single/multi-linear toy models and refactor them across the codebase (src/test/benchmark/tutorial).

Test Plan: CI

Integrates common used toy model and refactor across TorchAO (ao/test/benchmark/tutorial)
- fix: pytorch#2078

Test Plan: CI
Copy link

pytorch-bot bot commented Aug 11, 2025

🔗 Helpful Links

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

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

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 Aug 11, 2025
@jainapurva jainapurva self-requested a review August 11, 2025 16:24
@jainapurva
Copy link
Contributor

@namgyu-youn thanks for taking up this effort

@jainapurva jainapurva added the topic: not user facing Use this tag if you don't want this PR to show up in release notes label Aug 11, 2025
self.linear1 = torch.nn.Linear(k, n, bias=False).to(dtype)
self.linear1 = torch.nn.Linear(m, n, bias=False)
self.linear2 = torch.nn.Linear(n, k, bias=False)
self.linear3 = torch.nn.Linear(k, 1, bias=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please create a separate model for two linear layers. This model for single linear layer is used in benchmarking run on CI.

Copy link
Contributor Author

@namgyu-youn namgyu-youn Aug 11, 2025

Choose a reason for hiding this comment

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

@jainapurva I prefer to define ToySingleLinearModel and ToyMultiLinearModel for a future update as you mentioned, but how about reverting benchmark_aq.py?

Unit tests (e.g., test_quant_api.py, test_awq.py) are using single/multiple layers in a mixed manner, and using only multiple layers might be an update. If this makes sense, benchmark_aq.py would be the only case using single layers. Let me know which one aligns better.

Copy link
Contributor

Choose a reason for hiding this comment

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

ToySingleLinearModel and ToyMultiLinearModel sounds good. Please ensure all the tests are running smoothly for it.
For benchmark_aq.py you can add the bias parameter as the last arg in init and set it to False by default. In addition to this, ToySingleLinearModel is used in running .github/workflows/run_microbenchmarks.yml. It uses the create_model_and_input_data, please ensure that method is running smoothly, and is updated as per the new toy models.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for opening the PR without checking it. And I will move into your suggestion; thanks for your leading.

@namgyu-youn namgyu-youn marked this pull request as draft August 11, 2025 22:23
@jainapurva
Copy link
Contributor

@namgyu-youn Please feel free to divide this into multiple PRs if it's too many changes.

@namgyu-youn namgyu-youn marked this pull request as ready for review August 12, 2025 01:04
@namgyu-youn namgyu-youn requested a review from jainapurva August 12, 2025 01:04
Integrate commonly used single/multi-linear toy models and refactor them across the codebase (src/test/benchmark/tutorial).

- fix: pytorch#2078

Test Plan: CI
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: not user facing Use this tag if you don't want this PR to show up in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor torchao and tests to use model architectures from torchao.testing.model_architectures
2 participants