All pages
Docs · IndexMarkdown
SexpGPU usage
SexpGPU is a Common Lisp for stating machine learning experiments, a compiler that turns one experiment file into a checked IR, and a runtime that trains it on GPUs. Each page answers one question and links the rest.
Every page is also served as markdown at /docs/<page>.md, and /llms.txt lists every page.
Start here
Why SexpGPU
what goes wrong in ML research code and what a one-file experiment fixes
Install
the install script, the published binaries,
sexpgpu update, what a machine needs to run themQuickstart
check, explain and run a first experiment in five commands
How it works
the file, the compile-time Lisp, the IR and the fixed training loop
Working as an agent
the loop, the machine-readable outputs, and the rules that keep a run honest
The run file
The run file
the contract names, their order, and the smallest file that trains
Modules and require
the standard modules, relative libraries, scopes and imports
Knobs, variants and sweeps
everything a run may vary, declared in the file, selected before it is read
Loaders and prepare
sources, fields, stages, batches,
prepare and countersObjective and evaluate
the loss that is optimized, the metrics that are reported
Evaluation passes
defeval: named loaders with a cadence, run inline or from checkpoints with sexpgpu evaluateGeneration inside the step
defgenerate: records made on the device before the step reads themOptimizer groups
configuring an optimizer, selectors, per-group hyperparameters and optimizers
Curriculum and ctx
moving between loader stages, and every
ctx keydefrun
steps, microbatches, precision, seed, checkpoints, diagnostics sampling
The language
It is Common Lisp
the implemented subset, the reader, the deliberate differences, evaluation limits
Special forms
every form the evaluator treats specially, with its shape
Functions and bindings
let, setq, lambda lists, apply, flet, labelsTruth, iteration and values
what is true,
dotimes, dolist, multiple values, stagingMacros and symbols
capture, gensyms,
once-only, macroexpand, generated declarationsBuiltins
every compile-time builtin on ordinary values
The prelude
loaded before every file: every macro and function in it
Tensor operations
shapes, dtypes, broadcasting and every tensor builtin
Nonlinear element scans
independent scalar or small-vector recurrences, runtime sequence loops and gradients
Models and optimizers
Models and parameters
defmodel, defparam, with-loaded, parameter roots and paths, weight tyingPrecision and numerics
:bf16, with-numerics, f32 islands and master weightsRecomputing a loop body
checkpoint: keep an iteration's boundary, recompute the rest in the backwardDeterminism
numerical agreement, measured and recorded choices, and closest reproduction
Writing optimizers
defoptimizer, defstate, optimizer-update, schedulessexpgpu/nn
the standard neural network module, every definition
sexpgpu/optim
the standard optimizer module, every definition
sexpgpu/axes
rearrange and broadcast-axes: split, merge, permute and broadcast named tensor axesThe command line
The command line
every verb, the selection flags, standard streams, exit codes
check and watch
diagnostics in under a second, again on every save
Probe tensor expressions
small CPU fixtures and initialized model outputs without a training contract
explain, diff, ir and eval
what the compiler made of a file, the CUDA lowering report, and what changed between two
new, fmt and variants
starting a run from another or from a built-in example, the one layout, the declared selection
run
training: flags, output, the slug, stopping
sweep
every point of a declared sweep, in order, and where each point checkpoints
bundle and remote runs
one directory that runs anywhere, a run or every point of a sweep as rrun jobs, preemptible jobs, and reading a preempted run
Running a trained model
export a checkpoint as the model alone, serve it behind a socket, and the protocol a program calls it bydoctor
whether a run can start on this machine
feedback
report a bug or feedback from the command line, and what the report carries
Devices
CPU, Apple GPUs through Metal, NVIDIA GPUs through CUDA, AMD GPUs through ROCm, and several GPUs and nodes
Environment
every variable, S3 credentials, and what wins over what
Observing a run
Metrics
targets,
metric, runtime metadata, the series every run reportsDiagnostics
numbers that cost nothing until selected; selection, sampling, the built-in set
Writing diagnostics
diagnostic, reducers, optimizer and gradient diagnosticsGuards
guard, assert-finite and bounds: counts that stop a run at the step they are not zeroJSONL events
the event kinds, annotations and the
open metadataThe status file
the one file to poll, and the final summary
Checkpoints and resume
what a checkpoint holds and
sexpgpu checkpoint, --resume latest, signals, the finite guardReference
Function transforms
Parameter trees
Read trainable model values by path.
Buffer trees
Read model buffer values by path.
Frozen parameter trees
Read frozen and nonfloating model values by path.
Tree merge
Combine disjoint binding trees and reject conflicting values.
Functional call
Apply explicit parameter bindings.
Gradient functions
Differentiate functions over tensor trees.
Value and gradient
Compute primal values and tree gradients together.
VJP
Apply a closed vector-Jacobian pullback over tensor trees.
JVP
Push a tangent direction through a function over tensor trees.
Vmap
Map a function over tensor lanes with logical-lane random draws.
Tree map
Map a function over corresponding tensor leaves.