What optimum is for
optimum is HF's hardware-acceleration umbrella. Each subpackage targets a vendor / runtime: optimum.onnxruntime, optimum.intel (OpenVINO, Neural Compressor), optimum.habana (Gaudi), optimum.tpu, optimum.nvidia (TensorRT-LLM). Same Auto-class shape (ORTModelForCausalLM, OVModelForCausalLM, ...) so swapping runtimes is a one-line import change.
Two patterns
- Export-time optimization —
ORTModelForCausalLM.from_pretrained(repo, export=True)converts and saves an optimized graph. - Run-time optimization —
optimum-cli onnxruntime quantizeapplies INT8 dynamic quantization, etc.
When to reach for it
If your serving target is anything other than "PyTorch on a NVIDIA GPU," optimum probably has a runtime for it. Mobile / embedded / Intel CPU / TPU / Gaudi / TensorRT — all converge on optimum's shape. The cost is one extra dependency and a per-target export step.