All pages
explain, diff, ir and eval
The verbs that show what the compiler made of a file. None of them trains or
reads data; explain --device opens the selected backend without running a
step. CUDA, ROCm and Metal add a lowering report; CPU and reference keep the
backend-independent report.
explain and ir accept --checkpoint <location/step-N> to inspect the
selection evaluation uses, with recorded knobs before explicit --set values.
They read metadata without loading weights. Differences from file defaults go to
standard error, leaving the report or IR on standard output. See
checkpoint selection.
explain
The target-independent account of one file, on standard output: the selection
with each knob's source, the parameter tree with the update group of every leaf,
the optimizer groups with their states and the constants their schedules folded
to, every graph with its ops by family and its ten largest tensors with the
file:line that made them, one training step, the diagnostics, and where the
precision policy keeps f32. An update row counts one graph run per parameter
in the group (parameters whose updates trace alike share a graph; see
writing optimizers), gives the first one's ops,
and names the ctx scalars its schedules read and any other parameter its
optimizer reads, reading step, progress, panel.rows. --json is the same
report as a document. What a device did is a hole labelled device.
The numerics section counts float nodes in the training and evaluation graphs
that carry high-precision or :sensitivity :high. Each nonzero count adds a
line beside the dtype counts:
4 high-precision float nodes
8 sensitivity-high float nodes--json always includes numerics.high_precision_nodes and
numerics.sensitive_nodes, with zero when no float nodes carry that mark. These
counts describe the requested accuracy separately from physical dtypes. An
explicit (cast x :f64) alone does not count as high-precision.
--json always includes numerics.ir_output_bounds, with default_accuracy
and high_accuracy. Each class is null when it has no float graph outputs.
Otherwise it contains epsilon, retained_bits and bits_lost for the worst
float graph output in that class. A null epsilon inside a present bound means
unbounded error. Bit counts remain finite. Zero error retains 24 bits for
default accuracy or 53 for high accuracy, with zero bits lost. For positive
error, retained bits are clamp(-log2(epsilon), 0, P), with P equal to that
class's 24 or 53 bits, and bits lost are P - retained_bits.
These bounds describe IR-law rewrite spend under the current law assignment, before accuracy lowering, over training alternatives and evaluation graphs with diagnostics stripped. They exclude initializers, optimizer updates and curriculum graphs. They do not include device execution error or compose a whole-plan guarantee. Text adds an IR-law output-bound line with retained bits only for a class with nonzero or unbounded error. Exact IR laws therefore add no text line, while JSON still carries their zero bounds.
Check a run against its plan here: the knob values and where each came from, the
parameter count, which parameters each optimizer group got, tokens per step, the
evaluation cadence and where each pass runs, inline in the loop or offline
from the checkpoints, and the memory bound.
$ sexpgpu explain my-run.sx --variant smoke
my-run.sx: 33 parameters, 300 steps, precision f32 (sexpgpu 0.1.0)
selection:
variant smoke
lr 0.0015 default
layers 2 variant
width 128 variant
seq 64 variant
seed 1 default
parameters: 33, 13.3M elements, 50.8 MiB stored
model 13.3M
embed.table [50304, 128] f32 6.44M model.embed.*
...
groups:
model.embed.* 1 param 6.44M states m, v 12.9M constants 0, 1e-10, 0.05, 0.2, 0.3, ...
default 12 params 393k states m, v 786k constants 1e-10, 0.0015, 0.05, 0.1, ...
graphs:
train 439 nodes, 0 casts added by the f32 policy
ops input 34, const 54, unary 28, binary 119, compare 4, reduce 17, shape 156, ...
emits metric train/loss, counter tokens
largest tensors:
25.8M [4, 128, 50304] f32 broadcast model.sx:25
...
training step:
records 4 microbatches of 4 = 16 per step, 300 steps
counter tokens 1040 per step (static)
evaluation eval: inline, every 25 steps, the whole loader in batches of 4
checkpoints none
precision f32, seed 1
peak activation <= 915.5 MiB for one microbatch, an upper bound: ...The diagnostics section lists every diagnostic the file and its libraries define, its reducer, its graphs, and whether this selection turns it on; see diagnostics. The guards section, only in a file that has one, lists every guard by name, the graphs it runs in and the line it is written on, and says which are a diagnostic's bound:
guards: each stops the run when its count is not 0
train/loss train my-run.sx:43:5
train/logits train my-run.sx:44:5
train/loss-max train my-run.sx:46:5 with its diagnosticexplain --device
With --device cuda, rocm or metal, or the matching SEXPGPU_DEVICE, on a
machine with that device and binary, the report ends with the
lowering report of the graphs a run would prepare
instead of the device hole, and --json puts the same numbers under device.
It builds each graph's plan, as a run's first step does, but reads no data and
writes nothing. SEXPGPU_DEVICES picks the device and the rank count the
stacking line assumes, as for run.
The lowering report
What the CUDA lowering made of each graph a step runs, in one block. run
prints it on standard error before its first step, or, when the first step
measures the stacking, once it has chosen, and sends the same text as a
lowering annotation (events); explain --device cuda
prints it on standard output. The CPU and reference backends do not emit a
lowering report; --cpu-cores N still applies when explaining with
--device cpu.
$ sexpgpu explain my-run.sx --device cuda
...
lowering: cuda compute_80 NVIDIA A100-SXM4-80GB, patterns on
train 1259 nodes, 302 kernels: 49 fused groups of 2 to 15 nodes (median 5), 66 GEMMs
row programs row 39, softmax backward 4 model.norm1, model.blocks.{0..3}.attn, model.blocks.{0..3}.norm2, 2 more
pointwise programs pointwise model.blocks.0.norm1
cross-entropy tail forward, backward model.proj
as gather of log-probabilities, negated per row
train stacked 1949 nodes, 367 kernels: 112 fused groups of 2 to 15 nodes (median 11), 66 GEMMs
...
update default 24 graphs: 1536 nodes, 120 kernels: 96 fused groups of 2 to 9 nodes (median 2)
pointwise programs pointwise 24
stacking 4, 2 or 1: chosen when the run opens its device- The first line names the device and whether the pattern kernels are on.
- One row per graph: with a generator,
generateand, when the run stacks,generate stacked, each summing itsinit,step,finishanduntil; thentrain,train accumulating(what later microbatches run, adding into the previous gradients),train stacked,train diagnosed, each evaluation pass by name, and one row per update group summing the graphs its updates run, the group's work in one step. On CUDA asteprow is a step run as one graph, its training and its updates in one call, where a step can run so, andstep diagnoseda sampled step's. On CUDA, the updates of a group whose optimizer multiplies matrices, such asmuon, run together for parameters of one shape, so the row can count fewer graphs than the group has parameters. A row gives the nodes, the kernels one call launches, the fused groups and their sizes and the GEMMs. Areplayline under it says whether a step replays the graph as one CUDA graph or launches its kernels one by one, and why. Where that is measured,explainsays so; a run measures it on its device at the graph's third call, on that call's inputs, and records the choice. - Under a row, one line per pattern family that fired, with its kernels, how
often each fired, and the model paths of the regions,
model.blocks.{0..11}.attnfor twelve blocks. Afell backline names a region a family matched but left to the generic lowering, and why: a shape, dtype or head dimension the kernel does not take, or an observation that reads a value inside the region. Anasline names each form in which a family recognized its math, such as the cross-entropy tail's loss written as a gather or a one-hot sum, negated per row or after the reduction. - The last lines are about the run as a whole:
memory, with a generator's largest phase,generation, its trips,up to N trips until :until holdswith an:until, and the stacking it shares with the training graph,stacking(devices), and for an offline runevaluation, naming the passessexpgpu evaluateruns instead, then whatever the pattern kernels cannot do on this device, then a run'sdeterminism, its choice provenance, and itschoices.explainhas no run, so itsstackingline lists the degrees a run would choose among and it has neither of the last two. sexpgpu evaluateprints the same report for what it runs: the generator's rows when a pass runs it, each pass,memory, then itsdeterminism,2when it took the checkpoint's choices and3when it chose its own, and itschoices.
A product implementation line can include law product.pedantic-f32,
law product.tf32x3, law product.pedantic-f64 or law product.f64-residue.
When the dimensions identify a contraction length k, the line also shows
epsilon <= coefficient*C (k=...). Here C=S/R, where S is the maximum over
output cells of the sum of absolute input products, and R is the oracle output's
maximum absolute scale, for the tensor or row being bounded. Cancellation can
make C arbitrarily large. R zero with S positive has no finite C; S zero gives
zero error under the law's conditions.
The coefficient is conditional on C, finite operands and intermediates, representability, and the law's accumulator assumptions. The line does not establish these conditions or promise identical bits. Residue-corrected products report the conservative correction and fallback bound; exact packing is a runtime fact and does not reduce the reported coefficient. A store choice bounds product arithmetic only, excluding its epilogue. These coefficients and the IR-law bounds do not compose a whole-plan total. If dimensions cannot be read, the line retains only the law name.
Sum laws lines count sums by law name, extent n and coefficient, for example
2 sums; law sum.generic-split, epsilon <= 1.0995903603324582e-3*C (n=8192).
Zero coefficients are included. A line such as 3 sums have no law counts sums
that no law bounds. Each coefficient is per unit C=S/R, where S is the maximum
over output cells of the sum of absolute summands and R is the oracle output's
maximum absolute scale on the same tensor. These lines establish neither C,
finiteness nor the other conditions of the law, and do not compose a whole-plan
bound.
SEXPGPU_EXPLAIN=kernels adds every launch of each row's first graph, in
execution order, with its shape, dtype and model path; the annotation never
carries that list.
diff
sexpgpu diff <a.sx> <b.sx> compiles two files, or one file twice under two
selections, and prints only what differs, by section, with an a and a b
column: knobs, parameters by path with their update group, graph node counts by
op family and largest tensors, the training step, the data, and each optimizer
group's members, states and constants. A key only one side has reads -.
Sections over twenty rows print twenty and a count, and text shortens values
over 160 characters; --json prints the whole structured diff. Buffer update
and evaluation rows carry their graph or pass name, such as
after-step.model.teacher nodes or eval dev nodes, so each compares with its
namesake on the other side whatever the order;
the pass named eval is eval nodes, as
on the progress line.
The selection applies to both files: sexpgpu diff a.sx b.sx --set lr=0.25
reads normalized IR: same when an edited b.sx keeps the graph a.sx has
under --set lr=0.25. --b-variant <name> and each --b-set <knob>=<value>
change b's selection alone, on top of the shared one: --b-variant replaces
the variant and --b-set overrides a knob of the same name, so one file twice
with --b-set is the diff of a knob. Each side's header line is the selection
it compiled under.
Every comparison reports summary: same|different and
normalized IR: same|different; JSON has them as same_summary and
same_normalized_ir. Matching summaries say nothing about whether the
computation matches: an addition that became a multiplication changes no row.
When the summaries match and the IR does not, a final normalized IR section
lists the changes by JSON pointer, such as /graphs/12/nodes/40/op/op; when the
summaries differ already, text gives only the count of IR changes, and --json
lists them either way.
The normalized IR is the document ir prints, so a comment, a moved
line, another seed or other data changes nothing there. Everything in it is
compared, down to exact constant bits, operand order and graph and node IDs.
Equal normalized IR means the same declarations before precision, autodiff,
optimization and lowering; two different graphs can still compute the same
function.
What a run binds the IR to is in the summary rows. The training step has the
steps, the seed, the checkpoint cadence, each pass's cadence and batches and the
diagnostics' sampling. The data section has one row per stage of each loader,
train stage main or eval stage main (eval <pass> stage <name> for another
pass), and one per :load parameter, load model.table. A local data or weight
path is joined to its entry file's directory, so the same relative path beside
two files is two paths; nothing is read or resolved.
$ sexpgpu diff my-run.sx my-run.sx --b-set lr=0.25
a my-run.sx
b my-run.sx --set lr=0.25
summary: different
normalized IR: different, 5 changes in --json
knobs
lr 0.5 (default) 0.25 (set)
optimizer groups
default constants 0, 0.5 0, 0.25Any row you did not expect is a change you did not mean to make.
ir
sexpgpu ir <file.sx> writes the whole experiment document on standard output
as one line of compact JSON: parameters, graphs with their operations, RNG
streams, observations, counters, guards and numerical annotations, each loader's
fields and batch size, evaluation passes, optimizer updates and state,
generation, and what of the run changes the graphs (microbatches, precision,
diagnostics, the finite guard). The source files, the version, the selection,
source lines, guard locations, the component and model each node was made in,
the step count, the seed, the cadences, the data and the loaded files are not in
it; explain --json has the files, the selection and the schedule. So a
comment, a moved line, a new version, another seed, --steps (when no graph
reads a knob steps) or data elsewhere print the same bytes. It is large, 0.7
MB for GPT-2 124M; pipe it through jq to read it. A checkpoint does not hold
it; see checkpoints.
--digest prints only the document's digest, sha256: and the 64 hex digits of
the SHA-256 of that line without its newline. One digest is one program,
whatever files, selection or run binding it was compiled from; the nodes of a
multi-node run compare it as they meet. --digest
takes no --graph (exit 2).
$ sexpgpu ir my-run.sx --digest
sha256:8dcb9e22fa0065525a8318d41d7f77bf520b26025eff516ca6eaacc738c0d008--graph <name|id> prints one graph, selected by exact name or numeric ID.
Ambiguous graph names require an ID. Add --model <path> to print the nodes
created in the model at that dotted path or one under it: model.blocks.1
includes model.blocks.1.attn and excludes model.blocks.10. A model or
parameter name holds no . (E-PARAM-010), so a path is never ambiguous.
--model needs --graph (exit 2); a selector that matches nothing exits 1.
Compilation failures render as check renders them.
sexpgpu ir my-run.sx --graph train
sexpgpu ir my-run.sx --graph train --model model.blocks.0.attnA model fragment keeps its original node IDs and annotations and includes its
selected observations, counters and guards; the model paths that select it are
not printed. Its boundary_inputs list gives the ID, shape, dtype and input
binding of every external operand and selected graph input. Its outputs list
gives the selected nodes read outside the region or used as graph outputs,
observations, counters or guards. Upstream dependencies and sibling models are
excluded, so a fragment is for reading, not running. Selection only limits the
output: the whole experiment still compiles.
eval
sexpgpu eval <file.sx> evaluates every top-level form and prints each value,
one per line; a defining form prints name = value. Several values print as
#<values ...>.
eval <file.sx> --expr FORM loads the file under --variant and --set, then
evaluates one expression in a fresh module scope of that environment. The
expression sees the file's private and imported bindings. A relative require
resolves beside the file. eval --expr FORM without a file starts with the
prelude and resolves relative paths against the working directory; nothing is
read from standard input. The file needs no training contract.
sexpgpu eval my-run.sx --variant smoke --expr '(list seq lr)'
sexpgpu eval my-run.sx --expr "(macroexpand-1 '(my-macro x))"
sexpgpu eval --expr '(reduce + 0 (range 5))'--expr accepts exactly one form. let* or progn can contain several forms.
The ordinary evaluation limits apply to both the
file and the expression, together. --json emits an object with kind: "eval",
the Lisp type, and value as printed Lisp text. Without --expr, the object
contains values, the array of top-level printed lines. Diagnostics use the
same JSON array as check --json. Tensor operations need probe,
which opens a CPU graph.
$ sexpgpu eval my-run.sx
nil
nil
seq = 16
defknobs
lr-scan
train-loader = #<loader 1 fields, batch 4>
eval
prepare = #<function prepare>
model = #<model gpt as model>
objective = #<function objective>
optimizer = #<optimizer sgd>
evaluate = #<function evaluate>
defrun = #<run 20 steps>Related: check, knobs, working as an agent.
For a run with training phases, the training step lists each selector and the graph rows include every alternative. A device report labels the alternatives by phase name.
For a run that extends a base, the origins section
shows the source file, line and column for inherited and overridden
declarations. Selected evaluation values also report their construction site.
Origins are metadata; a provenance change alone does not change the normalized
IR digest.