-
Notifications
You must be signed in to change notification settings - Fork 257
Model shapes config #2116
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
Model shapes config #2116
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/2116
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (6 Unrelated Failures)As of commit a750555 with merge base dd5c7b0 ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs failed but was 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request refactors the microbenchmarking framework by centralizing model creation into torchao.testing.model_architectures, adds new model types with varied activation functions, and extends shape generation options for benchmarking. It also updates tests and documentation accordingly.
- Centralizes model definitions and input generation via create_model_and_input_data.
- Implements new shape generation options (custom, llama, pow2, pow2_extended, sweep).
- Updates tests and documentation to reflect refactoring and new functionality.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
torchao/testing/model_architectures.py | New model classes and unified model creation function added/refined |
test/test_model_architecture.py | Tests updated to use the new model creation function |
benchmarks/microbenchmarks/utils.py | Removed redundant model definitions and deprecated function |
benchmarks/microbenchmarks/test/* | Updated tests to work with refactored models and shape generation |
benchmarks/microbenchmarks/benchmark_runner.py | Enhanced shape generation and improved error messaging |
benchmarks/microbenchmarks/benchmark_inference.py | Updated to use the refactored model creation function |
benchmarks/microbenchmarks/README.md | Documentation updated with new model types and shape generation options |
Comments suppressed due to low confidence (2)
torchao/testing/model_architectures.py:164
- [nitpick] Consider using a stricter regex (e.g., r"ln_linear_(\w+)$") to extract the activation type more precisely from model_type, ensuring it only matches valid activations.
match = re.search(r"ln_linear_?(\w+)?", model_type)
torchao/testing/model_architectures.py:141
- Update the docstring for create_model_and_input_data to reflect the actual parameter names (e.g., 'm' instead of 'batch_size') for clarity and to avoid confusion.
def create_model_and_input_data(
Duplicates PR: #2036 |
This pull request introduces significant updates to the microbenchmarking framework, focusing on new model types, and enhanced shape generation options. The changes aim to expand functionality, and more extensive benchmarking configurations.
Enhancements to Model Types and Shape Generation
ln_linear_<activation>
(e.g.,sigmoid
,relu
,gelu
) andtransformer_block
with self-attention and MLP. These are documented inbenchmarks/microbenchmarks/README.md
.custom
,llama
,pow2
,pow2_extended
,sweep
) to support diverse matrix shapes for benchmarking. These options are implemented inbenchmark_runner.py
and documented in the README.Refactoring and Code Simplification
create_model_and_input
withcreate_model_and_input_data
, now imported fromtorchao.testing.model_architectures
. This centralizes model definitions and input data generation.ToyLinearModel
,LNLinearSigmoid
) fromutils.py
, consolidating them intotorchao.testing.model_architectures
.Future TODO: Refactor Torchao to use model definitions from torchao.testing.model_architectures, #2078
Updates to Configuration
benchmark_config.yml
to include configurations for new model types and shape generation options, such asllama
andpow2
.Documentation Improvements
README.md
to provide detailed descriptions of new model types and shape generation options, ensuring users can easily understand and utilize the new features.These changes collectively enhance the flexibility, maintainability, and usability of the benchmarking framework.
Sample configuration.yml for inference benchmarks