TWEO Framework for Stable FP8 Training
- TWEO is a framework that uses a data-independent regularizer to suppress catastrophic activation outliers during low-precision transformer training.
- It introduces a loss term after each transformer block with parameters (τ=3, p=4, ε=10⁻⁶), ensuring stable FP8 training even for large models.
- TWEO supports fast, hardware-friendly 8-bit quantization, achieving significant throughput improvements without architectural modifications.
Transformers Without Extreme Outliers (TWEO) is a framework addressing the problem of catastrophic activation outliers during low-precision training and quantization of transformer models. By introducing a non-invasive, data-independent regularizer targeting the mechanical origin of such outliers, TWEO enables stable full-model FP8 training for large language and vision transformers and supports fast, hardware-friendly quantization to 8-bit precision—all without architectural changes, complex mixed-precision engineering, or invasive algorithmic modifications (Liang et al., 28 Nov 2025).
1. Motivation and Problem Context
Transformer activations are known to produce massive outliers (|activation| ≫ 1000), a ubiquitous phenomenon in both LLMs and vision transformers (ViTs). Native FP8 support (e.g., E4M3 format, dynamic range ≈ ±448) in modern hardware, while promising increased training throughput, is rendered unreliable by these outliers. The key failure modes are (i) post-training quantization (PTQ) collapse due to unusably large quantization ranges, and (ii) catastrophic failure of full FP8 training arising from accumulator overflow and exploded loss. Existing remedies—extensive mixed-precision engineering (restricting FP8 to certain modules), architectural hacks premised on token statistics, and invasive activation modifications—either misdiagnose outlier genesis, sacrifice generality, or increase implementation complexity.
2. Theoretical Origin of Activation Outliers
TWEO identifies the root cause of extreme activations as a mechanical artifact of weight-matrix structure in transformer MLP blocks, specifically strong colinearity between up- and down-projection layers, rather than data characteristics or special token frequencies. For a simplified linear MLP,
If is given by its SVD , the -th output is
where is the -th row of . If both and align strongly with the same singular vectors, 0 becomes arbitrarily large, even with random inputs—demonstrating data-independence. This is empirically validated, e.g., in a ViT-B model, giving predicted and observed maximum values within 0.5% relative error.
3. TWEO Loss Regularizer
To mitigate this issue, the TWEO framework introduces a simple regularizer that directly penalizes large post-residual activations after each transformer block. Given activations 1 for block 2, the total loss is
3
where
4
Parameter settings are: 5 (soft-threshold), 6 (penalty power), 7 (stability), and weighting factor 8 (optionally cosine-annealed). This loss is negligible when activations are small but imposes a steep penalty for values exceeding 9, eliminating extreme outlier tails without discontinuities or architectural coupling.
4. Training Algorithm and Implementation
TWEO integrates seamlessly into standard transformer training, requiring only the addition of the 0 term at each block. All layers—including embeddings, LayerNorm, and output heads—are run under FP8 autocast with NVIDIA Transformer Engine (E4M3/E5M2 format, DelayedScaling, amax_history_len=16). Optimization (AdamW), learning rate schedules, and gradient handling remain as in the baseline. No further clipped-gradient, quantization tricks, or architectural tweaks are utilized.
Key pseudocode logic:
7
5. FP8 Pre-Training Results
TWEO enables stable full FP8 pre-training across GPT-2 model scales (124M–7B) on OpenWebText, whereas standard FP8 baselines collapse. Training throughput improves by 36% compared to BF16, as no modules revert to higher-precision compute.
Table: FP8 Pre-training Results (OpenWebText)
| Model | BF16 PPL | FP8 Baseline PPL | FP8+TWEO PPL | Peak Outlier |
|---|---|---|---|---|
| GPT-2-124M | 20.04 | 169.81 (collapse) | 19.26 | 17 |
| GPT-2-350M | 16.77 | collapse | 15.64 | 19 |
| GPT-2-774M | 14.78 | collapse | 13.89 | 18 |
| GPT-2-1.6B | 13.84 | collapse | 12.58 | 19 |
| GPT-2-3.0B | – | collapse | 12.24 | 18 |
| GPT-2-7.0B | – | collapse | 12.02 | 20 |
TWEO regularization clamps outlier magnitudes below 20 in all layers, and training/validation curves match the BF16 baseline.
6. Quantization: W8A8 and Residual Stream
TWEO suppresses activation extremes, making previously intractable static per-tensor 8-bit (W8A8) quantization practical. Symmetric AbsMax quantization is used, supporting per-tensor (T), per-channel (C, for weights), and per-token (K, for activations) strategies:
- 1
- 2
- 3
- 4
Table: PTQ with AbsMax Static Quantization (GPT-2 Family)
| Model / Method | BF16 PPL | W8(T)A8(T) / W8(T)A8(K) | W8(C)A8(T) / W8(C)A8(K) |
|---|---|---|---|
| GPT-2-124M (default) | 20.04 | 86.60 / 22.02 | 82.94 / 21.49 |
| GPT-2-124M (+TWEO) | 18.83 | 20.82 / 19.51 | 20.54 / 19.00 |
| GPT-2-350M (default) | 16.77 | 1451.4 / 19.76 | 1456.97 / 19.95 |
| GPT-2-350M (+TWEO) | 15.18 | 16.50 / 15.53 | 16.32 / 15.40 |
| ... | ... | ... | ... |
TWEO-trained models match or outperform BF16 PPL with even the fastest per-tensor PTQ.
Quantizing the residual stream (5) becomes feasible for the first time, outperforming prior "difficulty transfer" approaches (e.g., SmoothQuant, AWQ) that typically cannot quantize 6 without collapse.
Table: Residual-Stream Quantization (GPT-2-XL)
| Method | Residual Quant? | W8(C)A8(T) / W8(C)A8(K) |
|---|---|---|
| SmoothQuant (default) | no | 14.81 / 14.01 |
| SmoothQuant (default) | yes | 1876.70 / 21.93 |
| AbsMax on TWEO | yes | 13.06 / 12.63 |
| SmoothQuant on TWEO | yes | 12.89 / 12.51 |
Vision models (e.g., ViT-B) also benefit: under W6A6 quantization, top-1 accuracy recovers to 66.4%, up from 7.4% baseline.
7. Ablations, Sensitivity, and Deployment
Extensive ablations show:
- Varying 7 and 8 consistently yields strong outlier suppression.
- All blocks' activation tails are equally suppressed; no per-layer tuning required.
- The regularizer scales across model depth (12–48 layers) and width (124M–7B).
- 9 can be fixed (0) or cosine-annealed with similar results.
Deployment recommendations:
- Insert the 1 term after each transformer block with 2, 3, 4.
- Use 5 (optionally cosine-annealed to 6).
- Run the entire model—including embeddings, LayerNorm, and heads—under FP8 autocast.
- No additional engineering, architectural changes, or quantization-specific tricks are necessary.
Limitations and Potential Directions:
- Scalability beyond 7B parameters remains untested.
- Fine-tuning legacy BF16 checkpoints for outlier removal is uninvestigated.
- Extending the approach to enable stable FP4 training and inference is a future prospect.
TWEO offers a theoretically justified, implementation-efficient remedy for transformer outliers, supporting FP8 and post-training W8A8 quantization with state-of-the-art accuracy and throughput (Liang et al., 28 Nov 2025).