Visualize the quantized model

I have set some qconfig for a model and want to check whether I insert the fake quant in right place or not.
If possible to visualize the quantized model like the ONNX model?

Right now we don’t have a visualization tool.

  • for eager mode quantization it is expected that user needs to reason about the model and make sure fake quant are inserted correctly when they place QuantStub/DeQuantStub around the model
  • for fx graph mode quantization, fake quant will be inserted correctly based on qconfig settings (QConfigMapping), and you can print the model graph (print(prepared_model.graph)) to see where they are

You can try also the package torchview, which provides several features (useful especially for large models). For instance you can set the display depth (depth in nested hierarchy of moduls).

Note: The accepted format for tool is pytorch model, which would be fine if you can extract pytorch model from onnx format

github repo

Disclaimer: I am the author of the package

1 Like