TorchLean API

NN.Proofs.RuntimeApprox.Scale.ForwardScale

ForwardScale #

Forward scale propagation over SSA/DAG graphs.

This optional module mirrors NN.Proofs.RuntimeApprox.Graph.ForwardApprox, but for scale bounds (nonnegative bounds on linf_norm) rather than eps error bounds.

PyTorch analogue: users often track activation magnitudes (for normalization, stability, or analysis). Here we make that tracking explicit and compositional at the proof level.

structure Proofs.RuntimeApprox.FwdNodeScale {α : Type} (toSpec : αSpec.SpecScalar) (Γ : List Spec.Shape) (τ : Spec.Shape) extends Proofs.RuntimeApprox.FwdNode toSpec Γ τ :

A forward node augmented with a scale bound function and a soundness lemma.

Instances For

    Forward graph with scale-aware nodes.

    Instances For
      def Proofs.RuntimeApprox.FwdGraphScale.toFwdGraph {α : Type} {toSpec : αSpec.SpecScalar} {Γ ss : List Spec.Shape} :
      FwdGraphScale toSpec Γ ssFwdGraph toSpec Γ ss

      Forget the scale annotations on nodes, producing an ordinary FwdGraph.

      Instances For

        Evaluate the forward pass on spec values, returning the extended context Γ ++ ss.

        Instances For
          def Proofs.RuntimeApprox.FwdGraphScale.evalRuntime {α : Type} {toSpec : αSpec.SpecScalar} {Γ ss : List Spec.Shape} (g : FwdGraphScale toSpec Γ ss) (x : TList α Γ) :
          TList α (Γ ++ ss)

          Evaluate the forward pass on runtime values, returning the extended context Γ ++ ss.

          Instances For
            def Proofs.RuntimeApprox.FwdGraphScale.evalBounds {α : Type} {toSpec : αSpec.SpecScalar} {Γ ss : List Spec.Shape} (g : FwdGraphScale toSpec Γ ss) (epsIn : EList Γ) (xR : TList α Γ) :
            EList (Γ ++ ss)

            Forward-pass error bounds for all intermediate nodes, computed from input bounds epsIn.

            Instances For
              def Proofs.RuntimeApprox.FwdGraphScale.evalScales {α : Type} {toSpec : αSpec.SpecScalar} {Γ ss : List Spec.Shape} (g : FwdGraphScale toSpec Γ ss) (bIn : BList Γ) (xR : TList α Γ) :
              BList (Γ ++ ss)

              Forward-pass scale bounds for all intermediate nodes, computed from input bounds bIn.

              Instances For
                theorem Proofs.RuntimeApprox.FwdGraphScale.eval_scale {α : Type} {toSpec : αSpec.SpecScalar} {Γ ss : List Spec.Shape} (g : FwdGraphScale toSpec Γ ss) (xS : TList Spec.SpecScalar Γ) (xR : TList α Γ) (epsIn : EList Γ) (bIn : BList Γ) :
                approxCtx toSpec xS xR epsInscaleCtx toSpec xS xR bInscaleCtx toSpec (g.evalSpec xS) (g.evalRuntime xR) (g.evalScales bIn xR)