S-exp GPU
All pages
Docs · The run fileMarkdown

Curriculum and ctx

A curriculum moves the training loader between its stages based on what an evaluation pass just observed. ctx is the plist of run progress that schedules, optimizers and the curriculum read.

(defun curriculum (stage ctx observations)
  (where (< stage 1)
         (where (< (getf observations "eval/loss") 3.3) (+ stage 1) stage)
         stage))

curriculum

  • Receives the current stage as an i64 scalar tensor, ctx, and the observations of the pass that just finished, a plist keyed by metric name as a string.
  • Returns the new stage: any stage of the training loader, forwards or backwards, or the current one to stay. Stages are declared with :stages on the loader; see loaders.
  • It is a graph, so branching is where, not if. See truth and staging.
  • Runs after every pass, including those at step 0, never after the last step. Two passes due at one step run it twice, each time on the observations of the pass that just ran.
  • Diagnostics are never offered to it; they do not exist on unsampled steps. A metric in it is not read.
  • A curriculum with no pass is E-CONTRACT-014.

A stage change is the annotation stage <old> -> <new>, every metric carries the stage it was measured in, and curriculum/stage is emitted with every evaluation. See events.

ctx

A plist of scalar tensors, read with getf:

keydtypemeaning
:stepi64optimizer steps completed
:stepsi64the run's total, defrun :steps
:microbatchi64the microbatch index inside the step
:recordsi64loader records consumed
:progressf32:step divided by :steps
:stagei64the curriculum stage
:stage-stepsi64steps since the stage began
:stage-recordsi64records since the stage began
:<counter>i64one per declared counter, for the whole run
:stage-<counter>i64the same, since the stage began

The stage- entries reset to zero whenever the stage changes. Because the values are tensors, arithmetic on them builds graph nodes: cast before mixing, (cast (+ (getf ctx :step) 1) :f32).

Related: evaluation passes, schedules.