-
Notifications
You must be signed in to change notification settings - Fork 177
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
Autoquant v2 initial version #1240
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/1240
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ No FailuresAs of commit 0019456 with merge base d224653 (): This comment was automatically generated by Dr. CI and updates every 15 minutes. |
torch.nn.Linear(*new_shape, dtype=weight_val.dtype), | ||
).cuda() | ||
|
||
else: |
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.
this file has some complexity for extracting (prev_op -> linear1 -> maybe_linear_2 -> next_ops) because the models we originally studied had back to back linears. If you only care about transformer models, you can simplify this code quite a bit by removing the special logic for extraction of the second linear. Happy to point to the right places in the code if needed.
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.
let me clean this up a bit later since I'm still not sure if we need to reimplement the functionality with some other approaches yet, will figure out as we expand to test on more models
return True | ||
return False | ||
|
||
def debug_single_linear( |
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.
depending on what you're using this file for, this function also might be deleteable
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.
yeah will refine more when it's closer to land, right now just experimenting to see if this approach helps improve things over the original approach on models we care about
c54af02
to
f18ddbb
Compare
e444b5a
to
cb72ebc
Compare
One overall nit is that since this seems like a prototype that will eventually back the main autoquant API, we should probably put this in the prototype folder until we're ready to move. |
oh OK makes sense, I can move it |
f4f8ab5
to
831107f
Compare
torchao/prototype/quantization/subgraph_utils/extract_subgraphs.py
Outdated
Show resolved
Hide resolved
torchao/prototype/quantization/subgraph_utils/extract_subgraphs.py
Outdated
Show resolved
Hide resolved
Summary: We refactored the v1 to do benchmark for subgraphs of (prev_op -> linear -> post_op) in order to get more accurate estimation of timing. One issue here is now we need to care about batch size of the subgraph, so we'd need the batch size dimension to use symbolic shape, seems that it does not have good support on torch.compile right now More improvements: * current batch size adjustment code is hardcoded to work for llama model, need to think of a way to generalize it * using canonicalized subgraph as key for the cache to reduce the number of times we need to do benchmarking * add accuracy sanity checks Test Plan: Testing with torchao/_models/llama/generate.py ``` python generate.py --checkpoint_path $CHECKPOINT_PATH/$MODEL_REPO/model.pth --compile --compile_prefill --quantization autoquant_v2-int4 ``` Reviewers: Subscribers: Tasks: Tags:
a15efab
to
be822ae
Compare
Summary:
We refactored the v1 to do benchmark for subgraphs of (prev_op -> linear -> post_op) in order to get more accurate estimation of timing. One issue here is now we need to care about batch size of the subgraph, so we'd need the batch size dimension to use symbolic shape, seems that it does not have good support on torch.compile right now
Current Status:
More improvements:
Test Plan:
Testing with torchao/_models/llama/generate.py
<style type="text/css"></style>
Reviewers:
Subscribers:
Tasks:
Tags: