How Surogate Works
EngineSurogate EngineSurogate 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.
Core Architecture
Section titled “Core Architecture”1. Native C++/CUDA Execution Engine
Section titled “1. Native C++/CUDA Execution Engine”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.
2. DSL + Graph Compiler
Section titled “2. DSL + Graph Compiler”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.
3. Graph-Based Autodiff
Section titled “3. Graph-Based Autodiff”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.
4. Multi-threaded Scheduler
Section titled “4. Multi-threaded Scheduler”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.
5. Mixed-Precision & Quantization
Section titled “5. Mixed-Precision & Quantization”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.
Scalability
Section titled “Scalability”Multi-GPU Training
Section titled “Multi-GPU Training”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.
Multi-Node with Ray
Section titled “Multi-Node with Ray”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.
Deployment & Production
Section titled “Deployment & Production”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.