eqiora.diff
Implicit differentiation of Eqiora programs.
View sourceExample: evaluate a parameter derivative
Section titled “Example: evaluate a parameter derivative”Continue with the scalar Poisson model and plan from
the differentiation guide:
import numpy as npimport eqiora.diff
program = eqiora.diff.compile( plan, inputs=(model.parameter("source"),), outputs=(plan.capability.fields[0],),)evaluation = program.evaluate((1.5,))values = evaluation.primal()directional_derivative = evaluation.jvp((1.0,))values holds the solution at source value 1.5. The JVP gives its change per
unit increase of that parameter. A VJP instead propagates output weights back
to parameter coordinates. The original model and plan remain unchanged.
DerivativeImplementation
Section titled “DerivativeImplementation”See eqiora.DerivativeImplementation.
Which implementation supplied the derivative for an evaluation.
DifferentiableEvaluation
Section titled “DifferentiableEvaluation”See eqiora.DifferentiableEvaluation.
Converged evaluation at one parameter point.
DifferentiableJvp
Section titled “DifferentiableJvp”Ordered output leaves and their shape-preserving forward tangent leaves.
DifferentiablePrimal
Section titled “DifferentiablePrimal”See eqiora.DifferentiablePrimal.
Ordered typed output leaves from a primal evaluation.
DifferentiableProgram
Section titled “DifferentiableProgram”See eqiora.DifferentiableProgram.
Differentiable map between ordered typed input and output products.
DifferentiableVjp
Section titled “DifferentiableVjp”Ordered output leaves and the shape-preserving input cotangent leaves.
DifferentiableValueSignature
Section titled “DifferentiableValueSignature”See eqiora.DifferentiableValueSignature.
Exact native Model/type/support identity of one selected numerical leaf.
DifferentiationEvidence
Section titled “DifferentiationEvidence”See eqiora.DifferentiationEvidence.
Provenance of one differentiation: model, plan, solve summaries, and residual.
DifferentiationMode
Section titled “DifferentiationMode”See eqiora.DifferentiationMode.
Kind of differentiation: primal, JVP, or VJP.
FieldRef
Section titled “FieldRef”See eqiora.FieldRef.
Field selected from an immutable model.
LinearizationState
Section titled “LinearizationState”See eqiora.LinearizationState.
Whether the linearization was computed afresh or reused.
ParameterRef
Section titled “ParameterRef”See eqiora.ParameterRef.
Parameter selected from an immutable model.
compile
Section titled “compile”Compile a differentiable program over an ordered set of parameters.
For a finite affine Plan, the inputs are real or complex Parameters, scalar or shaped, and outputs are ordered real/complex Fields or Observables; the Plan must not require state. Complex derivatives use the real differential with the pairing Re(sum(conj(a)*b)), so dependence on the conjugate is kept. Input coordinates are ordered by selection, then row-major by component, then real before imaginary part. The input identities count Parameters; the input shape counts real coordinates. A finite nonlinear Plan also needs its exact seed.
def compile(plan: Plan, *, inputs: Sequence[ParameterRef], outputs: Sequence[FieldRef | ObservableRef], state: State | None=None) -> DifferentiableProgram: ...