-
Notifications
You must be signed in to change notification settings - Fork 25.7k
[pt2e] Avoid getting model device once per node #159901
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/159901
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit c4be20c with merge base 791eff9 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@andrewor14 has imported this pull request. If you are a Meta employee, you can view this in D79674759. |
| "Both 'meta' and 'cpu' are present in the list of devices. Module can have one device. We Select 'cpu'." | ||
| ) | ||
| devices = {torch.device("cpu")} | ||
| "" |
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.
@jerryzh168 is it safe to remove this?
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 check
326006f to
82e8fd3
Compare
|
@andrewor14 has imported this pull request. If you are a Meta employee, you can view this in D79674759. |
82e8fd3 to
4eeaee7
Compare
**Summary:** Previously, we call `assert_and_get_unqiue_device` once per node in convert. This is expensive and unnecessary since the model device is the same across all nodes, so we should just call this once in the beginning and reuse the same model device across all the nodes. torchao version of pytorch/pytorch#159901 **Test Plan:** ``` python test/quantization/pt2e/test_quantize_pt2e.py ```
|
@andrewor14 has imported this pull request. If you are a Meta employee, you can view this in D79674759. |
1a3b405 to
f1b7d46
Compare
**Summary:** Previously, we call `assert_and_get_unqiue_device` once per node in both prepare and convert. This is expensive and unnecessary since the model device is the same across all nodes, so we should just call this once in the beginning and reuse the same model device across all the nodes. torchao version of pytorch/pytorch#159901 Note: The prepare path is not completely done yet, since we are blocked on the pytorch PR on being merged. It's different from convert since it still calls utility functions from `torch.ao.quantization.fx`. **Test Plan:** ``` python test/quantization/pt2e/test_quantize_pt2e.py ```
|
@andrewor14 has imported this pull request. If you are a Meta employee, you can view this in D79674759. |
f1b7d46 to
16077ad
Compare
|
@andrewor14 has imported this pull request. If you are a Meta employee, you can view this in D79674759. |
|
Adding |
**Summary:** Previously, we call `assert_and_get_unqiue_device` once per node in both prepare and convert. This is expensive and unnecessary since the model device is the same across all nodes, so we should just call this once in the beginning and reuse the same model device across all the nodes. torchao version of pytorch/pytorch#159901 Note: The prepare path is not completely done yet, since we are blocked on the pytorch PR on being merged. It's different from convert since it still calls utility functions from `torch.ao.quantization.fx`. **Test Plan:** ``` python test/quantization/pt2e/test_quantize_pt2e.py ```
16077ad to
27e08a5
Compare
|
@andrewor14 has imported this pull request. If you are a Meta employee, you can view this in D79674759. |
27e08a5 to
64aae3a
Compare
|
@andrewor14 has imported this pull request. If you are a Meta employee, you can view this in D79674759. |
**Summary:** Previously, we call `assert_and_get_unqiue_device` once per node in both prepare and convert. This is expensive and unnecessary since the model device is the same across all nodes, so we should just call this once in the beginning and reuse the same model device across all the nodes. torchao version of pytorch/pytorch#159901 Note: The prepare path is not completely done yet, since we are blocked on the pytorch PR on being merged. It's different from convert since it still calls utility functions from `torch.ao.quantization.fx`. **Test Plan:** ``` python test/quantization/pt2e/test_quantize_pt2e.py ```
torch/ao/quantization/observer.py
Outdated
| model.graph, | ||
| "_scale", | ||
| scale, | ||
| scale.device, |
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.
value could be a non-Tensor I think? according to create_getattr_from_value L274, so should this be the device from model?
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.
Ok, seems like if we just get it from the model there will be no benefits, so how about here we get it from the scale if it's a tensor and get it from the model otherwise?
**Summary:** Previously, we call `assert_and_get_unqiue_device` once per node in both prepare and convert. This is expensive and unnecessary since the model device is the same across all nodes, so we should just call this once in the beginning and reuse the same model device across all the nodes. torchao version of pytorch/pytorch#159901 Note: The prepare path is not completely done yet, since we are blocked on the pytorch PR on being merged. It's different from convert since it still calls utility functions from `torch.ao.quantization.fx`. **Test Plan:** ``` python test/quantization/pt2e/test_quantize_pt2e.py ```
**Summary:** Previously, we call `assert_and_get_unqiue_device` once per node in both prepare and convert. This is expensive and unnecessary since the model device is the same across all nodes, so we should just call this once in the beginning and reuse the same model device across all the nodes. **Test Plan:** python test/test_quantization.py -k TestQuantizePT2E ghstack-source-id: 3e72b14 Pull Request resolved: #162012
64aae3a to
c4be20c
Compare
|
@andrewor14 has imported this pull request. If you are a Meta employee, you can view this in D79674759. |
|
@pytorchbot merge |
**Summary:** Previously, we call `assert_and_get_unqiue_device` once per node in both prepare and convert. This is expensive and unnecessary since the model device is the same across all nodes, so we should just call this once in the beginning and reuse the same model device across all the nodes. torchao version of pytorch/pytorch#159901 Note: The prepare path is not completely done yet, since we are blocked on the pytorch PR on being merged. It's different from convert since it still calls utility functions from `torch.ao.quantization.fx`. **Test Plan:** ``` python test/quantization/pt2e/test_quantize_pt2e.py ```
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
**Summary:** Previously, we call `assert_and_get_unqiue_device` once per node in both prepare and convert. This is expensive and unnecessary since the model device is the same across all nodes, so we should just call this once in the beginning and reuse the same model device across all the nodes. **Test Plan:** python test/test_quantization.py -k TestQuantizePT2E Pull Request resolved: pytorch#159901 Approved by: https://github.com/jerryzh168
**Summary:** Previously, we call `assert_and_get_unqiue_device` once per node in both prepare and convert. This is expensive and unnecessary since the model device is the same across all nodes, so we should just call this once in the beginning and reuse the same model device across all the nodes. **Test Plan:** python test/test_quantization.py -k TestQuantizePT2E Pull Request resolved: pytorch#159901 Approved by: https://github.com/jerryzh168
**Summary:** Previously, we call `assert_and_get_unqiue_device` once per node in both prepare and convert. This is expensive and unnecessary since the model device is the same across all nodes, so we should just call this once in the beginning and reuse the same model device across all the nodes. **Test Plan:** python test/test_quantization.py -k TestQuantizePT2E Pull Request resolved: pytorch#159901 Approved by: https://github.com/jerryzh168
Summary: Previously, we call
assert_and_get_unqiue_deviceonce per node in both prepare and convert. This is expensive and unnecessary since the model device is the same across all nodes, so we should just call this once in the beginning and reuse the same model device across all the nodes.Test Plan:
python test/test_quantization.py -k TestQuantizePT2E
cc @ezyang @SherlockNoMad @EikanWang @jgong5 @wenzhe-nrv