hawk.diff

hawk.diff#

IR -> IR autodiff, symbolic and in both directions. vjp() and jvp() synthesise a NEW IR from a primal one, driven by the per-node-KIND rule table (hawk.diff.rules); the result is an ordinary HAWK IR that goes through the same canonical walk, emitter and cache as any primal.

param_planes() reads a kernel’s uniforms from one-cell planes, so a recorded launch can change them without re-capture; tape(), step_vjp(), step_jvp() and refine_entry() build the kernels a launching runtime needs to reverse a whole rollout of a step kernel and to refine its stop time; hawk.diff.event reads a stop rule as a smooth guard.

Functions

vjp(…)

The reverse-mode derivative IR of primal: one adjoint plane per primal sink in, one gradient plane per wrt input out.

jvp(…)

The forward-mode derivative IR of primal: one tangent plane per wrt input in, one directional-derivative sink per primal sink out.

with_derivative(…)

ONE kernel that computes primal's outputs and their forward-mode tangents along wrt: the sinks of primal followed by the sinks of jvp().

tape(…)

The taping twin of kernel for windows of window steps (see the module docstring).

step_vjp(…)

The vjp of ONE step of an in-place step kernel (one that updates Mutable planes and finishes its samples), for a reverse through a rollout.

step_jvp(…)

The forward-mode twin of ONE step of an in-place step kernel, for a tangent carried across launches: a kernel that commits each state plane <plane> AND dot_<plane> (its tangent), both advanced by the same step.

refine_entry(…)

The REFINE entry <name>_refine of a kernel declaring time_step=: one step from the state a sample held before its stop step, of size <dt>_tau (a per-sample plane), with the time plane in the split index form (t_0 + k*dt) + tau — so d t / d tau == 1.

param_planes(…)

kernel with its uniform parameters read from one-cell planes.

Classes

Derived

The sink tuple vjp()/jvp() return, tagged with facts the transform already knows: which kernel it differentiated (primal, or None for an unnamed sink set), which direction (kind, "vjp"/"jvp"), with respect to which leaves (wrt, resolved names in traversal order) and which already-published unit the primal lives in (primal_unit, None meaning "same bundle as this derivative").