Overview

9 Shipping with the Right Toolchain

Shipping a quantized model is not just a matter of having the right file on disk; it is a deployment problem where the hardware, runtime, execution provider, and artifact format must all line up. The chapter emphasizes that a model can look quantized yet still run in FP32 if the target runtime lacks kernels for the intended dtype, so the first job of an inference engineer is to choose the serving stack based on the silicon and then verify what precision actually executes. ONNX Runtime is the portable default for mixed fleets, TensorRT is the NVIDIA path for peak GPU throughput, and OpenVINO is the Intel path for CPUs and integrated accelerators.

The chapter then shows how to build production-ready ONNX Runtime deployments correctly, especially for transformers like BERT. It recommends task-aware export and quantization through Optimum, transformer-specific graph fusion before quantization, and careful overrides such as restricting static quantization to MatMul, disabling per-channel quantization when it hurts more than it helps, and using MinMax calibration for transformer graphs. It also explains that dynamic quantization is often better than static for transformers, and that the choice of quantization format matters: QDQ gives execution providers more flexibility than QOperator on CPU, while INT8 on CUDA EP alone is usually a trap because unsupported kernels fall back to slower paths.

The final sections extend the same logic to TensorRT and OpenVINO, then close with packaging and verification. TensorRT can be driven through implicit or explicit INT8 workflows, but the chapter shows that explicit QDQ graphs are safer for transformers even when implicit can win on simple CNNs, because calibration-based builds can silently lose INT8 coverage. OpenVINO follows a similar split between standalone IR workflows and ORT-based serving, with performance depending on the model and host capabilities such as BF16 or AMX. To prevent silent regressions, the chapter packages each artifact with a manifest that records the recipe, calibration fingerprint, and compatibility metadata, and it runs a verification matrix on the target host so deploy gates can detect demotions, missing runtimes, and precision fallbacks before anything ships.

Hardware selects the runtime family, and the execution provider selects which kernels dispatch. The leaf node is the production artifact. The two routes to TensorRT and OpenVINO, standalone versus via ORT, trade peak latency against a unified serving surface across heterogeneous fleets. Branches marked Chapter 10 and Chapter 11 point to regimes covered there.
Hardware selects the runtime family, and the execution provider selects which kernels dispatch. The leaf node is the production artifact. The two routes to TensorRT and OpenVINO, standalone versus via ORT, trade peak latency against a unified serving surface across heterogeneous fleets. Branches marked Chapter 10 and Chapter 11 point to regimes covered there.
BERT-base SST-2 on CPU EP. Dynamic INT8 is 1.35× faster than static INT8 at the same accuracy band. Newcomers find this direction counterintuitive; ORT documents it as expected behavior for transformer-class graphs.
BERT-base SST-2 on CPU EP. Dynamic INT8 is 1.35× faster than static INT8 at the same accuracy band. Newcomers find this direction counterintuitive; ORT documents it as expected behavior for transformer-class graphs.
Transformer-aware optimizer on BERT-base, CUDA EP, batch 8, sequence 128. The 1.17× reflects fusion alone. ORT_ENABLE_ALL at session-init does not run these transformer-specific patterns.
Transformer-aware optimizer on BERT-base, CUDA EP, batch 8, sequence 128. The 1.17× reflects fusion alone. ORT_ENABLE_ALL at session-init does not run these transformer-specific patterns.
ResNet-18 static INT8, three calibration methods on CPU EP. Top-1 agreement collapses to a sub-1 pp band. The Entropy-latency spike is most likely a single-run measurement artifact; the three graphs have identical op types and node counts.
ResNet-18 static INT8, three calibration methods on CPU EP. Top-1 agreement collapses to a sub-1 pp band. The Entropy-latency spike is most likely a single-run measurement artifact; the three graphs have identical op types and node counts.
SessionOptions and io_binding on the FP32-optimized BERT graph, CUDA EP. All three configurations within 30 µs of each other. Same levers pay off differently on raw exports and on per-request LLM serving; this graph is already past the regime where they matter.
SessionOptions and io_binding on the FP32-optimized BERT graph, CUDA EP. All three configurations within 30 µs of each other. Same levers pay off differently on raw exports and on per-request LLM serving; this graph is already past the regime where they matter.
ResNet-18 inference latency on L4, batch 32. Implicit INT8 reaches 1.04 ms (6.44× over FP32) and outperforms explicit INT8's 1.73 ms (3.84×). The direction is counterintuitive at first, explicit is the recommended path and the engine inspector explains it.
ResNet-18 inference latency on L4, batch 32. Implicit INT8 reaches 1.04 ms (6.44× over FP32) and outperforms explicit INT8's 1.73 ms (3.84×). The direction is counterintuitive at first, explicit is the recommended path and the engine inspector explains it.
BERT-base SST-2 latency on L4, batch 8, seq 128. Explicit INT8 leads at 2.73 ms; implicit INT8 lands within measurement noise of FP16. Dotted lines mark Table 9.1's CUDA EP INT8 (14.4 ms) and FP32-optimized (9 ms) references. TRT's INT8 explicit closes the gap section 9.2 identified.
BERT-base SST-2 latency on L4, batch 8, seq 128. Explicit INT8 leads at 2.73 ms; implicit INT8 lands within measurement noise of FP16. Dotted lines mark Table 9.1's CUDA EP INT8 (14.4 ms) and FP32-optimized (9 ms) references. TRT's INT8 explicit closes the gap section 9.2 identified.
ResNet-18 latency on c3-standard-4 (Intel Xeon Platinum 8481C, Sapphire Rapids), batch 32. OV native INT8 reaches 41.79 ms (9.55× over FP32) on AMX-INT8 tile registers; OV native BF16 reaches 58.04 ms (6.88×) on AMX-BF16. The via-ORT FP32 path costs essentially nothing (1.01×); via-ORT INT8 costs 38% relative to native. The asymmetry is informative. The two INT8 routes hand OpenVINO different artifacts.
ResNet-18 latency on c3-standard-4 (Intel Xeon Platinum 8481C, Sapphire Rapids), batch 32. OV native INT8 reaches 41.79 ms (9.55× over FP32) on AMX-INT8 tile registers; OV native BF16 reaches 58.04 ms (6.88×) on AMX-BF16. The via-ORT FP32 path costs essentially nothing (1.01×); via-ORT INT8 costs 38% relative to native. The asymmetry is informative. The two INT8 routes hand OpenVINO different artifacts.
BERT-base SST-2 latency on c3-standard-4, batch 8, seq 128. OV native BF16 (121.01 ms, 5.80×) and OV native INT8 (110.17 ms, 6.37×) both clear section 9.2's Cascade Lake CPU EP baseline by more than 2×. Via-ORT INT8 reaches 96.28 ms (7.29×), the fastest cell in the table, and the reason is recipe asymmetry, not runtime advantage.
BERT-base SST-2 latency on c3-standard-4, batch 8, seq 128. OV native BF16 (121.01 ms, 5.80×) and OV native INT8 (110.17 ms, 6.37×) both clear section 9.2's Cascade Lake CPU EP baseline by more than 2×. Via-ORT INT8 reaches 96.28 ms (7.29×), the fastest cell in the table, and the reason is recipe asymmetry, not runtime advantage.
Packaging verification matrix on an NVIDIA L4 host. Rows are artifact kinds; columns are runtimes. Solid cells executed at the claimed precision (the OpenVINO Core CPU column reports per-op precision fractions; ORT cells verify load and run, since ORT's Python API does not expose per-op precision). Hatched cells loaded but fell back. ResNet INT8 × ORT TRT EP routed 19 nodes to CUDA EP because TensorRT's parser rejects ORT's INT32 zero-point format on Conv DQ; BERT INT8 × ORT CUDA EP is the 9.2 anti-pattern resurfacing. Filled cells are runtime, hardware, or artifact absent; information about the deploy target, not bugs.
Packaging verification matrix on an NVIDIA L4 host. Rows are artifact kinds; columns are runtimes. Solid cells executed at the claimed precision (the OpenVINO Core CPU column reports per-op precision fractions; ORT cells verify load and run, since ORT's Python API does not expose per-op precision). Hatched cells loaded but fell back. ResNet INT8 × ORT TRT EP routed 19 nodes to CUDA EP because TensorRT's parser rejects ORT's INT32 zero-point format on Conv DQ; BERT INT8 × ORT CUDA EP is the 9.2 anti-pattern resurfacing. Filled cells are runtime, hardware, or artifact absent; information about the deploy target, not bugs.
Packaging verification matrix on a c3-standard-4 host (Intel Xeon Platinum 8481C, Sapphire Rapids). The ORT/OV EP column lights up for the first time. The Section 9.4 via-ORT route runs end-to-end on AMX silicon. ORT/CUDA EP and ORT/TRT EP block (no GPU). The OV/CPU INT8 fractions match the L4 host within rounding (40% ResNet, 22-27% BERT); the BF16 fractions in the same column move sharply, from 0% on FP32 ONNX × OV/CPU on the L4 host to 26% on c3, because OpenVINO's INFERENCE_PRECISION_HINT defaults to BF16 on AMX-capable CPUs and auto-downcasts FP32 weights at compile time.
Packaging verification matrix on a c3-standard-4 host (Intel Xeon Platinum 8481C, Sapphire Rapids). The ORT/OV EP column lights up for the first time. The Section 9.4 via-ORT route runs end-to-end on AMX silicon. ORT/CUDA EP and ORT/TRT EP block (no GPU). The OV/CPU INT8 fractions match the L4 host within rounding (40% ResNet, 22-27% BERT); the BF16 fractions in the same column move sharply, from 0% on FP32 ONNX × OV/CPU on the L4 host to 26% on c3, because OpenVINO's INFERENCE_PRECISION_HINT defaults to BF16 on AMX-capable CPUs and auto-downcasts FP32 weights at compile time.

Summary

  • Hardware selects the runtime family, the execution provider selects which kernels dispatch, and the artifact is whatever the winning runtime consumes: a TensorRT .plan, an OpenVINO IR pair, or a quantized ONNX served through ORT. When kernels for the target dtype are missing, runtimes fall back to FP32 silently, so verifying the executing dtype on the deploy host is the only proof the claimed precision is real.
  • ORT's three quantization entry points are not interchangeable. On transformers, dynamic INT8 beats static because the static default quantizes the embedding lookup; restricting quantization to MatMul restores production behavior. Graph optimization that fuses Attention, LayerNorm, and GELU is a separate pass layered on top, and INT8 belongs on the CPU EP unless the TensorRT EP is in the provider list.
  • TensorRT reaches INT8 through two paths that build different engines from the same model. The implicit calibrator path is fastest on simple CNNs but can silently demote a transformer to FP16 when key tensors never receive scales. The explicit QDQ-in-ONNX path carries a small reformat cost on CNNs but holds INT8 through the encoder on BERT.
  • OpenVINO compiles two artifacts against the same CPU plugin, and the recipe, not the runtime, decides which wins. The native NNCF transformer preset favors Conv-heavy graphs; the leaner via-ORT recipe favors transformer matmuls. On Sapphire Rapids and later, BF16 captures most of the INT8 speedup without calibration and is the cheapest deliverable when the latency budget allows.
  • Every artifact ships with a manifest sidecar and a content hash that pin the quantizer, format, calibration fingerprint, required hardware, and runtime compatibility. Precision lives in the artifact graph rather than the serving config, so a Triton INT8 config looks almost identical to its FP32 sibling. Run the verification matrix on the deploy host before opening the gate: move the artifacts to new silicon and the reachability columns shift while the INT8 fraction barely moves, because the recipe chose what to quantize.

FAQ

Why is the portable artifact not always the production artifact?The portable artifact is usually a vendor-neutral file, like quantized ONNX, that is easy to move between teams and tools. The production artifact is the version compiled for the actual serving runtime and target silicon, such as a TensorRT engine or OpenVINO IR. A file can look correctly quantized on disk but still execute in FP32 at serving time if the runtime lacks the right kernels.
How do I choose the right runtime for my hardware?Use the target hardware to select the runtime family: ONNX Runtime for portability across mixed fleets, TensorRT for NVIDIA GPUs when you want peak throughput, and OpenVINO for Intel CPUs and accelerators. The runtime choice should follow the silicon, not the other way around.
What causes silent FP32 fallback during deployment?Silent FP32 fallback happens when the runtime or execution provider does not have kernels for the target dtype or operator pattern. In that case, it often falls back to FP32 without an error or warning. The fix is to verify the dtype actually executed on the hardware, not just inspect the file contents.
When should I use ONNX Runtime versus TensorRT or OpenVINO directly?Use ONNX Runtime when you need one serving code path across heterogeneous hardware. Use TensorRT directly when the deployment is NVIDIA-only and you want the best possible latency. Use OpenVINO directly when the deployment is Intel-only and you want a purpose-built IR for that platform.
What is the difference between standalone deployment and via-ORT deployment?Standalone deployment converts the model into the vendor’s native artifact and serves it with the vendor API. Via-ORT keeps the ONNX Runtime serving code and uses an execution provider to hand off supported subgraphs to the vendor runtime. Standalone usually favors peak performance on a single hardware type, while via-ORT favors a unified serving stack across mixed fleets.
Why does dynamic INT8 often work better than static INT8 for transformers?For transformer-shaped graphs, dynamic quantization usually works better because it quantizes mainly the weight matmuls and computes activation scales at runtime. Static quantization can overreach and quantize parts of the graph that are sensitive, such as embeddings or other transformer-specific nodes, which can hurt both latency and accuracy unless you override the defaults carefully.
What Optimum and ONNX Runtime quantization settings matter most for BERT-like models?The chapter emphasizes a few key overrides: restrict static quantization to MatMul nodes, set per_channel=False when it does not help enough, and use CalibrationMethod.MinMax for transformer models. It also recommends transformer-aware graph optimization before quantization so the quantizer sees fused subgraphs.
Why does QDQ sometimes outperform QOperator on CPU?Although QOperator looks simpler, QDQ often gives the CPU execution provider more freedom to fuse and rewrite the graph. That extra flexibility can make QDQ faster on x86 CPUs, even if folk wisdom suggests QOperator should win on CPU. On the chapter’s BERT example, QDQ beat QOperator on CPU EP.
Why can TensorRT explicit INT8 be faster than implicit INT8 on transformers?Explicit INT8 pins quantization placement with Q/DQ nodes, which is more reproducible and works better for transformer graphs that need precise control. Implicit INT8 can fail to cover all important tensors during calibration, causing the engine to fall back to higher precision or even end up effectively FP16. On BERT, explicit INT8 closed the gap and produced the fastest engine in the chapter’s comparison.
What should be included in a packaging manifest for quantized models?A good manifest should record the artifact kind and path, a content hash such as SHA-256, the quantization recipe, calibration details, and the hardware/runtime compatibility requirements. That metadata lets deployment systems verify what the file is, what created it, and where it can safely run.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Quantization and Fast Inference Quantization and Fast Inference ebook for free
Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Quantization and Fast Inference Quantization and Fast Inference ebook for free