pytorch/ao
PyTorch native quantization for training and inference
What it solves
TorchAO provides a native PyTorch library for optimizing models from training to serving. It addresses the challenge of reducing model size and increasing inference speed without sacrificing significant accuracy, specifically by providing tools for quantization and sparsity.
How it works
TorchAO integrates directly with torch.compile() and FSDP2, allowing it to work out-of-the-box with most HuggingFace models. It implements various low-precision data types (dtypes) and memory layouts, using kernels in PyTorch, CUDA, C++, or Triton to accelerate performance on GPUs and CPUs.
Who it’s for
It is designed for machine learning engineers and researchers who need to deploy large models (like LLMs or diffusion models) more efficiently on server GPUs, edge devices via ExecuTorch, or ARM CPUs.
Highlights
- Quantization-Aware Training (QAT): Recovers accuracy degradation caused by post-training quantization, particularly for int4 models.
- Float8 Training: Accelerates pre-training (e.g., Llama-3.1-70B) by up to 1.5x using scaled float8 dtypes.
- Inference Optimization: Supports int4 weight-only and float8 dynamic quantization for significant speedups and memory reduction.
- Memory-Efficient Optimizers: Includes quantized optimizers (AdamW 4-bit/8-bit/Fp8) and CPU offloading to reduce VRAM requirements.
- C-level Integrations: Integrated with vLLM, HuggingFace Transformers/Diffusers/PEFT, Unsloth, and SGLang.
Related
- Project
- Project
- Project
- Project
- Project