TorchLean API

NN.Runtime.Autograd.Torch.Core.Session.State

Eager Session State #

The tapes and side tables shared by eager operations. Parameters own their CUDA mirrors; the session owns recorded intermediates. Handle generations separate consecutive forward passes.

The mutable cells owned by a parameter, without reading or comparing tensor elements.

Two registrations share optimizer storage only when all three cells coincide. Equal values and equal names do not make separately allocated parameters aliases. Keeping this descriptor in the session leaves the public Param record and its construction interface unchanged.

Instances For

    Compare mutable-cell identity using Lean's safe stateful reference operation.

    Instances For

      Map each present storage to its first occurrence, retaining absent slots.

      A balanced tree of full-width reference keys avoids pairwise searches among independent storages. Reference equality remains authoritative even if keys collide. Representatives retain their cells until the operation ends; neither keys nor references are cached between calls. Consequently a new parameter list or recording can change its alias layout without invalidating a cache.

      Instances For

        Mutable tapes and side tables for eager execution.

        paramsByLeaf links parameter leaves to their persistent storage. A reset drops the recording and advances refGeneration, but keeps the owner id, random counter, and backend selections.

        • options : Config

          Session options controlling backend/device/kernel behavior.

        • tape : IO.Ref (Tape α)

          CPU eager tape used when Config.device options = .cpu.

        • cudaTape : IO.Ref Cuda.Tape

          CUDA eager tape used when Config.device options = .cuda.

        • paramsByLeaf : IO.Ref (Std.HashMap (AnyParam α))

          Map from tape leaf ids to trainable parameter objects.

        • parameterStorageByLeaf : IO.Ref (Std.HashMap (ParameterStorage α))

          Storage identities for this recording's parameter leaves; no tensor snapshots are cached.

        • nats : IO.Ref (Array )

          Non-differentiable integer inputs for dynamic indexing operations.

        • rngCounter : IO.Ref

          Number of seeded random tensors generated by this session.

        • Accepted capsules already reported for this session, in first-use order.

        • refOwner :

          Process-unique owner id for session references.

        • refGeneration : IO.Ref

          Current recording generation for session references.

        Instances For