GraphM Core #
Typed variables, builder state, input binding, constants, random nodes, and detach for the proof-compiled graph authoring API.
Shorthand for the underlying executable SSA graph type from Proofs.Autograd.Algebra.
Instances For
Executable node payload for the proof-compiled SSA graph (GraphData).
Instances For
A typed handle to a value in the growing compiled context.
Var s carries its expected Shape at the type level, while id is the runtime index into the
concatenated context Γ ++ ss.
- id : ℕ
Runtime id of the value inside the concatenated context
Γ ++ ss.The shape index on
Var sis the static guarantee; this numeric id is the executable handle used when constructingIdxproofs forGraphDatanodes.
Instances For
Instances For
GraphM.arg is correct but a little noisy for examples (you must repeat the index and shape).
VarList + args give a typed variable layer: args returns one Var per entry in Γ,
in order, without spelling indices.
First variable in a nonempty VarList.
Instances For
Tail variables in a nonempty VarList.
Instances For
State for the GraphM builder.
It is a sigma pair of:
- the list of intermediate shapes
ssproduced so far, and - the corresponding executable SSA graph payload
GraphData α Δ Γ ss.
Instances For
StateT builder monad for authoring a GraphData program, with explicit environment Δ.
Instances For
Empty builder state (no intermediate nodes yet).
Instances For
Empty builder state for an explicit environment type Δ.
Instances For
Run a GraphM program from an empty state.
Instances For
Build a GraphData by running a GraphM program.
This is the usual entry point: write a do-block that constructs the graph using arg, ops,
and returns Unit; get back the finalized builder state containing ss and the graph.
Instances For
Length of the current context Γ ++ ss (inputs + intermediates).
Instances For
Convert a Var s into a dependent Idx (Γ ++ ss) s.
This performs bounds checking and a runtime shape check, returning a structured error if the variable points outside the current context or has the wrong shape.
Instances For
Append a node to the graph state and return a fresh Var pointing to its output.
The returned variable id is Γ.length + ss.length, i.e. it points at the newly appended entry.
Instances For
Forward-mode JVP availability for a compiled graph builder op.
- implemented : JvpAvailability
The op supplies a real forward-mode JVP rule.
- reverseOnly
(op : String)
: JvpAvailability
The op supplies reverse-mode VJP only. Forward-mode requests fail loudly.
Instances For
Instances For
Instances For
Compiled ops that provide VJP for training but no forward-mode JVP rule.
Keeping the list executable gives callers a stable preflight hook instead of discovering the gap only after a directional-derivative run reaches the node. The list is intentionally empty when all compiled builder ops have concrete JVP rules.
Instances For
Return the JVP status for a named compiled op.
Instances For
Diagnostic message for reverse-only compiled ops.
Instances For
Fail-fast marker for compiled nodes whose forward-mode JVP rule is intentionally absent.
Returning a zero tangent here would silently corrupt forward-mode autodiff. Reverse-mode users are
unaffected because these nodes still provide real vjp implementations. Forward-mode callers get a
loud error, and reverseOnlyJvpOps provides a preflight list for tools that want to reject such
graphs before running a JVP.
Instances For
Reference an input variable from the initial context Γ.
This checks that the provided index is within bounds and that the requested shape matches the
shape at that position in Γ.
PyTorch comparison: this is like naming a graph input tensor in a traced graph.
Instances For
Pure helper to build VarList Γ starting at a given id offset.
Instances For
Return one Var per entry of Γ, in order.
This is the canonical argument environment for a graph with input context Γ.
Instances For
Embed a constant tensor as a node in the compiled graph.
This node has no input dependencies (vjp = 0, jvp = 0), i.e. it is treated as a constant
with respect to the graph inputs.
PyTorch comparison: a constant literal captured into a traced/compiled graph.
Instances For
Deterministic U[0,1) tensor generator (seeded, pure).
Instances For
Deterministic {0,1} mask generator (seeded, pure).
Note: for differentiation purposes, this node is treated as a stop-gradient op:
jvp = 0 and vjp = 0 for all inputs (including keepProb). This matches the intended use in
dropout where the probability is a hyperparameter (not differentiated), while keeping execution
deterministic in the .compiled backend.
Instances For
Stop-gradient boundary.
Forward semantics: identity (detach(x) = x).
Backward semantics: no gradient flows to x (treated as constant w.r.t. the graph inputs).