All pages
Evaluation passes
A pass is a named loader and a cadence. Every pass runs eval-prepare (or
prepare), the model and evaluate over its own
loader, or the :prepare and :evaluate it names. A file declares as many
passes as it needs.
Where the passes run is a separate choice. Inline, the training loop runs them
between steps. Offline, the run only writes checkpoints and sexpgpu evaluate
runs the same passes from them, in another process, perhaps on another machine
and device, reporting the same series at the same steps.
(defeval eval
:loader (loader :sources [(files ["data/val.parquet"])]
:fields [(field :tokens :from "input_ids" :dtype :i32 :shape [1025])]
:batch-size 4)
:every 25)
(defeval probe :loader val-loader :every 5 :batches 16)| keyword | default | meaning |
|---|---|---|
:loader | required | the records the pass reads; see loaders |
:every | none | steps between runs, at least 1; without it the pass runs only after the last step |
:batches | all full batches | read this many batches from the start, at least 1; without it the loader must be finite |
:prepare | eval-prepare, then prepare | this pass's own prepare, for a loader whose records the file's are not written for |
:evaluate | evaluate | this pass's own evaluate; the file needs no evaluate when every pass has one |
:ema | true | under defrun :ema, false reads the trained weights |
Evaluation uses the loader's declared batch size throughout. An incomplete final
batch is dropped, so a pass over 105 rows at :batch-size 10 evaluates 100
rows. When the pass reaches the loader's end, a warning names the pass and how
many rows batching omitted. With several devices, full batches are distributed
among ranks; a rank may have fewer batches than another, or none. :batches
limits the total across all ranks: :batches 1 evaluates one batch on one rank.
See loaders for choosing a batch size that reads every row. Metrics
retain their declared reductions; the default mean averages the values reported
by full batches, excluding ranks that have none.
If an evaluation operation takes more than 30 seconds, stderr periodically names the pass, step, device rank, batch and operation still waiting. A completed pass's progress line can precede a wait for its data loader to close. These notices help locate a stall; they do not stop the pass or shorten storage recovery.
When a pass runs
defrun :evaluate says where every pass of the file runs: :inline, the
default, or :offline. sexpgpu run --evaluate inline|offline replaces it for
one session, recorded as knob evaluate, source override.
Inline:
- At step 0, every
:everysteps, and once more after the last step. With zero steps, only the final pass runs, once at step 0 on a fresh run. - Passes due at the same step run in the order the file declares them.
- A pass reopens its loader every time, so a limited pass reads the same records each time.
- With a checkpoint location, the final passes run after the last step's
checkpoint is written. One that fails stops the
run; the error names the pass, the step and that checkpoint, for
sexpgpu evaluateto run the passes on. - A pass whose loader has the training loader's fields and batch size, in a run
of one training loader, runs the file's generator on each
batch, unstacked, and reads what it makes as
preparedoes in training. A pass a generator's:passesnames runs that one instead, over its own loader of any fields and batch size. The generator reads the weights the pass reads: underdefrun :emathe averages, unless the pass says:ema false. --eval-every Nreplaces every pass's:everyfor one session;0leaves only the pass after the last step, so a curriculum never runs. See run.
Offline:
- The run prepares and runs no pass, not even after the last step, and its
memory plan holds none; on a GPU its
lowering report says
evaluation offline: eval, probe run from the checkpoints with sexpgpu evaluate. A curriculum never runs. :everykeeps its meaning against the checkpoints that exist:evaluate --followruns a pass on each checkpoint whose step is a multiple of its:every. A pass without:everyruns on every checkpoint, and every pass runs on the checkpoint of the last step. A fresh zero-step run writes its final checkpoint at step 0 when a checkpoint location is configured.- So every
:everymust be a multiple of:checkpoint-every(:every 5under:checkpoint-every 2would be evaluated only every 10), and a pass with an:everyneeds checkpoints:checkandrun --evaluate offlinerefuse either mistake (E-CONTRACT-018).run --evaluate offlinealso refuses to start without a checkpoint location.
(defeval eval :loader val-loader :every 250)
(defeval probe :loader val-loader :every 50 :batches 16)
(defrun :steps 3000 :checkpoint-every 50 :evaluate :offline)sexpgpu evaluate
Checkpoint selections restore recorded knob values as data, including lists and
vectors with nested lists or symbols. You do not need to repeat a list-valued
--set from training. This also applies to check, explain, ir and
bundle with --checkpoint; an explicit --set still replaces the recorded
value when it leaves the parameters compatible.
sexpgpu evaluate my-run.sx --checkpoint s3://my-bucket/runs/my-run/step-00000300
sexpgpu evaluate my-run.sx --checkpoint o41://my-team/my-run --follow --pass probeIt compiles the file under the checkpoint's selection, its variant, every knob
recorded in experiment.json, and the run's --steps, --eval-every,
--evaluate and --diagnostics overrides, so the passes are the ones the run
would have run; --variant is not taken, and a --set changes a knob on top
(another knob). It verifies the file against the checkpoint as
a resume does: a parameter that is new, gone, of
another shape or dtype, or trains where it was frozen is refused, naming each,
and so is a :load file whose bytes changed (E-LOAD-001). Edited sources are
allowed and printed under the checkpoint, one line each.
It builds only the pass graphs, and the generator's when a pass runs it, loads
the trained parameters from params.safetensors and any with-loaded teacher
from the files the checkpoint pinned, and never reads the optimizer states or
the training loader. By default, each pass reports into the run's own Metrics
experiment, named by the slug experiment.json records (a checkpoint without
one is refused), at the checkpoint's step, with the series names and metadata it
has inline. The experiment keeps describing the training run: its open carries
the checkpoint's setup, every pass whatever --pass picked, and the
checkpoint's device kind and count. A follower only reads the location, so it
never takes over an o41:// artifact the run is writing. See
metrics.
| flag | meaning |
|---|---|
--checkpoint <location>/step-<n> | evaluate that checkpoint, in any location |
--checkpoint <location> | a location of step-<n> checkpoints: the newest complete one, or with --follow each as it appears |
--checkpoint latest | the same under --checkpoint-dir or SEXPGPU_CHECKPOINT_DIR |
--pass <name> | only this pass; repeatable. Every pass by default; an undeclared one is an error |
--follow | watch the location: evaluate each new checkpoint once, in step order, until the run's last |
--poll <seconds> | how often --follow lists the directory; 60 |
--from-step <n|latest> | with --follow, evaluate only checkpoints at step n or later; latest: from the newest one when the follower starts. See a later start |
--metrics-slug <slug> | report into an independent evaluation experiment, with checkpoint provenance; see isolated rereads |
--set <knob>=<value> | change a knob for this evaluation when the parameters stay the checkpoint's; repeatable. See another knob |
--drop-recorded-knob <knob> | leave out a knob the checkpoint records and the file does not declare; repeatable. See another file |
--data-map <json> | a bundle's data map, relative to the source file: moves local data paths in the checkpoint's knob values, nothing else; :load files keep their byte checks |
--records <dir|s3://...> | where the passes' record tables go; records/ beside the checkpoint by default |
--device, --cpu-cores, --metrics, --choices, --deterministic, --checkpoint-dir | as for run; SEXPGPU_DEVICES picks the GPU, its first ordinal, so an evaluation beside a training run can keep off the run's |
Without --follow, every selected pass runs on the one checkpoint, whatever its
:every. A machine with no GPU evaluates small passes with --device cpu; an
evaluation bundle carries one
checkpoint's passes and their data to a GPU box.
Choices. On the kind of device the checkpoint's choices were made on,
evaluate takes them. On another kind it makes its own. Compare offline and
inline eval/* values within numerical tolerance; neither mode guarantees
identical bits. See offline evaluation. A
pass the run never planned may need a choice the checkpoint does not record,
which stops with E-CHOICE-001; --choices missing makes only those here and
takes the rest from the checkpoint
(determinism). --choices
and --deterministic replace either; the lowering report and the first
annotation say which.
Memory. On a GPU the memory plan holds the parameters, the loaded teacher
among them, the generator's phases and each pass's graph; no optimizer state,
gradient or training graph. A pass that does not fit stops before it starts,
E-MEM-001, as a run does; see devices.
Following. --follow records each pass's evaluated steps in
evaluated.json beside the checkpoints once its numbers have reached the
metrics target, so a restarted follower, on any machine, repeats no step it
marked; see checkpoints. Numbers that do
not arrive within 60 seconds stop the follower with an error, the step undone. A
follower started before the first checkpoint waits for it, and stops after the
checkpoint of the run's last step, the one marked "finished": true.
Writes. It writes no checkpoint or status file. Ordinary evaluation leaves the training experiment's lifecycle alone, so it can run beside training or long after it. An isolated reread starts and finishes its own experiment.
Stopping. SIGTERM, SIGINT or SIGHUP stops a pass at its next batch;
that pass reports nothing, and in --follow its step stays undone for a
restart. A follower waiting for a checkpoint stops at once. The process prints
sexpgpu evaluate: interrupted by <signal> and exits 128 + n.
Output. On standard error: where the numbers go, the lowering report on a
GPU, evaluate: on <device>, determinism <level>, under a
--from-step bound above 0
evaluate: from step <n>; earlier checkpoints are skipped and stay unevaluated,
one evaluate: <checkpoint> line per checkpoint with any edited source under
it, one progress line per pass, and a done: block with each
pass's numbers.
| code | when |
|---|---|
0 | every pass asked for ran |
1 | refused or failed: diagnostics, an identity that does not match, no checkpoint, an undeclared --pass, a pass that did not fit |
2 | the command line was wrong: no file, no --checkpoint, a --poll that is not a positive number, a --from-step that is not a step number or latest or without --follow |
128 + n | stopped by signal n |
Starting a follower later
By default a follower evaluates every checkpoint the location already holds,
from the first. --from-step <n> evaluates only those at step n or later, n
included; with --from-step latest the bound is the newest complete checkpoint
when the follower starts, which it evaluates, and a location with none yet
bounds nothing. Each pass still runs only at steps its :every divides, and the
run's last checkpoint takes every pass at or past the bound. A bound past the
run's last step evaluates nothing and stops at that checkpoint. Earlier
checkpoints are skipped, never marked: evaluated.json lists only what was
evaluated, so a follower without the bound, under the same metrics identity,
still evaluates them. The bound is not stored; it names no new series and does
not change the note's name. A restart repeats no marked step under any bound,
but resolves latest again, past checkpoints written while it was down; restart
with the step number the first start printed (evaluate: from step <n>; ...) to
keep it.
sexpgpu evaluate my-run.sx --checkpoint o41://my-team/my-run --follow \
--from-step latest --pass depth-grid --set grid=true --metrics-slug my-run-gridIsolated rereads
Use --metrics-slug when a reread should have its own Metrics experiment:
sexpgpu evaluate my-run.sx --checkpoint o41://my-team/my-run/step-00000300 --metrics-slug my-run-read-searchThe slug is used exactly as given, independently of SEXPGPU_RUN_SLUG, the
variant and knob overrides. It must be nonempty, at most 200 UTF-16 units, and
different from the training slug. Choose a distinct slug for each independent
reread; reusing one reports into that same evaluation experiment.
The experiment describes the effective knobs, selected passes and evaluation
device. Its evaluation metadata records source_run, checkpoint and step.
Each evaluated checkpoint gets an annotation with its URI, source run and step.
The reread starts its own experiment and finishes it only after all selected
passes and reports succeed; a failed or interrupted reread sends no done. The
training experiment receives no events from this reread.
With --follow, completion is remembered separately for each evaluation slug,
in evaluated-<sha256-of-slug>.json beside the checkpoints. Restarting the same
slug skips its completed passes; another slug starts independently. Without
--metrics-slug, the existing evaluated.json and training identity apply.
Passes' record tables keep their configured location; use
--records to choose a separate destination for those files.
Another file
A file other than the run's own, an evaluation wrapper say, compiles under the
same recorded selection. A recorded knob it does not declare is E-KNOB-005,
which names the checkpoint. When the file computes the same without that knob,
--drop-recorded-knob <knob>, repeatable, leaves it out and prints it. The
parameters must still match. The checkpoint must record the knob and the file
must omit it. To change a declared knob, use --set NAME=VALUE. The flag
rejects the run's recorded overrides for --steps, --eval-every, --evaluate
and --diagnostics. export, serve --pass, bundle --checkpoint, and
check, explain and ir with --checkpoint also accept the flag. It
requires --checkpoint.
Inspecting the checkpoint selection
check, explain and ir accept --checkpoint to compile under the same
recorded selection and explicit --set rules as evaluation, without loading
weights or running a pass:
sexpgpu check my-run.sx --checkpoint o41://my-team/my-run/step-00000300 --json
sexpgpu explain my-run.sx --checkpoint o41://my-team/my-run/step-00000300 --set search=true
sexpgpu ir my-run.sx --checkpoint o41://my-team/my-run/step-00000300 --digestThey accept a checkpoint, a location of checkpoints (the newest complete one),
or latest with --checkpoint-dir or SEXPGPU_CHECKPOINT_DIR. A bundle's
--data-map relocates local paths in recorded knobs. The checkpoint supplies
--variant, --steps and --diagnostics; giving those flags with it is
refused. A --set must leave the checkpoint's parameter paths, shapes, dtypes
and trainable/buffer flags intact, as for evaluation.
Evaluation and checkpoint-aware inspection print selection differences on
standard error. Each line shows the recorded value and source, the current file
default, and the effective value with its source (checkpoint or --set). File
defaults mean a separate compilation without a variant or overrides; they do not
change the effective compilation. If those defaults fail, available values are
still shown and others say unknown; a valid checkpoint selection still
succeeds. Standard output keeps its normal JSON, diagnostic array or IR digest.
Another knob
A pass a knob kept out of training, an expensive search say, runs from the
checkpoints with --set:
(defknobs (search false))
(when search
(defeval restarts-16 :loader val-loader :batches 8 :prepare restarts-prepare))sexpgpu evaluate my-run.sx --checkpoint /tmp/my-run/step-00003000 --set search=true --pass restarts-16-
A
--setis taken when the parameters stay the ones the checkpoint holds: the same paths, shapes and dtypes, each frozen or trained as it was, the same buffers. Every pass then reads the trained weights. One that changes any parameter is refused before a pass is built, naming each:sexpgpu evaluate: /tmp/my-run/step-00003000 under --set classes=10: the checkpoint's parameters do not match this experiment: model.head.weight is [10, 256] f32 but the checkpoint holds [100, 256] f32 model.head.bias is [10] f32 but the checkpoint holds [100] f32 evaluate takes a --set that leaves the parameters as the checkpoint holds them; one that changes them needs a run trained with it -
A knob
--stepsbound is the run's:--set steps=Nis refused. -
Each knob it moves is printed under the checkpoint,
knob search false -> true, and is in the annotation'schanged. -
Every metric of a pass run under a moved knob carries
set, the moved knobs asknob=valuein knob-name order, so its numbers are series apart from the run's own,eval/losswithpassevalamong them. A--setthat moves nothing adds none. -
On the kind of device the checkpoint's choices were made on, they are taken as without
--set. A pass the--setadds may need a choice they never made, which stops withE-CHOICE-001.--choices missingchooses only that here and keeps the recorded ones;--choices freshchooses everything here. -
A follower notes such a pass's steps in
evaluated.jsonunder its name and thatset,"restarts-16 search=true", apart from the run's own passes.
Records
record writes rows out of a pass: a table with one row per element of its
columns' first axis, written as one Parquet file each time the pass runs. It is
how a pass hands its states to another program, such as a solver that labels the
boards a closed-loop pass reached so they can join the next run's data.
(defun play-evaluate (prediction targets metadata)
(record "unsolved"
:cells (getf metadata :final)
:steps (getf metadata :steps)
:keep (- 1.0 targets))
(metric "eval/solved" (mean targets)))- Where. In a pass's graph (its
:prepare, the model it runs, its:evaluate) and in the:finishof a generator of:passes, which sees the state its trips left. Anywhere else, training included, isE-REC-001, so a pass that records frompreparegives itself its own:prepare.recordreturns nil. - Columns.
:name tensorpairs, every tensor's first axis the rows, of one length for the table.:keep, one value a row, keeps the rows where it is not zero; without it every row is kept. Shapes are static, so a batch keeps as many rows as its mask says and writes those. - Types. A row of one value is a column of the tensor's type:
f32andbf16asfloat,f64asdouble,i32asint32,i64asint64,boolasboolean. A row of more is a fixed-size list of them, row-major, its Parquet field'sshapemetadata the row's shape,[100]or[10, 10]. A loader reads such a column back with(field :cells :dtype :i32 :shape [100]). Rows come in the order the pass read its batches. - Files.
step-<n>/<pass>/<table>.parquetunder the records location, the step as checkpoints name it,step-00012000. A pass that runs again at that step, offline or under a--set, replaces the file. With several GPUs each writes the rows of the batches it read,<table>-rank<i>-of-<n>.parquet. Table names are letters, digits,.,_and-, not starting with.; one graph records a table once, and a pass and its generator's:finishrecord different tables (E-REC-002). - Location.
--records <dir|s3://bucket/prefix>onrunandevaluate; without it,records/beside the checkpoints: the run's--checkpoint-dir, or forsexpgpu evaluatethe location of the checkpoint it reads. A bucket is written with the checkpoints' credentials. A run whose passes record and that has neither is refused before its first step, and so is one whose location iso41://without--records: 041 Artifacts keeps checkpoints, not tables.sexpgpu rruntakes no--records, so a job whose passes record keeps its--checkpoint-dirin a bucket.
sexpgpu evaluate play.sx --checkpoint s3://my-bucket/runs/play/step-00012000 --pass hard
# s3://my-bucket/runs/play/records/step-00012000/hard/unsolved.parquet
sexpgpu evaluate play.sx --checkpoint o41://my-team/play --pass hard --records s3://my-bucket/harvestThe pass named eval
The pass named eval is the one the summary, the status file, the progress line
and sweep's table report; a file without one reports its first pass. Every
observation from a pass carries pass metadata, so eval/loss from eval and
from probe are two series. See metrics.
Errors
| code | when |
|---|---|
E-CONTRACT-013 | two passes share a name |
E-CONTRACT-014 | an evaluate or a curriculum in a file with no pass, so nothing would run it; an explicit empty selection may disable inherited evaluate |
E-CONTRACT-003 | a pass's :prepare or :evaluate that is not a function, a defrun :evaluate other than :inline or :offline |
E-CONTRACT-018 | an offline run whose checkpoints do not land on a pass's :every |
E-REC-001 | a record outside a pass's graph and the :finish of a generator of :passes |
E-REC-002 | a record without a valid table name or a column, with a column without rows or columns of different rows, or a table recorded twice |
Related: curriculum, the status file, checkpoints, determinism.
Build passes as values
eval-pass accepts a nonempty name string (also a keyword or quoted symbol) and
the same :loader, :every, :batches, :prepare, :evaluate and :ema
options as defeval. It returns a value. Select a list or vector of those
values with defrun :evals; construction alone schedules nothing.
A macro that stamps declarations:
(defmacro dev-read (name split)
`(defeval ,name :loader (dev-loader ,split) :batches 2))
(dev-read dev-small "small")
(dev-read dev-full "full")becomes a function returning a pass:
(defun dev-read (name split)
(eval-pass name :loader (dev-loader split) :batches 2))
(defrun :steps steps
:evals (map (lambda (split) (dev-read (str "dev-" split) split))
["small" "full"]))Lists can be built with functions, map, filter and append before
selection. Nil items are omitted, so a conditional factory can return nil. For
eval-pass, :every nil and :batches nil mean that the option is omitted.
The selection expression runs after all top-level definitions; other defrun
settings still run at the declaration. Spell the selection keys literally.
Attach generated records with
:generator (generator :trips n :init start :step next ...). The generator
value takes :trips, :init, :step, :finish, :until and :persistent;
it belongs to this pass, so it takes no :passes. An unselected pass's
generator is never registered. Existing defgenerate declarations retain their
meaning.
Legacy defeval passes run first in declaration order, then selected values in
list order. Names must be unique (E-CONTRACT-013).
defrun :drop-evals ["dev-small"] removes a declared pass and its generator
after selection; it cannot replace a pass with a second pass of the same name. A
wrong constructor input is E-PASS-001, a selection that is not a list of pass
values is E-PASS-002, and an invalid or absent dropped name is E-PASS-003.
An explicit empty selection or removal of every pass can disable inherited
evaluate. A curriculum still needs a pass to supply its observations.