Autograd #
Autograd widgets (tapes + gradients).
This module provides infoview panels for TorchLean’s eager-mode autograd tape:
#tape_view trenders the tape nodes, showing parents, stored forward values, and a DOT snippet.#tape_grads_view t, outIdruns reverse-mode from a scalar output (outId) and shows which node ids received gradients, plus small previews.
Main definitions #
tapeHtml: inspect a tape's nodes and edge structure.tapeGradsHtml: run scalar reverse-mode and show gradient coverage/results.tapeTraceHtml: step-by-step reverse-pass trace with per-parent VJP contributions.#tape_view,#tape_grads_view,#tape_trace_view: command frontends.
def
NN.Widgets.tapeHtml
{α : Type}
[TorchLean.Storage α]
[ToString α]
(t : Runtime.Autograd.Tape α)
(maxDotChars : ℕ := 6000)
:
Render a tape as an HTML panel (nodes + DOT).
Instances For
def
NN.Widgets.tapeGradsHtml
{α : Type}
[TorchLean.Storage α]
[ToString α]
[Add α]
[One α]
(t : Runtime.Autograd.Tape α)
(outId : ℕ)
:
Render gradients from a scalar output id (like loss.backward()).
Instances For
Reverse-Pass Trace #
#tape_grads_view answers "which nodes received a gradient?".
When you need to understand why a gradient was produced (or why it is missing), it is useful to see the reverse traversal itself:
- the upstream cotangent at each node, and
- the per-parent contributions returned by the node’s local VJP rule.
This viewer runs reverse-mode and renders a step-by-step trace in reverse id order.
def
NN.Widgets.tapeTraceHtml
{α : Type}
[TorchLean.Storage α]
[ToString α]
[Add α]
[One α]
(t : Runtime.Autograd.Tape α)
(outId : ℕ)
:
Render a reverse-pass trace for a tape, starting from a scalar output node outId.