Modalities, a PyTorch-native Framework For Large-scale LLM Training and Research

Max Lübbering, Timm Ruland, Richard Rutmann, Felix Stollenwerk, David Fitzek, Michael Fromm, Alexander Weber, Rafet Sifa, Nicolas Flores-Herr, Joachim Köhler, Mehdi AliarXiv 2026

TL;DR

Modalities is an end-to-end, PyTorch-native framework designed to bridge the gap between rigid production-grade LLM pretraining and highly flexible research experimentation. By combining a modular, declarative configuration system with advanced parallelization strategies, it allows researchers to seamlessly swap components and scale systematic ablation studies up to 1000+ GPUs without modifying the core codebase.

What Problem Does This Paper Address?

Large Language Model (LLM) pretraining is incredibly expensive, leaving a razor-thin margin for error. Consequently, existing open-source frameworks typically fall into one of two camps:

  1. Production-oriented frameworks (e.g., NeMo, Bridge) provide rigid, well-tested recipes for established architectures but lack the flexibility needed for novel research.
  2. Research-oriented codebases (e.g., MegatronLM, TorchTitan) offer hackable reference implementations but leave the burden of engineering complex, reproducible ablation setups entirely to the user.

Because LLM research is heavily data-driven, researchers frequently need to run massive ablation studies (testing different architectures, data mixes, or hyperparameters). Without a framework that supports both agility and scale, researchers waste significant time writing custom wrappers and scripts, which hurts reproducibility and slows down innovation.

Methods

Modalities introduces a clean separation between experimental setup and execution through a decoupled, modular architecture:

  • Declarative Construction: The entire training setup is defined as an interface-level dependency graph within a self-contained YAML configuration file. At runtime, a registry-factory mechanism resolves this graph into a validated object graph. Modalities ships with 93 pluggable components implementing 32 pre-defined interfaces (IFs). Misconfigurations are automatically caught before execution begins.
Figure 1: High-level Modalities architecture. A self-contained YAML configuration defines an interface-level dependency graph that is resolved via a registry–factory mechanism into a resolved object graph. The resulting object graph is validated and injected into a generic SPMD training driver for distributed training and evaluation.
  • Advanced Parallelization: Built on the single-program multiple-data (SPMD) paradigm, Modalities leverages PyTorch-native Fully Sharded Data Parallel (FSDP). To scale beyond vanilla FSDP's typical limits, it integrates tensor parallelism, pipeline parallelism, and hybrid sharded data parallel strategies.
  • Optimized Data Pipeline: The framework features a massively parallel data processing routine (indexation, tokenization, chunking, and global shuffling). It uses a producer-consumer design with a single reader/writer for contiguous I/O and memory-mapped files to allow $O(1)$ random access to tokenized documents.

Datasets

To evaluate the framework, the authors benchmarked it by training an 8-billion parameter LLaMA 3 model using a 100-billion token subset of the FineWeb-Edu dataset.

Key Insights and Ideas

  • Plug-and-Play Research: By establishing strict interface-level contracts (e.g., an nn.Module model interface), a researcher can implement a brand-new model architecture, register it via the API, and immediately benefit from the framework's existing distributed checkpointing and evaluation suites without touching the core training loop.
  • Tackling Communication Latency at Scale: As distributed training scales up to 1024 ranks (GPUs), the global message sizes for standard FSDP collectives (like all-gather and reduce-scatter) shrink. This can cause the network interconnect to become latency-bound rather than bandwidth-bound. Modalities solves this by implementing adaptable FSDP unit sizes, trading a small memory overhead for significantly improved NCCL communication bandwidth.

Key Results

The authors evaluated Modalities against TorchTitan, Bridge, and NeMo on the Leonardo Supercomputer:

  • Convergence and Throughput: Modalities achieved identical training loss convergence to the other major frameworks while demonstrating strong scaling behavior up to 1024 ranks.
Benchmarking results for an 8B LLaMA 3 model showing training loss equivalence, throughput scaling, and NCCL bandwidth.
  • Blazing Fast Data Processing: Thanks to its optimized producer-consumer architecture, the Modalities data pipeline achieved an average end-to-end throughput of 31 million tokens per second, making it 7x faster than the MegatronLM implementation when benchmarked on a single DGX A100 node.
  • Ecosystem Integration: Modalities plays nicely with the Hugging Face ecosystem, supporting any decoder-only model out-of-the-box and providing built-in routines to convert distributed PyTorch checkpoints into Hugging Face-compatible formats.

Limitations and Future Work

While Modalities provides excellent out-of-the-box support for decoder-only Transformer architectures, the paper focuses primarily on text modalities. Extending this declarative, interface-driven approach to multi-modal architectures (e.g., vision-language models) or alternative architectures like state-space models remains an open avenue for future development.

Summary updated

BibTeX
@misc{lubbering2026modalities,
  author = {Max Lübbering and Timm Ruland and Richard Rutmann and Felix Stollenwerk and David Fitzek and Michael Fromm and Alexander Weber and Rafet Sifa and Nicolas Flores-Herr and Joachim Köhler and Mehdi Ali},
  title = {{Modalities, a PyTorch-native Framework For Large-scale LLM Training and Research}},
  year = {2026},
  eprint = {2602.08387},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.08387},
}
Figure