Skip to content

geope.jax.dexpm¤

geope.jax.dexpm.Ui(x, basis) ¤

Compute a matrix from a linear combination of generators.

Constructs \(U = \exp(\sum_k x_k E_k)\).

Parameters:

Name Type Description Default
x Array

Coefficient vector of shape (K,).

required
basis Array

Generator array of shape (K, d, d) (skew-Hermitian in the pipeline; see the module docstring).

required

Returns:

Type Description
Array

A matrix of shape (d, d).

geope.jax.dexpm.get_Ui_fn(basis) ¤

Create a partial gate function with a fixed generator array.

Parameters:

Name Type Description Default
basis Array

Generator array of shape (K, d, d).

required

Returns:

Type Description
Callable[[Array], Array]

A callable that accepts a coefficient vector and returns the

Callable[[Array], Array]

corresponding gate matrix.

geope.jax.dexpm.dexpm_block(A, x) ¤

Compute the derivative of the matrix exponential via the block method.

Implements the block-matrix approach of Al-Mohy & Higham (2009) <https://arxiv.org/pdf/1506.00628>_, Eq. (31), extracting \(d\exp(A)/dA \cdot x\) from the upper-right block of \(\exp([[A, x], [0, A]])\).

Parameters:

Name Type Description Default
A Array

The generator combination \(\sum_k x_k E_k\), of shape (d, d).

required
x Array

The direction matrix of shape (d, d).

required

Returns:

Type Description
Array

The directional derivative matrix of shape (d, d).

geope.jax.dexpm.dexpm(x, basis) ¤

Compute the derivative of the exponential map for all generator directions.

For each generator \(E_k\), computes \(\partial \exp(\sum_j x_j E_j) / \partial x_k\).

Parameters:

Name Type Description Default
x Array

Coefficient vector of shape (K,).

required
basis Array

Generator array of shape (K, d, d).

required

Returns:

Type Description
Array

An array of shape (d, d, K) whose last axis indexes the

Array

partial derivatives with respect to each coefficient.

geope.jax.dexpm.dexpm_batched(x, basis, batch_size) ¤

Batched derivative of the exponential map.

Same as dexpm but uses jax.lax.map with a configurable batch_size to limit peak memory usage.

Parameters:

Name Type Description Default
x Array

Coefficient vector of shape (K,).

required
basis Array

Generator array of shape (K, d, d).

required
batch_size int

Number of generators to process per batch.

required

Returns:

Type Description
Array

An array of shape (d, d, K).

geope.jax.dexpm.get_dexpm(basis, batch_size=None) ¤

Create a JIT-compiled exponential-map derivative function.

Parameters:

Name Type Description Default
basis Array

Generator array of shape (K, d, d).

required
batch_size int | None

Optional batch size. If None, the full vmap variant is used; otherwise the batched variant.

None

Returns:

Type Description
Callable[[Array], Array]

A callable that accepts a coefficient vector and returns

Callable[[Array], Array]

the derivative array of shape (d, d, K).

The adjoint¤

The per-gate transpose of the above: all K overlaps of one covector with dexpm's directions, from a single eigendecomposition and without ever forming the (d, d, K) tensor. This is the step geope.jax.get_vjp_propagator is built from.

geope.jax.dexpm.adj_expm_eig(x, b, basis, hermitian=True) ¤

Adjoint of the exponential-map derivative: all K overlaps, no (d, d, K).

Returns the vector of Frobenius overlaps of a single covector b with every partial derivative of Ui,

\[t_k = \mathrm{Tr}\bigl(b^\dagger\,\partial_k \exp(\textstyle\sum_j x_j E_j)\bigr),\]

which is what a chain rule through the exponential actually needs — the (d, d, K) tensor dexpm_eig builds is contracted away immediately, and building it first costs \(O(d^3 K)\) where this costs \(O(d^3 + d^2 K)\).

Writing \(M = \sum_j x_j E_j = V\,\mathrm{diag}(\mu)\,V^{-1}\) and \(\Delta\) for the divided differences of \(\exp\), dexpm_eig gives \(\partial_k e^M = V(\Delta \circ V^{-1}E_kV)V^{-1}\), so

\[t_k = \mathrm{Tr}\bigl(\bar A\,E_k\bigr),\qquad \bar A = V S^\intercal V^{-1},\quad S_{pq} = \Delta_{pq}\,\bigl(V^{-1} b^\dagger V\bigr)_{qp}.\]

The K directions therefore cost one \((K, d, d)\) tensordot against a single \(d \times d\) matrix, and the two rotations that build \(\bar A\) are paid once.

Parameters:

Name Type Description Default
x Array

Coefficient vector of shape (K,).

required
b Array

The covector to contract against, of shape (d, d). Paired with \(\partial_k e^M\) through \(\mathrm{Tr}(b^\dagger \cdot)\), i.e. b is conjugated.

required
basis Array

Generator array of shape (K, d, d).

required
hermitian bool

Assume a skew-Hermitian combination and diagonalise via eigh — see _eig. Set False for complex coefficients or non-skew generators.

True

Returns:

Type Description
Array

A complex Array of shape (K,). Real-valued cost gradients take

Array

2 * jnp.real(...) of it; the raw complex value is what a projective

Array

(absolute-value) cost needs.

geope.jax.dexpm.get_adj_expm_eig(basis, hermitian=True) ¤

Create a JIT-compiled spectral exponential-map adjoint.

Wraps adj_expm_eig with a fixed generator array. This is the per-gate step geope.jax.get_vjp_propagator is built from.

Parameters:

Name Type Description Default
basis Array

Generator array of shape (K, d, d).

required
hermitian bool

Assume a skew-Hermitian combination and use eigh — see _eig. Set False for complex coefficients or non-skew generators.

True

Returns:

Type Description
Callable[[Array, Array], Array]

A callable accepting a coefficient vector (K,) and a covector

Callable[[Array, Array], Array]

(d, d), returning the complex overlaps of shape (K,).

geope.jax.dexpm.adj_expm(x, b, basis) ¤

adj_expm_eig by the block-exponential route — the slow, general path.

The auxiliary-matrix method has no spectral structure to exploit, so this genuinely does build dexpm's (d, d, K) tensor and contract it. It exists for parity with method="block" elsewhere in this module, and because the block method tolerates arbitrary generators; prefer adj_expm_eig.

Parameters:

Name Type Description Default
x Array

Coefficient vector of shape (K,).

required
b Array

The covector to contract against, of shape (d, d).

required
basis Array

Generator array of shape (K, d, d).

required

Returns:

Type Description
Array

A complex Array of shape (K,).

geope.jax.dexpm.get_adj_expm(basis) ¤

Create a JIT-compiled block-method exponential-map adjoint.

Wraps adj_expm with a fixed generator array — the slow path, kept for parity with method="block".

Parameters:

Name Type Description Default
basis Array

Generator array of shape (K, d, d).

required

Returns:

Type Description
Callable[[Array, Array], Array]

A callable accepting a coefficient vector (K,) and a covector

Callable[[Array, Array], Array]

(d, d), returning the complex overlaps of shape (K,).