TorchLean API

NN.API.Public.Facade.Runtime.Adapters

TorchLean Adapter Facade #

Parameter-efficient adapter operations exposed by the NN umbrella.

@[reducible, inline]
abbrev TorchLean.Adapters.LoRA.Params (α : Type) (inDim rank outDim : ) :

LoRA adapter parameters for a linear weight matrix of shape inDim × outDim.

The usual LoRA scaling is alpha / rank; TorchLean keeps the final scalar as an explicit scale argument so callers can choose that convention, a schedule, or a test value.

Instances For
    def TorchLean.Adapters.LoRA.delta {α : Type} [Add α] [Mul α] [Zero α] {inDim rank outDim : } (p : Params α inDim rank outDim) (scale : α) :

    The low-rank matrix scale * (A * B) added to a base linear weight.

    Instances For
      def TorchLean.Adapters.LoRA.effectiveWeight {α : Type} [Add α] [Mul α] [Sub α] [Zero α] {inDim rank outDim : } (base : Spec.Tensor α (Spec.Shape.dim inDim (Spec.Shape.dim outDim Spec.Shape.scalar))) (p : Params α inDim rank outDim) (scale : α) :

      Apply a LoRA adapter to a base linear weight matrix.

      Instances For
        def TorchLean.Adapters.LoRA.linear {α : Type} [Add α] [Mul α] [Sub α] [Zero α] {batch inDim rank outDim : } (x : Spec.Tensor α (Spec.Shape.dim batch (Spec.Shape.dim inDim Spec.Shape.scalar))) (base : Spec.Tensor α (Spec.Shape.dim inDim (Spec.Shape.dim outDim Spec.Shape.scalar))) (p : Params α inDim rank outDim) (scale : α) :

        Run a batched linear projection using the base weight plus the LoRA delta.

        Instances For