Skip to content
Get started

eqiora.diff

← Python API index

Implicit differentiation of Eqiora programs.

View source

Continue with the scalar Poisson model and plan from the differentiation guide:

python
import numpy as np
import 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.

See eqiora.DerivativeImplementation.

Which implementation supplied the derivative for an evaluation.

See eqiora.DifferentiableEvaluation.

Converged evaluation at one parameter point.

See eqiora.DifferentiableJvp.

Ordered output leaves and their shape-preserving forward tangent leaves.

See eqiora.DifferentiablePrimal.

Ordered typed output leaves from a primal evaluation.

See eqiora.DifferentiableProgram.

Differentiable map between ordered typed input and output products.

See eqiora.DifferentiableVjp.

Ordered output leaves and the shape-preserving input cotangent leaves.

See eqiora.DifferentiableValueSignature.

Exact native Model/type/support identity of one selected numerical leaf.

See eqiora.DifferentiationEvidence.

Provenance of one differentiation: model, plan, solve summaries, and residual.

See eqiora.DifferentiationMode.

Kind of differentiation: primal, JVP, or VJP.

See eqiora.FieldRef.

Field selected from an immutable model.

See eqiora.LinearizationState.

Whether the linearization was computed afresh or reused.

See eqiora.ParameterRef.

Parameter selected from an immutable model.

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.

python
def compile(plan: Plan, *, inputs: Sequence[ParameterRef], outputs: Sequence[FieldRef | ObservableRef], state: State | None=None) -> DifferentiableProgram: ...