S-exp GPU
All pages
Docs · Function transformsMarkdown

Parameter trees

(parameters model) returns the model's trainable floating-point parameters as a plist keyed by their full paths. A static list, vector or plist of model roots is also accepted. Paths are ordered lexically; a tied parameter appears once. Buffers and frozen parameters are outside this differentiated tree; tree-merge combines the three subsets for a complete functional call.

Query the tree inside a traced function, after model paths are assigned. An early query during top-level loading is refused with E-FUNC-003; put an initializer query in a lambda.

The leaves are tensor values when the tree is used in a traced function. Reading them does not update the model. Use functional-call to apply replacement values, and tree-map to construct an update.

Save this as scalar.sx:

(defmodel scalar ()
  (defparam weight (full [] 4.0))
  (lambda (x) (* weight x)))
(defvar model (scalar))

Inspect its weight with a bounded probe:

sexpgpu probe scalar.sx --expr '(getf (parameters model) :model.weight)' --max-elements 100

This returns 4.0. Parameter paths identify values; equal numerical values do not tie independent parameters.