chapter six

6 Porting Workflows Across Frameworks

 

This chapter covers

  • Recognizing where quantization workflows diverge across frameworks
  • Running end-to-end quantization in PyTorch and TorchAO
  • Exporting to ONNX with correct quantization semantics
  • Converting to TensorFlow and TFLite quantized formats
  • Validating numerical equivalence across exported artifacts

Up to this point, we’ve discussed quantization within a single framework. You learned to choose granularity, calibrate ranges, and recover accuracy with QATin PyTorch. But production teams rarely live in a single framework: A research team trains in PyTorch, the serving team needs an ONNX artifact (a portable model graph in an open exchange format that we’ll cover in detail in section 6.4), and the mobile team needs TensorFlow Lite. Same model, same quantization intent, three different export targets.

This is where quantization projects run into trouble. You quantize in PyTorch, export to ONNX, and accuracy drops 1.3%, not because either tool has a bug, because each framework makes different default choices about how to quantize, and those choices compound.

That 1.3% matters more than it looks.

6.1 Know where frameworks diverge

6.2 Run the PyTorch and TorchAO path end-to-end

6.3 Run the TensorFlow path with the model optimization toolkit

6.4 Export to ONNX and drive ONNX Runtime quantization

6.5 Verify equivalence and diagnose coverage

6.6 Summary