Skip to content

Commit

Permalink
capture_pre_autograd_graph -> export_for_training
Browse files Browse the repository at this point in the history
  • Loading branch information
daniil-lyakhov committed Nov 14, 2024
1 parent d00309b commit 17c0192
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions docs/optimization_guide/nncf/ptq/code/ptq_torch_fx.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ def transform_fn(data_item):
input_fp32 = ... # FP32 model input

with nncf.torch.disable_patching():
# Using capture_pre_autograd_graph to export torch.fx.GraphModule
# the same way it done for PyTorch 2 Export Post Training Quantization:
# https://pytorch.org/tutorials/prototype/pt2e_quant_ptq.html
captured_graph = torch._export.capture_pre_autograd_graph(model, args=(input_fp32,))
quantized_model = nncf.quantize(captured_graph, calibration_dataset)
exported_model = torch.export.export_for_training(model, args=(input_fp32,)).module()
quantized_model = nncf.quantize(exported_model, calibration_dataset)
#! [quantization]

#! [inference]
Expand Down

0 comments on commit 17c0192

Please sign in to comment.