ALTO is a Python library for low-precision model training and optimization, built on top of the TorchTitan fork. It ships Triton-backed low-precision kernels (MXFP4, NVFP4, block-scaled FP8, and related utilities) and a configurable stack of modifiers—low-precision training (LPT)—wired into TorchTitan through a model-converter pipeline.
Training-oriented kernels and schemes include:
- Blockwise FP8 — linear, grouped GEMM, and FlashAttention.
- MXFP4 — linear, grouped GEMM, and FlashAttention.
- MXFP8 — linear and grouped GEMM (block-scaled E4M3, with E5M2 reserved for gradients).
- NVFP4 — linear and grouped GEMM, using an E4M3 inner-block scale with an optional two-level (tensorwise) outer scale.
Techniques used to narrow the gap versus BF16 include:
- 2D block quantization
- Randomized Hadamard Transform (RHT)
- Stochastic Rounding (SR)
- Differential Gradient Estimation (DGE)
- Two-Level Scaling
- blockwise (128-dim macro-block for MXFP4)
- tensorwise (for NVFP4)
- Weight De-Oscillation
- see PR #25
Recipes can combine multiple stages under alto/modifiers/, e.g. Low-Precision Training (LPT) Modifier.
Recipe YAML follows the same general shape as llm-compressor; use the configs under alto/models/*/configs/ as concrete templates.
| Model | Integration notes |
|---|---|
| Llama 3 | * Extended state dict adapter for observer and modifier state; * Config registry hooks for TorchTitan. |
| DeepSeek V3 | Config registry hooks for TorchTitan. |
| GPT-OSS | Config registry hooks for TorchTitan. |
- Python 3.9+
- PyTorch 2.9+ (see
pyproject.tomlfor the full dependency set:torchao,safetensors,compressed_tensors,lm_eval, etc.) - GPU — training paths expect ROCm/CUDA-capable hardware; see TorchTitan documentation for parallel layout details.
Clone the repository with submodules so the vendored TorchTitan tree is present:
git clone --recurse-submodules https://github.com/AMD-AGI/ALTO.git
cd ALTOIf you already cloned without submodules:
git submodule update --init --recursiveInstall the TorchTitan tree shipped under 3rdparty/torchtitan, then install ALTO in editable mode:
pip install --no-build-isolation -e 3rdparty/torchtitan
pip install -e .- Author or copy a recipe YAML (see existing files under
alto/models/<model>/configs/). - Register a TorchTitan config that attaches ALTO’s converter to
model_converters.
Example (Llama 3 registry pattern):
from torchtitan.components.model_converter import ModelConvertersContainer
from alto.components.converter import ModelOptConverter
config.model_converters = ModelConvertersContainer.Config(
converters=[
ModelOptConverter.Config(recipe="./alto/models/llama3/configs/recipe.yaml"),
],
)Each model's config_registry.py starts from the upstream recipe when one exists, then restores the ALTO dataset, batch, checkpoint, and modifier settings. examples/run.sh selects ALTO's trainer through TRAIN_FILE (default alto.train).
From the repository root, the shared launcher wraps torchrun and python -m alto.train:
NGPU=8 MODULE=llama3 CONFIG=your_config_name ./examples/run.shExtra arguments are forwarded to alto.train. Besides the TorchTitan loader options (--override, --output-dir, --resume-step, ...), dotted config field overrides are accepted, e.g. --training.steps 10 --checkpointer.folder ckpt. Overrides are applied after the config function runs. Recorded model configs are then rebuilt using the original flavor and attention backend, with the final parallelism settings and training.max_context_length.
Environment variables (see examples/run.sh):
| Variable | Role |
|---|---|
NGPU |
Processes per node (default 8). |
MODULE |
Model name (llama3, gpt_oss, …) resolving to alto.models.<name>.config_registry, or a fully qualified module. |
CONFIG |
Registered config function name. |
TRAIN_FILE |
Python module for training entrypoint (default alto.train). |
COMM_MODE |
Optional: fake_backend for config checks with fake process groups. |
-
Recipe:
alto/models/gpt_oss/configs/lpt_recipe.yamluses
LowPrecisionTrainingModifierwithscheme: "mxfp4". -
Config:
gpt_oss_20b_lpt. This config builds the Primus-Megatron-style20b_megatronflavor and keeps ALTO's pretraining batch, learning rate, and Megatron data settings.gpt_oss_debugmodel_lptremains available for a small upstream debug run. -
Run:
NGPU=8 MODULE=gpt_oss CONFIG=gpt_oss_20b_lpt ./examples/run.sh
Illustrative recipe fragment:
training_stage:
lpt_modifiers:
LowPrecisionTrainingModifier:
scheme: "mxfp4" # also supports "nvfp4" (plus "mxfp8_e4m3" / "mxfp8_e5m2")
targets: ["Linear", "GptOssGroupedLinear"]
ignore: ["lm_head", "re:.*\\.router\\.gate"]
use_2dblock_x: false
use_2dblock_w: true
use_hadamard: true
use_sr_grad: true
use_dge: false
# Use "tensorwise" to enable NVFP4's outer scale
two_level_scaling: none
# Step to enable weight de-oscillation. 0 means disabled.
# If 0, weight de-oscillation is disabled.
deosc_step: 2000To train the same model with NVFP4 instead, set scheme: "nvfp4" and two_level_scaling: "tensorwise".
TorchTitan typically saves checkpoints in PyTorch DCP format; you can convert to Hugging Face Safetensors and run lm-eval tasks with the bundled export utility:
python ./alto/utils/exportation/export.py \
alto.models.llama3.config_registry llama3_1b_opt \
--tasks wikitext- Homepage github.com/AMD-AGI/ALTO
- TorchTitan submodule: github.com/AMD-AGI/torchtitan-amd (
3rdparty/torchtitan)
For questions, issues, or contributions, please reach out to the maintainers:
- @guanchenl
- @hann-wang
- @ysa2215
- @zhitwang17
See CODEOWNERS for the full ownership list.