Purpose
Meta Lingua is a minimal, fast training and inference library for large language model (LLM) research. It uses easy-to-modify PyTorch components, making it convenient for researchers to experiment with new architectures, loss functions, data, and more. Its goal is to support end-to-end training, inference, and evaluation, and to provide tools for better understanding training speed and stability. The project is positioned for researchers who want to experiment with new ideas for LLM pretraining and quickly get feedback on training/inference speed and downstream benchmarks, aiming to lower the barrier to entry for LLM research through a lightweight, focused codebase.
Main capabilities
- End-to-end workflow: Supports training, inference, and evaluation.
- Training configuration: Provides multiple apps to show how to use the codebase; the main training loop is located in
apps/main. - Model architecture:
transformer.pydefines the model architecture, as pure PyTorchnn.Module. - Distributed support:
distributed.pydistributes the model across multiple GPUs via theparallelize_modulefunction, and can combine data parallelism, fully sharded data parallelism (FSDP), model parallelism,torch.compile, activation checkpointing, and float8. - Data loading:
data.pyprovides a data loader for LLM pretraining. - Performance analysis:
profiling.pyis a small wrapper around the xformers profiler, can automatically compute MFU and HFU, saves profile traces to the profiling folder under the dump directory, and provides memory profiling traces. - Checkpoint management:
checkpoint.pysaves the model in the checkpoints folder under the dump directory in.distcpformat (PyTorch's new distributed saving method); this format allows the model to be reloaded with a different number of GPUs and different sharding schemes, and can also be converted to a regular PyTorch checkpoint viatorch.distributed.checkpoint.format_utils.dcp_to_torch_save, and conversely usingtorch_save_to_dcp. - Configuration tools:
args.pyuses dataclasses to represent configuration objects, and supports conversion betweenconfig.yaml, configuration dictionaries, and dataclasses. For example,apps/main/train.pyinTrainArgscontains subitems such asLMTransformerArgs、OptimArgs. - Command-line arguments:
train.py、eval.py、stool.pyuses OmegaConf and accepts arguments in dot-list form (such asmodel.dim=32)。train.pytakes a configuration file path as an argument; the behavior is: first instantiate TrainArgs with default values, then override the defaults with values from the configuration file, and finally override the result with additional arguments provided on the command line. - SLURM launch:
lingua/stool.pycan save the configuration to dump_dir, copy the current code to dump_dir as a backup, createsubmit.slurm, and launch the job with the given configuration; it can be used via the command line or by directly calling thelaunch_jobfunction, the latter being convenient for creating many configurations in a jupyter notebook (such as parameter sweeps and ablation experiments) and launching jobs directly.
Usage
The materials provide instructions for steps such as environment creation (creating the environment via a SLURM job, about 5 minutes, excluding downloads), activating the environment, data download and preparation (downloading fineweb_edu, fineweb_edu_10bt, or dclm_baseline_1.0 from huggingface; the default nchunks is 32, and if there are fewer than 32 GPUs it is recommended to set it to 1 or equal to the number of GPUs), downloading the tokenizer (llama3), and launching a debug job, but the specific command code is given in the materials in code blocks and is not repeated here.
Note: The provided configuration is a template and needs to be adjusted (such as dump_dir、data.root_dir、data.tokenizer.path , etc.). When using stool, if the job crashes, you can use sbatch Restart. For fast iteration, it is recommended to have SLURM allocate resources and then run multiple commands on the same allocation. When debugging with pdb, use -n 1 Run on only 1 GPU. Evaluation can be run periodically during training, or evaluation can be launched directly for a given checkpoint; the dump directory for the checkpoint and evaluation must be specified in the configuration.
Applicable scenarios
- Experimenting with new architectures, new losses, and new data for LLM pretraining.
- Quickly getting feedback on training/inference speed and downstream benchmarks.
- Typical workflow (as suggested by the material): first test new ideas in Lingua, then scale up with Torchtitan, and finally use Torchtune for instruction or preference fine-tuning.
Limitations and notes
- The project is still under development.
- Training results show strong performance on many downstream tasks, matching the DCLM baseline 1.0 on a 1B model with 60B DCLM tokens (as stated in the source material).
- It uses the BSD-3-Clause license; see the LICENSE file in the top-level directory for details.
- The material does not provide more information such as specific fees, pricing, or the scope of platform support.