TorchLean API

NN.Runtime.Autograd.Torch.Core.Session.Parameters

Parameter Mirrors #

CUDA updates leave the host tensor stale. We only download it at an explicit readback boundary; writing a host value removes the cached mirror without invalidating recorded CUDA snapshots.

Synchronize a CUDA-updated parameter back to its host tensor, if needed.

This synchronization point is explicit. Training hot paths keep parameters resident on device; public readback APIs call this helper before exposing parameter tensors to the Lean side.

Instances For

    Store/update the CUDA mirror of a parameter and mark the host tensor stale.

    Replacing the mirror drops its previous reference without invalidating recorded snapshots. The incoming buffer must not remain subject to another scope's explicit release; installing an owned tape intermediate requires a copy or transfer of that scope's release responsibility.

    Instances For

      Overwrite a host parameter value and invalidate any stale CUDA mirror.

      Instances For

        Read the current CUDA mirror, uploading a current host value when the cache is empty.

        The returned buffer is shared with the parameter. A caller may retain it as a recorded snapshot; replacing the cache later drops only the parameter's reference. A cache with the wrong shape, or an absent cache paired with a stale host value, has no justified current value to use.

        Instances For