Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion torchao/quantization/pt2e/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ def _maybe_insert_input_and_output_observers_for_node(
node: Node,
model: torch.fx.GraphModule,
obs_or_fq_map: dict[EdgeOrNode, ObserverOrFakeQuantize],
named_modules: dict[str, torch.nn.Module],
is_qat: bool,
model_device: Optional[torch.device] = None,
):
Expand All @@ -594,7 +595,6 @@ def _maybe_insert_input_and_output_observers_for_node(
if this_node_quantization_annotation is None:
return

named_modules = dict(model.named_modules(remove_duplicate=False))
_maybe_insert_input_observers_for_node(
node,
None, # qconfig
Expand Down Expand Up @@ -666,13 +666,15 @@ def prepare(
if obs_or_fq_callback:
obs_or_fq_callback(model, obs_or_fq_map)
model_device = _assert_and_get_unique_device(model)
named_modules = dict(model.named_modules(remove_duplicate=False))

for node in nodes_before_observation:
# TODO: simplify logic for inserting observers
_maybe_insert_input_and_output_observers_for_node(
node,
model,
obs_or_fq_map,
named_modules,
is_qat,
model_device,
)
Expand Down
Loading