Skip to content

Table of Contents

🏁 Getting Started

Your first job.

  • Installation: Install d9d from PyPI or from a checkout, and the optional extras.
  • Quickstart: Train a small model on one GPU and learn the parts of a d9d job.

💡 Concepts

The ideas behind d9d.

  • How d9d Works: The parts of a job, the model build, parameter placements, packs and pipeline programs, the training loop, checkpoints and events.
  • Choosing Parallelism: Where to learn the parallelism strategies and how to apply them in d9d.
  • d9d and Other Frameworks: How the design of d9d compares with Megatron-Core, torchtitan, DeepSpeed, Accelerate and others, and when to choose each.

🍳 Guides

Solutions for concrete tasks.

  • Write Your Own Job: Turn the Quickstart script into a job for your own model, data and loss.
  • Running Jobs: Launch on one GPU, several GPUs or several nodes. Checkpoints, resuming and export.
  • Fine-Tune a Hugging Face Model: Load Qwen3 from a Hugging Face checkpoint, fine-tune all weights or LoRA adapters and export it back.
  • Troubleshooting: Reading the logs of a multi-rank job.

🚀 Execution Engine

How to configure and run jobs.

  • Training Loop: How the Trainer builds a job and runs its steps, data prefetching, profiling, and sleep and wake.
  • Inference Loop: How the Inference engine runs forward passes over a dataset.
  • Checkpointing: What a checkpoint holds, when the job saves, how it resumes and where it must be stored.
  • Random Numbers in the Loop: How the loop seeds each call of user code, and the rules for random numbers in your code.
  • Configuration: The Pydantic models of the training and inference configuration.
  • Interfaces: The providers and tasks that plug your model, data, loss and optimizer into the loop.

💾 Data

Datasets and the streams of microbatches that a job consumes.

  • Data: Dataset wrappers for bucketing, sample concatenation, sharding and padding, and the streams of microbatch packs.

🧠 Modeling

Models, their building blocks and parameter-efficient fine-tuning.

  • Model Catalogue: The models that d9d ships, with their parallelism and Hugging Face state mappers.
  • Decoder with Heads: A decoder backbone composed with one or several task heads, and the pipeline I/O types.
  • Model Design: The rules that your own model must follow to run in the d9d loop.
  • Modules: The building blocks of models: attention, MoE, normalization, heads and other layers.
  • PEFT Overview: How a PEFT method changes the model, which parameters it trains and how it maps the checkpoint.
  • Methods: LoRA, Full Fine-Tuning, and Method Stacking.

📦 Model State

Loading and exporting model weights, including Hugging Face checkpoints.

  • Model State Mapper: Graphs of mappers that transform checkpoint keys and tensors into the model layout and back.
  • Model State I/O: Reading and writing checkpoints in a stream, with a mapper applied on the way.

⚡ Parallelism

Strategies for distributing computations.

  • Distributed Context: The DistributedContext, the assignment of ranks to GPUs and the DeviceMesh domains (base, dense, expert, metric and your own).
  • Horizontal Parallelism: Replicate, FSDP, HSDP and expert parallelism over DTensor placements.
  • Gradient Synchronization: Gradient all-reduce in buckets, overlapped with the backward pass.
  • Gradient Norm and Clipping: The global gradient norm and clipping over parameters with mixed placements.
  • Pipeline Parallelism: Pipeline stages, the schedules from GPipe to DualPipeV and how a model supports them.
  • Pipelining Internals: How the pipeline virtual machine runs programs, and how to write a new schedule.
  • Split Backward: Separate backward passes for input and weight gradients, and the context that custom autograd functions check.

📉 Optimization

Optimizers and learning rate schedules.

📊 Metrics and Tracking

What the job measures and where it goes.

  • Metrics Overview: The Metric interface and its lifecycle: update, sync, compute and reset.
  • Metric Catalogue: The metrics that d9d ships, e.g. a weighted mean, AUROC and the metrics of a confusion matrix.
  • Custom Metrics: How to write your own metric with MetricAccumulator.
  • Metric Collection: Synchronizing and computing a metric on a side CUDA stream, without blocking the loop.
  • Experiment Tracking: The trackers (the log, W&B, TensorBoard, MLflow, Aim), what the loop logs and how to add a tracker.

🧰 Utilities

Low-level helpers: nested tensor structures, moving GPU state to host memory and seeds.

  • PyTree Traversal: Mapping and flattening nested tensor structures, including dataclasses.
  • State Offloading: Moving GPU training state to host memory and back, the base of sleep and wake.
  • Random Number Generation: Deriving seeds from a base seed and keys, equal in every process, and forking the global generators with them.