S-exp GPU

The ML framework built for agents

ML research at the speed of thought.

Your agent writes one Lisp file. The compiler checks every shape in milliseconds on a laptop, so mistakes die before they reach a GPU. Then it trains faster than PyTorch on NVIDIA GPUs.*

$ curl -fsSL https://sx.041.io/install.sh | sh
See the loop ↓

macOS · Linux · one binary, no Python · Agents: curl /llms.txt

Getting started

The loop, in milliseconds.

  1. 01

    Start from a file

    One file holds the data, the model, the objective, the optimizer and the run. Nothing else: the compiler owns the training loop.

    Show minimal.sx
    (require "sexpgpu/nn" cross-entropy gpt)
    (require "sexpgpu/optim" sgd)
    
    (defvar train-loader
      (loader :sources [(files ["data/tiny-train.jsonl.gz"] :encoding "jsonl.gz")]
              :fields [(field :tokens :from "input_ids" :dtype :i32 :shape [17])]
              :batch-size 4
              :infinite true))
    
    (defun prepare (batch)
      (let ((tokens (field batch :tokens)))
        (list :inputs (slice tokens 1 0 16) :targets (slice tokens 1 1 17))))
    
    (defvar model (gpt :vocab 32 :layers 2 :dim 32 :heads 2))
    
    (defun objective (prediction targets) (cross-entropy prediction targets))
    
    (defvar optimizer (sgd :lr 0.5))
    
    (defrun :steps 20 :microbatches 2 :precision :f32 :seed 1)
    zsh
    $ sexpgpu new minimal.sx --example minimal
    wrote minimal.sx and data/tiny-train.jsonl.gz from the `minimal` example: 32 parameters, 20 steps
  2. 02

    Check it on a laptop

    Every shape of every graph, in milliseconds, with no GPU and no data. A mistake names your line, the shapes and the fix, and --json hands it to an agent.

    zsh
    $ sexpgpu check minimal.sx
    ok: 32 parameters, 38 graphs, 20 steps
    
    $ sexpgpu check bad-shape.sx
    error[E-DIM-001]: matmul: inner dims differ: [2, 16] x [32, 8]
      --> bad-shape.sx:7:15
       |
     7 |   (lambda (x) (matmul x weight)))
       |               ^^^^^^^^^^^^^^^^^
    note: operands: `x` [2, 16] f32, `weight` [32, 8] f32
  3. 03

    Run it here, then on any GPU

    explain reads back what will run. Train here on the CPU or Metal, then bundle the same run and send it to the cheapest cloud GPU with rrun by 041.

    zsh
    $ sexpgpu run minimal.sx
    done: 20 steps, train/loss 2.6462
    
    $ sexpgpu bundle minimal.sx -o ~/.sexpgpu/bundles/minimal \
        --binary ~/.sexpgpu/linux-x86_64/sexpgpu
    $ cd ~/.sexpgpu/bundles/minimal
    $ o41-rrun run --gpu RTX3090,L4,A100 --spot --cuda 13.0 \
        --image nvidia/cuda:13.0.3-cudnn-runtime-ubuntu24.04 \
        --env SEXPGPU_DEVICE=cuda -f -- ./run.sh
    lowering: cuda compute_86 NVIDIA GeForce RTX 3090, patterns on
    done: 20 steps, train/loss 2.6462
    [rrun] j-qp6j3k9cpk succeeded exit 0 after 8s

Why agents get it right

One file is the experiment. The compiler owns the rest.

Errors at your line, before the GPU

Every diagnostic has a code, your line, the shapes it expected and got, and the fix. Agents read it as JSON. check →

The plan and the run agree

explain states every knob and where its value came from, the optimizer groups and the memory. diff shows what changed between two runs, and nothing else. explain →

No loop to get wrong

Autodiff, accumulation, evaluation, checkpoints, precision and kernels belong to the compiler, so none of it is subtly wrong in your file. the run file →

A real Lisp, one binary

Closures and macros at compile time: one macro writes the ablation grid. One binary, no Python: bundle a run once, and on rrun a preempted spot run continues on the next GPU. macros →

The cherry on top

And on NVIDIA GPUs it trains faster than PyTorch.*

SexpGPU compiles the whole training step for the device it runs on, with no Python anywhere in the loop; on an NVIDIA GPU that is fused kernels, cuBLAS and cuDNN attention. Each tab times the same models against torch.compile on that device.

NVIDIA A100 80GB

On every one of the 14 models we measure on the NVIDIA A100 80GB it takes less time per step than the same model under torch.compile.

Training step time against torch.compile

Same model, same data, on an NVIDIA A100-SXM4-80GB and an NVIDIA A100 80GB PCIe: SexpGPU's CUDA device against torch.compile. Lower is faster: a shorter bar takes less time per step. The line is torch.compile.

Diffusion denoiserf32
Tiny Mambaf32
Tiny hyperbolic (Lorentz) GPTf32
Two-tower InfoNCEf32
Tiny GPT, Muonf32
Tiny RetNetf32
Tiny GPT, AdamWf32
Tiny GPT, AdamWbf16
Tiny nGPTbf16
Geometric transformer, Riemannian Adamf32, 512 sequences a step
MLP-Mixerf32
ResNet-9, CIFAR-10bf16
Tiny GPT, 8 expertsbf16, top-2
GPT-2 small, 124Mbf16
Show the numbers
modelSexpGPU s/steptorch.compile s/stepstep time
Diffusion denoiser, f320.0007750.0022380.35×
Tiny Mamba, f320.10420.24940.42×
Tiny hyperbolic (Lorentz) GPT, f320.016980.035980.47×
Two-tower InfoNCE, f320.0007580.0015950.48×
Tiny GPT, Muon, f320.070430.14250.49×
Tiny RetNet, f320.072960.14320.51×
Tiny GPT, AdamW, f320.071410.12030.59×
Tiny GPT, AdamW, bf160.018830.027870.68×
Tiny nGPT, bf160.02430.035170.69×
Geometric transformer, Riemannian Adam, f32, 512 sequences a step44.5263.260.70×
MLP-Mixer, f320.0014240.0018450.77×
ResNet-9, CIFAR-10, bf160.0099660.012310.81×
Tiny GPT, 8 experts, bf16, top-20.024160.029810.81×
GPT-2 small, 124M, bf162.5243.0170.84×

* Limited benchmark. 14 training runs on an NVIDIA A100-SXM4-80GB and an NVIDIA A100 80GB PCIe (drivers 595.91.07 to 620.70.06, CUDA 13.0), each timed against the same model under torch.compile 2.14.0+cu130, on the same data, with SexpGPU 0.2.0. Step time is the mean of run medians over steady-state steps, measured on 5 November 2026. Both sides of a row ran one after the other on one card; rows ran on different cards of that type, and the public table records each card's driver and versions. A row timed in several jobs shows the one least favourable to SexpGPU: on the smallest models torch.compile's step is bound by the host's CPU, which differs from machine to machine. No listed model is slower than torch.compile today. Every model not listed here is unmeasured on this device. We treat any model where we are slower as a bug.

NVIDIA H100

On every one of the 14 models we measure on the NVIDIA H100 it takes less time per step than the same model under torch.compile.

Training step time against torch.compile

Same model, same data, on an NVIDIA H100 PCIe, an NVIDIA H100 80GB HBM3 and an NVIDIA H100 NVL: SexpGPU's CUDA device against torch.compile. Lower is faster: a shorter bar takes less time per step. The line is torch.compile.

Diffusion denoiserf32
Two-tower InfoNCEf32
MLP-Mixerf32
Tiny hyperbolic (Lorentz) GPTf32
Tiny Mambaf32
Tiny nGPTbf16
Tiny GPT, AdamWbf16
Tiny GPT, AdamWf32
Tiny GPT, Muonf32
Tiny RetNetf32
Tiny GPT, 8 expertsbf16, top-2
GPT-2 small, 124Mbf16
Geometric transformer, Riemannian Adamf32, 512 sequences a step
ResNet-9, CIFAR-10bf16
Show the numbers
modelSexpGPU s/steptorch.compile s/stepstep time
Diffusion denoiser, f320.0006030.0047780.13×
Two-tower InfoNCE, f320.000460.001810.25×
MLP-Mixer, f320.0007820.0019480.40×
Tiny hyperbolic (Lorentz) GPT, f320.010040.0230.44×
Tiny Mamba, f320.056550.12740.44×
Tiny nGPT, bf160.012520.022150.57×
Tiny GPT, AdamW, bf160.011410.017370.66×
Tiny GPT, AdamW, f320.035310.053060.67×
Tiny GPT, Muon, f320.049970.073050.68×
Tiny RetNet, f320.056650.07940.71×
Tiny GPT, 8 experts, bf16, top-20.013650.018580.73×
GPT-2 small, 124M, bf161.0991.2820.86×
Geometric transformer, Riemannian Adam, f32, 512 sequences a step25.7229.70.87×
ResNet-9, CIFAR-10, bf160.0059450.0061930.96×

* Limited benchmark. 14 training runs on an NVIDIA H100 PCIe, an NVIDIA H100 80GB HBM3 and an NVIDIA H100 NVL (drivers 580.159.03 to 610.57.04, CUDA 13.0), each timed against the same model under torch.compile 2.14.0+cu130, on the same data, with SexpGPU 0.2.0. Step time is the mean of run medians over steady-state steps, measured on 5 November 2026. Both sides of a row ran one after the other on one card; rows ran on different cards of that type, and the public table records each card's driver and versions. A row timed in several jobs shows the one least favourable to SexpGPU: on the smallest models torch.compile's step is bound by the host's CPU, which differs from machine to machine. No listed model is slower than torch.compile today. Every model not listed here is unmeasured on this device. We treat any model where we are slower as a bug.

Apple M1 Pro

On 4 of the 7 models we measure on the Apple M1 Pro it takes less time per step than the same model under torch.compile, on 2 it is within 2% of it and on 1 it takes longer.

Training step time against torch.compile

Same model, same data, on an Apple M1 Pro: SexpGPU's Metal device against torch.compile on MPS. Lower is faster: a shorter bar takes less time per step. The line is torch.compile.

Tiny Mambaf32
Diffusion denoiserf32
Tiny hyperbolic (Lorentz) GPTf32
Two-tower InfoNCEf32
MLP-Mixerf32
Tiny RetNetf32
Tiny GPT, AdamWf32
Show the numbers
modelSexpGPU s/steptorch.compile s/stepstep time
Tiny Mamba, f323.03110.330.29×
Diffusion denoiser, f320.0047940.0062030.77×
Tiny hyperbolic (Lorentz) GPT, f320.54090.69580.78×
Two-tower InfoNCE, f320.0047110.0058910.80×
MLP-Mixer, f320.01340.013441.00×
Tiny RetNet, f322.3432.3361.00×
Tiny GPT, AdamW, f322.3552.2991.02×

* Limited benchmark. 7 training runs on an Apple M1 Pro (macOS 27.2), each timed against the same model under torch.compile 2.14.0 on MPS, on the same data, with SexpGPU 0.2.0. Step time is the mean of run medians over steady-state steps, measured on 5 November 2026. Both sides of a row ran one after the other on one machine, each checked first against a float64 reference. Tiny GPT, AdamW (1.02×) takes longer than under torch.compile today, as a multiple of torch.compile's step time. Every model not listed here is unmeasured on this device. We treat any model where we are slower as a bug.

AMD MI300X

On 5 of the 7 models we measure on the AMD MI300X it takes less time per step than the same model under torch.compile and on 2 it takes longer.

Training step time against torch.compile

Same model, same data, on an AMD Instinct MI300X VF: SexpGPU's ROCm device against torch.compile. Lower is faster: a shorter bar takes less time per step. The line is torch.compile.

MLP-Mixerf32
Tiny GPT, Muonf32
Tiny GPT, AdamWf32
Tiny RetNetf32
Tiny nGPTbf16
Tiny GPT, 8 expertsbf16, top-2
ResNet-9, CIFAR-10bf16
Show the numbers
modelSexpGPU s/steptorch.compile s/stepstep time
MLP-Mixer, f320.0013320.0025160.53×
Tiny GPT, Muon, f320.033310.062410.53×
Tiny GPT, AdamW, f320.031550.039440.80×
Tiny RetNet, f320.033160.035910.92×
Tiny nGPT, bf160.023720.025530.93×
Tiny GPT, 8 experts, bf16, top-20.025010.023231.08×
ResNet-9, CIFAR-10, bf160.021840.0078222.79×

* Limited benchmark. 7 training runs on an AMD Instinct MI300X VF (driver 6.16.13, ROCm 7.2.0), each timed against the same model under torch.compile 2.14.0+rocm7.2, on the same data, with SexpGPU 0.1.4-nightly.20261104.9da269e. Step time is the mean of run medians over steady-state steps, measured on 4 November 2026. Both sides of a row ran one after the other on one card; rows ran on different cards of that type, and the public table records each card's driver and versions. ResNet-9, CIFAR-10 (2.79×) and Tiny GPT, 8 experts (1.08×) take longer than under torch.compile today, as a multiple of torch.compile's step time. GPT-2 small, 124M and Geometric transformer, Riemannian Adam are not listed: torch.compile crashes on ROCm. Every other model is unmeasured on this device. We treat any model where we are slower as a bug.

Linux CPU

On every one of the 4 models we measure on the Linux CPU it takes longer per step than the same model under torch.compile: 1.20× to 1.48× its step time.

Training step time against torch.compile

Same model, same data, on an Intel Xeon Platinum 8488C, 8 cores, 16 threads: SexpGPU's CPU device against torch.compile on the CPU. Lower is faster: a shorter bar takes less time per step. The line is torch.compile.

Two-tower InfoNCEf32
Diffusion denoiserf32
MLP-Mixerf32
Tiny GPT, AdamWf32
Show the numbers
modelSexpGPU s/steptorch.compile s/stepstep time
Two-tower InfoNCE, f320.011550.0096351.20×
Diffusion denoiser, f320.011820.0095441.24×
MLP-Mixer, f320.029130.023181.26×
Tiny GPT, AdamW, f323.7682.5461.48×

* Limited benchmark. 4 training runs on an Intel Xeon Platinum 8488C, 8 cores, 16 threads (Ubuntu 22.04.5 LTS), each timed against the same model under torch.compile 2.14.0+cu130 on the CPU, on the same data, with SexpGPU 0.2.0. Step time is the mean of run medians over steady-state steps, measured on 5 November 2026. Both sides of a row ran one after the other on one machine, each checked first against a float64 reference. A row timed on several machines of that type shows the one least favourable to SexpGPU. Tiny GPT, AdamW (1.48×), MLP-Mixer (1.26×), Diffusion denoiser (1.24×) and Two-tower InfoNCE (1.20×) take longer than under torch.compile today, as a multiple of torch.compile's step time. Every model not listed here is unmeasured on this device. We treat any model where we are slower as a bug.

Hand it to your agent.

Every page of this site answers in markdown, short and dense, one question per page, so an agent reads only what it needs.

zsh
$ curl https://sx.041.io/llms.txt