TL;DR
QATFactory is an open-source framework designed to bridge the gap between high-precision training and low-precision (4-bit) deployment for Large Language Models (LLMs). By simulating the exact numerical "quirks" of production inference engines like vLLM and llama.cpp during the training process, it allows models to maintain high quality even when compressed to aggressive formats like NVFP4 and MXFP4, all without requiring specialized next-gen training hardware.
What Problem Does This Paper Address?
As LLMs scale, the cost of inference becomes the dominant expense. To keep throughput high and costs low, the industry is moving toward 4-bit quantization (e.g., W4A4, where both weights and activations are 4-bit). However, standard Post-Training Quantization (PTQ)—where you take a finished model and squash its values—often leads to significant accuracy drops, particularly in complex reasoning and coding tasks.
The challenge is twofold:
- Numerical Mismatch: Existing Quantization-Aware Training (QAT) tools often use generic math that doesn't match how specific inference engines (like vLLM or llama.cpp) actually handle data. A model might look great in training but break when deployed.
- Hardware Barriers: Training natively in new formats like NVFP4 typically requires the latest hardware (e.g., NVIDIA Blackwell), which is not yet widely accessible.
Methods
QATFactory introduces a "deployment-aligned" approach. It treats the target inference engine as the ground-truth numerical specification.
- Simulated Quantization: During training, the framework performs matrix multiplications in standard BF16 but applies "fake quantization" to the weights and activations. This reproduces the exact representable values, rounding behaviors, and scaling hierarchies of the target format (see Table 1 below).
- Hardware Independence: Because the underlying math remains in BF16, researchers can train models for Blackwell-native formats (NVFP4) on widely available H100 GPUs.
- Dual Workflows: It supports Quantization-Aware Distillation (QAD), where a quantized "student" model learns from a high-precision "teacher," and Quantization-Aware Reinforcement Learning (QARL), which uses quantized models directly in the RL rollout loop.
Datasets
The authors validated QATFactory across a massive range of models (8B to 230B parameters) using:
- Training/Distillation: Open Perfect Blend (math and code domains) and DeepMath-103K for RL.
- Evaluation: A comprehensive suite including GPQA-Diamond (science), MMLU-Pro (general knowledge), AIME25 (math), and coding benchmarks like LiveCodeBench and BigCodeBench.
Key Insights and Ideas
- Format-Dependent Precision: One of the most surprising findings is that "full fidelity" during training isn't always best. For NVFP4, the model performs better if only weights are quantized during training (W4A16). However, MXFP4—which has coarser scaling—benefits significantly from quantizing both weights and activations (W4A4) during training.
- The LoRA Ceiling: While LoRA (Low-Rank Adaptation) drastically reduces memory usage (by ~2.9x), simply increasing the rank of the adapters does not close the quality gap with full-parameter training.
- Sequence Length Matters: For a fixed budget of training tokens, training on fewer, longer sequences (32K) generalizes much better than training on many short sequences (4K), gaining nearly 2 points in average accuracy.
- QARL Efficiency: Integrating quantization into Reinforcement Learning (QARL) actually speeds up training by 1.23x because the rollout phase can use native low-precision kernels, while still producing a more robust final model.
Key Results
QATFactory consistently outperforms standard PTQ baselines across the board:
- Accuracy Recovery: On Qwen3.5-9B, QAD achieved 68.9% accuracy under NVFP4, significantly beating the best PTQ result of 65.4%.
- Coding Prowess: The improvements were most dramatic in coding. On LiveCodeBench, QATFactory produced an NVFP4 model with 83.0% accuracy, nearly matching the original BF16 model's 82.3%, whereas PTQ methods lagged behind at ~64-66%.
- Deployment Ready: Checkpoints exported from QATFactory load directly into vLLM and llama.cpp with zero additional conversion steps or inference overhead.
Limitations and Future Work
While QATFactory is a major step forward, the authors note that the gap between LoRA-based QAT and full-parameter QAT remains an open challenge for memory-constrained settings. Future work aims to extend the framework to even more aggressive formats, such as the programmable 3-bit lookup-table formats planned for NVIDIA’s upcoming Rubin architecture.
Summary updated