geope.jax.jacobian¤
First derivatives of the pulse model, in both directions.
jacobian_propagator builds the whole \((G, d, d, K)\) tensor
\(\partial U/\partial\phi_{g,k}\); vjp_propagator contracts an ambient covector
against every one of those columns without building it. Both share the two
jax.lax.scan partial products (the gates before and after the one being
differentiated), and both are exact — they differ only in what they are for. A
Jacobian is what the geodesic least-squares problem needs, one column per
parameter; a gradient is not, and paying \(O(G\,d^3K)\) to build a tensor you
immediately contract away is the difference between the two paths.
jvp_propagator is the third direction: one parameter-space direction pushed
forward, in \(O(G)\), without either.
The Jacobian¤
geope.jax.jacobian.jacobian_propagator(params, Ui_fn, jac_fn)
¤
Compute the full Jacobian propagator of the product unitary.
The product unitary follows the convention of
:func:geope.geometry.chart.compute_matrices_params_list_fn, where each gate is
left-multiplied onto the accumulator,
The derivative with respect to a parameter of gate \(i\) leaves every other gate untouched, so it is a product with a single factor replaced by the per-gate derivative:
Both the left (\(L_i\), exclusive suffix product) and right (\(R_i\), exclusive
prefix product) partial products are obtained in \(O(G)\) matrix
multiplications with two jax.lax.scan passes, after which the per-gate
derivative blocks are combined with a single vectorised einsum. This is
the equivalent of differentiating the whole sequence with autodiff, but
built explicitly from the per-gate derivative jac_fn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
Array
|
Parameter |
required |
Ui_fn
|
Callable[[Array], Array]
|
Callable mapping a coefficient |
required |
jac_fn
|
Callable[[Array], Array]
|
Callable computing the per-gate Jacobian |
required |
Returns:
| Type | Description |
|---|---|
Array
|
An |
geope.jax.jacobian.get_jacobian_propagator(gate_basis, method='eig', hermitian=True)
¤
Create a JIT-compiled manual Jacobian function for a given gate basis.
The returned function is wrapped in jax.jit so it is compiled once and
reused across calls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gate_basis
|
Array
|
Generator |
required |
method
|
str
|
Per-gate derivative method. |
'eig'
|
hermitian
|
bool
|
Assume real parameters (skew-Hermitian generators) and use
the faster |
True
|
Returns:
| Type | Description |
|---|---|
Callable[[Array], Array]
|
A |
Callable[[Array], Array]
|
of shape |
Callable[[Array], Array]
|
|
The pullback¤
geope.jax.jacobian.vjp_propagator(params, Ui_fn, adj_fn)
¤
Pullback (VJP) of the product unitary — every partial, no Jacobian.
Returns (U, pullback) in the shape of jax.vjp, and for the same reason:
the covector a cost hands back is a function of the value, so the two
cannot be asked for in one call. Splitting them this way means the gate
exponentials and their two partial products are computed once and shared
— a caller that evaluated the chart separately would pay for them twice.
pullback contracts a single ambient covector \(C\) against all
\(G\times K\) columns of the Jacobian at once,
which is what a chain rule out of the ambient space actually needs.
jacobian_propagator would build the whole \((G, d, d, K)\) tensor first; here
the partial products land on the covector instead. Using
each gate needs one \(d \times d\) covector \(B_i = L_i^\dagger C R_i^\dagger\) —
two matrix products — after which adj_fn returns all \(K\) overlaps for that
gate without ever forming its \((d, d, K)\) derivative. The whole call is
\(O(G(d^3 + d^2 K))\) in flops and \(O(G d^2)\) in memory, against the Jacobian
route's \(O(G d^3 K)\) and \(O(G d^2 K)\).
The pullback's result is complex, and deliberately not halved or
realified. A real-valued cost \(C(\phi)\) whose ambient Wirtinger gradient is
\(\hat G\) has \(\partial_{i,k} C = 2\,\mathrm{Re}\,t_{i,k}\) for a cotangent
of \(\hat G\), so the gradient is one 2 * jnp.real(...) away; but a
projective cost also needs the complex overlaps
\(\langle y, \partial U\rangle\) for its second-order term, and returning the
raw value serves both from one primitive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
Array
|
Parameter |
required |
Ui_fn
|
Callable[[Array], Array]
|
Callable mapping a coefficient |
required |
adj_fn
|
Callable[[Array, Array], Array]
|
Per-gate adjoint |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Tuple |
Callable[[Array], Array]
|
callable taking an ambient covector |
tuple[Array, Callable[[Array], Array]]
|
\(\mathrm{Tr}(C^\dagger\,\cdot)\), i.e. conjugated — to the complex |
tuple[Array, Callable[[Array], Array]]
|
overlaps of shape |
geope.jax.jacobian.get_vjp_propagator(gate_basis, method='eig', hermitian=True)
¤
Create a pullback propagator for a given gate basis.
Wraps vjp_propagator with a per-gate adjoint built from gate_basis.
Unlike get_jacobian_propagator the result is not jax.jit-wrapped —
it returns a closure, which a jitted function cannot. That is the right
default anyway: it fuses into the enclosing @jax.jit that actually wants
the gradient, which is where the value and the pullback get to share their
partial products.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gate_basis
|
Array
|
Generator |
required |
method
|
str
|
Per-gate adjoint method. |
'eig'
|
hermitian
|
bool
|
Assume real parameters (skew-Hermitian generators) and use the
faster |
True
|
Returns:
| Type | Description |
|---|---|
Callable[[Array], tuple[Array, Callable[[Array], Array]]]
|
A |
Callable[[Array], tuple[Array, Callable[[Array], Array]]]
|
shape |
The pushforward¤
geope.jax.jacobian.jvp_propagator(params, direction, step_fn)
¤
Directional first derivative (JVP) of the product unitary in \(O(G)\).
Computes the value and the single-direction derivative of the product
unitary along a parameter-space direction \(p\), without forming the full
Jacobian. With the product convention of
:func:geope.geometry.chart.compute_matrices_params_list_fn,
\(\phi(\theta) = U_{G-1} \cdots U_1 U_0\) with each gate left-multiplied,
define the partial product \(X_g = U_g \cdots U_0\) and its derivative
\(V_g = \dot X_g(0)\) along \(\theta(t) = \theta + t p\). Since
\(X_g(t) = U_g(t) X_{g-1}(t)\), the product rule gives the linear-time
recursion
with \(X_{-1} = I\), \(V_{-1} = 0\), where \(U_g = \exp(A_g)\) and
\(E_g = D\exp(A_g)[B_g]\) are the per-gate value and directional derivative
(step_fn). After all \(G\) gates, \(X_{G-1} = \phi(\theta)\) and
\(V_{G-1} = D\phi_\theta[p]\). The recursion is a single jax.lax.scan; this
is the forward-mode (JVP) analogue of jacobian_propagator, and the
first-order sibling of geope.jax.hessian.hvp_propagator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
Array
|
Parameter |
required |
direction
|
Array
|
Direction |
required |
step_fn
|
Callable[[Array, Array], tuple[Array, Array]]
|
Per-gate step |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Tuple |
Array
|
\(\phi(\theta)\) and its directional derivative \(D\phi_\theta[p]\). |
geope.jax.jacobian.get_jvp_propagator(gate_basis, method='eig', hermitian=True)
¤
Create a JIT-compiled directional-JVP propagator for a given gate basis.
Wraps jvp_propagator with a per-gate step built from gate_basis and is
wrapped in jax.jit so it compiles once and is reused across calls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gate_basis
|
Array
|
Generator |
required |
method
|
str
|
Per-gate method. |
'eig'
|
hermitian
|
bool
|
Assume real parameters and use the |
True
|
Returns:
| Type | Description |
|---|---|
Callable[[Array, Array], tuple[Array, Array]]
|
A |
Callable[[Array, Array], tuple[Array, Array]]
|
and a direction, both of shape |
Callable[[Array, Array], tuple[Array, Array]]
|
|