A reusable checkpointed wrapper over a JS-built subgraph.
fn(inputs) receives the input arrays (in order) and returns one or more
output arrays. Applying the checkpoint builds the same forward graph, but
marks it for recomputation: the enclosing backward recomputes fn rather
than reading retained activations. Gradients flow to the explicit inputs
AND to any outer-trace leaves captured by fn (e.g. swapped-in LoRA
primals), exactly as if fn had been inlined.
A reusable checkpointed wrapper over a JS-built subgraph.
fn(inputs)receives the input arrays (in order) and returns one or more output arrays. Applying the checkpoint builds the same forward graph, but marks it for recomputation: the enclosing backward recomputesfnrather than reading retained activations. Gradients flow to the explicit inputs AND to any outer-trace leaves captured byfn(e.g. swapped-in LoRA primals), exactly as iffnhad been inlined.