All pages
How it works
A .sx file states one experiment: the data it reads, the model, the objective,
the optimizer and the run configuration. sexpgpu reads that file with a
compile-time Lisp evaluator. Tensor operations evaluated during that pass
compute nothing; they append nodes to a graph. What comes out is one IR document
(parameters, graphs, the batches they read, optimizer updates, the run
configuration that shapes the graphs), which is validated, differentiated,
rewritten for the precision policy and then executed by one fixed training loop
on a device.
file.sx ──read──▶ Lisp evaluator ──trace──▶ graphs ──lower──▶ IR document
(compile time) │ validate
│ autodiff
│ precision
▼
fixed training loop on cpu | reference | cuda | rocm | metalThe file never sees the loop, the device or a kernel.
Two kinds of value
| kind | examples | when it exists |
|---|---|---|
| ordinary | numbers, strings, keywords, symbols, lists, vectors, functions, models, optimizers | at compile time, while the file is evaluated |
| tensor | the result of matmul, field, zeros, a parameter | symbolically, as a node with a static shape and dtype, inside a graph being traced |
Ordinary values drive construction: (repeat layers ...) builds a stack,
(if (> (dim x 0) (dim x 1)) ...) picks a code path from a shape. Tensor values
cannot be branched on, because both branches must exist in a static graph: that
is E-FLOW-001, and the fix is where. See
truth and staging.
Where graphs come from
Tensors exist only inside a function the compiler traces:
| traced function | graph |
|---|---|
defgenerate's :init, :step and :finish | three graphs run before each training call, :step once per trip; see generation |
prepare, the model, objective | the training graph, differentiated with respect to the objective |
eval-prepare, the model, evaluate | one graph per evaluation pass |
| an optimizer body | one update per parameter |
a defparam initializer | one closed graph per parameter |
curriculum | one graph run after each evaluation |
A tensor operation outside these is E-FLOW-003; a tensor carried from one
graph into another is E-FLOW-002.
What the compiler owns
The training loop, autodiff, gradient accumulation over microbatches, a generator's trips, the evaluation cadence, checkpoints and resume, the precision policy, kernels, metrics, the status file and data parallelism. None of it is in the file, so none of it can be subtly wrong in the file.
What is recorded
Every compilation records a setup beside its IR:
- every source file with its SHA-256, the version that compiled it, the selected variant, every knob with its source, and the line of each guard;
- what the run binds the IR to: the steps, the seed, the checkpoint, evaluation and diagnostics cadence, the data each loader reads and the files parameters are loaded from.
The IR names none of these, so a comment, another version, seed, data or
--steps leaves it unchanged, unless the graphs compute from a knob named
steps, which --steps binds. The setup travels in the checkpoint and the
metrics open event, so any number traces back to the exact text that produced
it; the status file carries only the entry file and the selection. See
events.
Related: the run file, It is Common Lisp, tensor operations.