Skip to content
SurogateSurogateDocs
↑↓ to move↵ to openesc to close

How Surogate Works

Surogate is built to train Large Language Models (LLMs) as fast and efficiently as possible on modern NVIDIA hardware. Many frameworks stack high-level abstractions that add overhead. Surogate instead pairs Python’s flexibility with CUDA’s raw performance through a DSL-driven compiler pipeline: you describe models in Python, and a native engine runs them.

At the center of Surogate is an engine written in C++ and CUDA. It gives you:

  • Near-zero overhead: Python-to-CUDA dispatch latency is kept to a minimum.
  • Custom kernel fusions: specialized kernels combine several operations (such as activation, normalization and projection) into a single pass, which greatly reduces memory-bandwidth bottlenecks.
  • Memory management: fine-grained control over how GPU memory is allocated and reused.

You define model architectures with a decorator-based Python DSL. The DSL produces explicit forward graphs and serializes them to a JSON IR, which the runtime executes. This gives you:

  • Custom architectures without changing C++/CUDA code
  • Static shape metadata for planning and verification
  • Save/recompute annotations for memory-efficient training
  • Stable tensor naming for deterministic checkpointing

See the DSL Language Specification for details.

Surogate derives the backward graph from the forward graph ahead of time. Because the backward pass is generated at compile time instead of at runtime, Surogate can:

  • Optimize whole-graph execution (fusion, dead code elimination)
  • Plan memory across forward and backward passes
  • Avoid Python overhead during training

See Automatic Differentiation (Autodiff) for details.

A custom multi-threaded backend runs data loading, gradient synchronization and kernel dispatch in parallel. This keeps the GPU busy instead of waiting for the next batch of data or for CPU-bound work.

Surogate supports a wide range of mixed-precision training:

  • BF16 and FP8: native support for these data types on Hopper (H100/H200) and Blackwell (B200) GPUs.
  • NVFP4: 4-bit floating-point training on Blackwell GPUs.
  • Stochastic rounding: used in low-precision training to keep numerics stable without giving up speed.

The Precision & Recipes guide explains how to choose between them.

Surogate uses an efficient Distributed Data Parallel (DDP) strategy. Multi-threading lets it overlap gradient communication with computation, so throughput scales almost linearly as you add GPUs. See Multi-GPU Training.

For larger runs, Surogate uses Ray to manage multi-node clusters, so the same setup carries over from a single workstation to a large GPU cluster. See Multi-Node Training.

Surogate aims for reliable, repeatable runs. Deterministic configurations and explicit training “recipes” mean you can expect predictable results from run to run.

Next: Installation gets Surogate running, and Training Modes helps you pick a workflow.