S-exp GPU
All pages
Docs · The command lineMarkdown

run

sexpgpu run <file.sx> compiles the file, applies the selection and the overrides, and runs the training loop in this process. It reads the .sx, everything it requires, the loaders' files (relative to the experiment file, or s3:// URIs) and, when resuming, a checkpoint. It writes the metrics target, the status file and checkpoints, each only when given a location.

sexpgpu run my-run.sx --variant smoke --steps 3 --device cpu
SEXPGPU_DEVICE=cuda SEXPGPU_METRICS=jsonl:my-run.jsonl sexpgpu run my-run.sx

Flags

Each is an alias of an environment variable or an override of defrun:

flagmeaning
--time-limit SECONDSSEXPGPU_TIME_LIMIT; positive finite session seconds; see time budgets
--final-eval-reserve SECONDSSEXPGPU_FINAL_EVAL_RESERVE; stop starting training steps this many seconds before the limit, default 0
--steps Nreplaces defrun :steps for this session, and binds the file's knob steps when it declares one (the knob steps); nonnegative, with 0 performing no optimizer updates. See zero steps. Recorded as knob steps, source override
--eval-every Nreplaces every pass's :every the same way; 0 leaves only the pass after the last step, so a curriculum never runs
--evaluate inline|offlinereplaces defrun :evaluate; recorded as knob evaluate, source override. Offline, the run runs no pass and needs a checkpoint location, and a :checkpoint-every that does not divide a pass's :every exits 2 with E-CONTRACT-018; see evaluation
--device cpu|reference|cuda|rocm|metalSEXPGPU_DEVICE; see devices
--cpu-cores NSEXPGPU_CPU_CORES; maximum host worker cores for --device cpu, positive integer
--metrics <target>SEXPGPU_METRICS; see metrics
--status <path>SEXPGPU_STATUS; without it no status file is written
--checkpoint-dir <dir>|s3://|gs://|az://...|o41://<artifact>SEXPGPU_CHECKPOINT_DIR; see checkpoints
--resume latest|<location/step-N>SEXPGPU_RESUME; see checkpoints
--choices <checkpoint>|<file.json>|fresh|missingSEXPGPU_CHOICES: take a recorded set of choices, make fresh ones on a resume, or (missing) take the checkpoint's and make only those it lacks; see determinism
--deterministicSEXPGPU_DETERMINISTIC=1: no measured choice, f32 between nodes; no guarantee of identical bits; see determinism
--jsonthe final summary as one JSON object on standard output instead of the done: block
--records <dir|s3://...>where the passes' record tables go; records/ beside the checkpoints by default
--data-map <json>a bundle's data map, relative to the file, which run.sh passes: knobs naming the data it moved are recorded as the file wrote them
--variant, --set, --diagnosticsthe selection

Flags win over environment variables; see environment.

Output

On standard error: one configuration line, where the numbers go, on a GPU the lowering report, one progress line per evaluation pass (a pass other than eval names itself first, probe: eval/loss ...), a timing block, on a GPU the memory: peak line (devices), and the done: block. There is no per-step line and no quiet switch; a step's numbers go to the metrics target, and the status file is the thing to poll.

A CUDA run also prints startup <phase> begin <about> and startup <phase> done <about> elapsed=<s> lines on standard error between the configuration line and the lowering report, to tell a slow startup from a slow first step: prepare (everything before the device opens), device-open, memory-plan, stack per stacking degree, and predict. The per-graph phases optimize, autodiff and cuda-plan print one startup <phase> slow <about> elapsed=<s> line only for a graph that takes a second or more. Only rank 0 of run prints them; a graph planned later in the run, explain --device cuda and evaluate print none.

$ sexpgpu run my-run.sx
run: my-run.sx slug my-run device cpu steps 20 microbatches 2 evals eval@10 diagnostics - precision f32 seed 1 checkpoints - resume - status -
step 0/20 loss - | eval/loss 3.46573 | 0 records | 0.0s
step 10/20 loss 2.66862 | eval/loss 2.62369 | 80 records | 0.1s
step 20/20 loss 2.62068 | eval/loss 2.46219 | 160 records | 0.2s
timing graph 0.012s device-open 0.000s plans 0.001s
timing kernels 0 compiled, 0 loaded in 0.000s, 0 cache hits; native graphs 0.000s
timing step-0 0.007s eval-0 0.020s
timing steps 1..20 median 0.0077s p90 0.0082s
timing eval 2 passes median 0.0195s p90 0.0195s
timing total 0.214s over 20 steps
done: 20 steps, train/loss 2.6207
  eval/loss 2.4622
  counter records 160
  counter tokens 2720

The configuration line's evals reads offline:eval@10,probe@5 for an offline run, whose passes sexpgpu evaluate runs. Its resume is - from the beginning, <dir> from a named checkpoint, latest=<dir> from the location's newest (with --resume latest, or a fork given again), latest=none from the beginning because there was none yet.

With --json the last block is one line on standard output instead; the fields are in the summary:

{
  "kind": "summary",
  "outcome": "done",
  "time_budget": null,
  "steps": 2,
  "train_loss": 3.347761631011963,
  "eval": { "eval/loss": 3.265638828277588 },
  "counters": { "records": 16, "tokens": 272 },
  "stage": 0,
  "metrics": "/tmp/my-run.jsonl",
  "status": "/tmp/my-run.status.json"
}

The run slug

The slug is SEXPGPU_RUN_SLUG or the file's stem, then -<variant>, then one -<knob>=<value> per --set in knob-name order: my-run-smoke-lr=0.003. Values are the evaluated overrides; a repeated --set keeps its last value, so --set lr=9 --set lr=0.003 and --set lr=0.003 name the same run. One selection always names one run, and Metrics by 041 keeps one experiment per slug, so a resume lands in the same experiment. See events.

Metrics keeps a slug of at most 200 characters, counted in UTF-16 units. A longer one keeps the parts that fit whole, base first and in order, then - and the first 16 hex digits of the SHA-256 of the whole slug:

s-hsdm-t3f-123527-long-m0-opt=:origin-...-mem-g-max=0.3-c09b1f80b503e5fe

The same selection always gets the same slug, and two selections almost surely two. A base longer than the 183 characters before the hash keeps its first 183. What the slug leaves out is in the experiment's variant and knobs. sweep and its checkpoint locations use the same slug, and sexpgpu check prints it after the ok: line, so a queued run's slug is seen before it starts:

$ sexpgpu check my-run.sx --variant smoke --set lr=0.003
ok: 32 parameters, 41 graphs, 2 steps
slug my-run-smoke-lr=0.003

Stopping

SIGTERM, SIGINT or SIGHUP stops the run at the next step boundary, writes a checkpoint when there is a location, and exits 128 + n; the details are in checkpoints.

Time budgets

sexpgpu run my-run.sx --time-limit 900 --final-eval-reserve 30 --json

This is a soft deadline, checked between complete optimizer steps and evaluation passes. A timed run checks the deadline before launching the next optimizer step, so device time for that step is included in runtime/step_seconds. A step, preparation phase, pass or checkpoint that crosses it finishes and reports the overrun; the process is never killed and no optimizer update is committed in part.

The clock starts when sexpgpu run starts compiling and covers compilation, checkpoint restore, device setup, initialization, kernel selection, every evaluation, training, checkpoint writes and the metrics drain. Opening an o41:// location is in it too: a resume after a writer died waits for that writer's last commit to settle, up to 600 s, before step 1. Publishing the final budget annotation, status and summary is outside it.

The reserve stops new training work at limit - reserve; it must be finite, nonnegative and smaller than the limit. The run then writes the last step's checkpoint, when it has a location, and attempts every final inline evaluation pass, even when it stopped short of its steps, and starts no pass after the full deadline; a pass in flight finishes. Choose a reserve large enough for the checkpoint and the final evaluation. With the default of zero, an exhausted budget usually leaves no final evaluation. A periodic pass right before the stop can be followed by a final pass at the same step; both count.

Every rank stops at the same boundary. Across nodes, any node's deadline ends training on all of them, and the report uses the largest elapsed clock. Every node must set the same limit and reserve.

--json returns outcome and time_budget. Status files contain the same budget report, and their final state uses the outcome. A soft stop exits zero so a caller can read the report. Check its fields before accepting a timed result:

fieldmeaning
limit_seconds, final_eval_reserve_secondsthe requested session policy
elapsed_secondsthe elapsed session including final work
overrun_secondselapsed minus limit, floored at zero
stopped_earlythe budget prevented a step or final evaluation pass
final_evaluation_completeevery configured final inline pass completed; false for a run with :evaluate offline, whose passes run later
within_budgetfinal inline evaluation completed and elapsed did not exceed the limit

outcome is budget-limited when the budget skipped a step or a final pass, and done when every requested step and final pass ran, even late: an overrun shows in overrun_seconds and within_budget, not in the outcome. A reserved final pass can produce within_budget: true with outcome: "budget-limited" because the step target was cut short. If a final pass overruns, its numbers remain available but within_budget is false. A run with :evaluate offline always reports within_budget: false: its evaluation is not inside the session. With no configured passes, final inline evaluation is complete. sexpgpu evaluate ignores SEXPGPU_TIME_LIMIT and SEXPGPU_FINAL_EVAL_RESERVE.

The metrics stream receives one session time budget annotation after its training and evaluation events have drained. Its report matches the final status and summary, including any overrun caused by that drain. A budget-limited session drains without a done event. Metrics by 041 keeps the experiment running until a resume finishes it; it is not marked failed.

A budget stop writes a checkpoint at the completed step when a checkpoint location is configured, including step zero. As after a signal, a resume reruns the scheduled evaluation at that step, starting from the curriculum the checkpoint holds. A resume starts a fresh session clock; no budget or elapsed time carries through the checkpoint, so resumed sessions are separate measurements, not one session's limit.

Related: sweep, bundle, metrics.