Skip to content
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

[pytorch][ao] force weight observer/fake_quant to be on the same device as the weight tensor #106755

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions torch/ao/quantization/fx/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
_get_module,
_is_custom_module_lstm,
_is_custom_module_mha,
assert_and_get_unique_device,
get_custom_module_class_keys,
create_getattr_from_value,
collect_producer_nodes,
Expand Down Expand Up @@ -733,6 +734,9 @@ def convert_weighted_module(
is_ptq = weight_post_process is None
if is_ptq:
weight_post_process = qconfig.weight() # type: ignore[union-attr, operator]
device = assert_and_get_unique_device(float_module)
if device:
weight_post_process.to(device)

# Call weight observer/fake_quant at least once to ensure the scales and zero points
# have the right shapes. Note: there are two cases where we don't have to do this:
Expand Down