Session-level autograd operations.
This module exposes backward and gradient-readback helpers for session tensors while preserving the host/CUDA synchronization invariants maintained by the runtime.
Run a backward pass and return a dense array of gradients for all leaf tensors.
This is the explicit dense-array version of calling backward and then reading every leaf gradient.
Instances For
Apply a gradient hook pointwise to a dense gradient array.
Invariant: the hook must preserve each gradient tensor's shape; we check this and throw if it changes.
Instances For
Backward pass with an optional gradient hook applied to the dense gradient array.
This is a runtime utility (similar in spirit to PyTorch hooks), not part of the proof semantics.
Instances For
Backward pass for a scalar loss, returning the dense gradient array (seed is implicitly 1).
Instances For
Extract the gradient for a particular tensor ref from a dense gradient array.
This is the non-mutating counterpart of reading x.grad.
Instances For
Vector-Jacobian product: vjp(out, seed)[x].
Instances For
Forward-mode: JVP #
Jacobian-vector product for a single leaf (typed graph execution only).
For eager sessions, use the typed graph execution if you need JVPs.
Instances For
Scalar-loss JVP for a single leaf (typed graph execution only).
Instances For
Forward-mode: dense JVP (typed graph execution only) #
Jacobian-vector product with explicit tangents for all leaf tensors.
dxs[i] is the tangent for leaf i (same indexing as grad/backwardDenseAll).
Instances For
Apply a dense SGD step to all learnable parameters.
This is an optimizer helper used by examples; for a higher-level API see
TorchLean.Trainer and TorchLean.Trainer.Session.