Manifolds¤
The spaces GEOPE can synthesise on. Each implements the hooks of
geope.geometry.manifold.Manifold; see that page for the contracts they must
satisfy.
All four also supply the declinable pair Manifold.cost_gradient and
Manifold.cost_hessian_form, which is what Manifold.value_and_grad and
Manifold.hessian are assembled from — no autodiff. Each does so in two lines,
because every one of them scores through the same complex ambient overlap
\(z = \sum \bar y\,x\): see geope.geometry.cost for the shared formulas and for
why that is an implementation they happen to share rather than a promise the
interface makes.
Matrix Lie groups¤
MatrixLieGroup is the middle layer that supplies everything
left-trivialisation makes free — a point-independent metric and coefficient map,
a matrix-logarithm geodesic, and the product-of-exponentials chart with its
manual propagator derivatives.
geope.geometry.lie.groups.MatrixLieGroup
¤
A compact matrix Lie group with a bi-invariant metric.
Elements of the Lie algebra are skew-Hermitian throughout — the generator
of \(U = e^{-iH}\) is \(-iH\), not \(H\). The single factor of \(\pm i\) between the
Hermitian frame and the algebra is
geope.geometry.basis.Basis.basis_convention, applied by
geope.geometry.basis.Basis.algebra going in and (conjugated) by
coefficients coming out.
Attributes:
| Name | Type | Description |
|---|---|---|
dim |
The Hilbert-space dimension \(d\); a point is a \(d\times d\) unitary. |
__dict__
class-attribute
¤
__weakref__
property
¤
list of weak references to the object
ambient_ndim
property
¤
The number of array axes one point has.
fidelity_at
cached
property
¤
phi -> the fidelity of the pulse phi against the target.
Compiled and memoised rather than evaluated eagerly, because the
host-side loops call it one trial pulse at a time: uncompiled, each
call re-lowers the chart's jax.lax.scan, which cost ~100 ms per
call on a 3-qubit, 20-step pulse and made geope.Geope's
Gram-Schmidt fallback more expensive than the whole geodesic step it
was replacing.
has_cost_gradient
property
¤
Whether this manifold overrides cost_gradient.
A host-side capability probe — an identity check on the bound method's
function, so nothing is traced and no exception has to be caught inside a
jax.jit. value_and_grad reads it to pick its path.
has_cost_hessian_form
property
¤
Whether this manifold overrides cost_hessian_form. See has_cost_gradient.
hessian
cached
property
¤
The infidelity Hessian (P, P) (used by GRAPE's Newton methods).
Analytic when this manifold supplies cost_hessian_form and the chart
has a second differential to offer
(geope.geometry.tangent.TangentBundle.hessian_vjp). The assembly is the
chain rule in two terms — the cost's own curvature and the chart's
bending —
the first from the hook and the second generic, since \(\hat G\) is just
cost_gradient. Falls back to hessian_autodiff otherwise.
The second term never forms \(\mathrm D^2\Phi\): the pullback splits the
pair table into a Gram matrix of two \(O(G)\)-propagated derivative
trajectories — see geope.jax.hessian_vjp_propagator — so a Newton step
costs \(O(GKd^3 + G^2K^2md)\) in flops and \(O(GKmd + (GK)^2)\) in memory
rather than the dense route's \(O(G^2K^2d^3)\) and \(O(G^2K^2d^2)\). That the
point comes back with the pullback keeps it to one pass over the pulse,
exactly as in value_and_grad.
The Jacobian is built only for the projective \(\zeta\) term; a
phase-sensitive cost's cost_hessian_form ignores its columns, and XLA
eliminates the whole computation.
hessian_autodiff
cached
property
¤
The infidelity Hessian (P, P) by forward-over-reverse HVPs.
The reference the analytic path is checked against, and the fallback
wherever the analytic one is unavailable — a manifold that declines
cost_hessian_form, or the param_transform chart, which has no
second differential to build one from.
Carries the same spurious imaginary part as value_and_grad_autodiff on
a complex128 pulse whose imaginary part is identically zero — it
differentiates the same holomorphic gradient. Its real part is right
in every case, and it is exact on the float64 pulses of the
param_transform path where it is actually used. Compare against it on
real input.
infidelity_at
cached
property
¤
phi -> the infidelity of the pulse phi — what GRAPE minimises.
Compiled and memoised, for the same reason as fidelity_at.
is_bound
property
¤
Whether a chart, tangent bundle and target are attached.
manifold_dim
property
¤
The intrinsic (real) dimension of the manifold.
value_and_grad
cached
property
¤
phi -> (infidelity, dinfidelity/dphi) (used by GRAPE).
Analytic when this manifold supplies cost_gradient: one pass over
the pulse through geope.geometry.tangent.TangentBundle.vjp, which
returns the point and a pullback sharing the gate exponentials and their
partial products, then one ambient cost gradient through it,
which never forms the Jacobian. That the value comes back with the
pullback is what keeps it to one pass: the covector \(\hat G\) is a function
of the point, so a separate compute_point call would re-exponentiate
every gate. Falls back to value_and_grad_autodiff otherwise.
The gradient is real by construction and returned in the parameter's
own dtype, so it drops straight into geope.optimizers on the
complex128 pulse arrays geope.parameters.Parameters.free hands out.
value_and_grad_autodiff
cached
property
¤
phi -> (infidelity, dinfidelity/dphi) by reverse-mode autodiff.
The reference the analytic path is checked against, and the fallback for a
manifold that declines cost_gradient.
Note that differentiating infidelity_at holomorphically with respect to
a complex128 array whose imaginary part is identically zero gives a
gradient with a spurious imaginary part. value_and_grad does not.
__abstractmethods__
class-attribute
¤
frozenset() -> empty frozenset object frozenset(iterable) -> frozenset object
Build an immutable unordered collection of unique elements.
__annotations__
class-attribute
¤
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__dataclass_fields__
class-attribute
¤
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__dataclass_params__
class-attribute
¤
__doc__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__match_args__
class-attribute
¤
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
__module__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
ambient_shape
property
¤
validate_point(point, what='point')
¤
Check membership of the group: \(UU^\dagger = \mathbb 1\).
Every geometric primitive here assumes it — log takes the logarithm
of \(U^\dagger V\) expecting a unitary (so logm_unitary's Schur form is
diagonal), and the fidelity normalisation assumes \(\lvert\mathrm{Tr}
\rvert \le d\). A non-unitary target produces plausible-looking numbers
rather than an error, so it is worth catching at configuration time.
Host-side and numpy; see geope.geometry.manifold.Manifold.validate_point.
project_algebra(x)
¤
Project \(\mathfrak u(d)\) onto this group's Lie algebra.
Distinct from the two other projections in the pipeline, and it belongs
here rather than on the geope.geometry.TangentBundle: whether the
global phase is a controllable direction is this group's structure, not
a property of the frame a run happens to be described in. For contrast,
Manifold.to_tangent is \(\mathcal A \to T_x\mathcal M\), and
TangentBundle.frame is the ambient frame a tangent's coefficients are
resolved against.
to_tangent(point, ambient)
¤
Left-trivialise: \(\dot X \mapsto U^\dagger\dot X\), skew-Hermitian.
Doing this before projecting is what makes coefficients lossless. The
raw Jacobian columns \(\partial_{g,k}U\) are ambient, of the form
\(U\cdot(\text{skew-Hermitian})\), whose skew-Hermitian part rotates with
\(U\); projecting them directly would discard most of each matrix and make
the geodesic least squares minimise in a \(U\)-dependent seminorm rather
than in \(\langle\cdot,\cdot\rangle_F\). Left translation is itself an
isometry — it is the projection after it that would be lossy, which is
why the two cannot be commuted.
inner(point, x, y)
¤
\(\mathrm{Re}\,\mathrm{Tr}(x^\dagger y)\) — bi-invariant, so point is unused.
The ambient metric as it stands: a bi-invariant group metric is the one induced by the embedding in \(\mathbb C^{d\times d}\).
coefficients(point, tangent)
¤
Resolve skew-Hermitian algebra elements against the ambient frame.
Projection onto the generators \(E_k = \mathrm{basis\_convention} \cdot B_k\) the chart exponentiates:
the real coefficients with \(X = \sum_k c_k E_k\) (metric constant
\(c = 1/d\)). This is the outbound half of the sign convention; both
halves read geope.geometry.basis.Basis.basis_convention, so they
cannot disagree. point is unused: one frame serves every fibre.
The frame must be Hermitian and trace-orthogonal with
\(\mathrm{Tr}(B_j B_k) = d\,\delta_{jk}\) (every geope.utils basis is);
an incomplete frame simply projects onto its subspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Array
|
Unused. |
required |
tangent
|
Array
|
Skew-Hermitian |
required |
Returns:
| Type | Description |
|---|---|
Array
|
A real |
log(x, y, key=None)
¤
\(\mathrm{Log}_x(y) = \mathrm{proj}\bigl(\log_{\min}(x^\dagger y)\bigr)\).
The algebra element \(A\) with \(x\,e^{A} = y\): skew-Hermitian, and traceless on SU. The pipeline's only matrix logarithm — the geodesic search direction, the geodesic-distance objective and the line-search slope and curvature are all algebra on the single \(A\) a step takes from here.
Taking a second logarithm in the conjugate order is not a harmless convention: \(\log(x^\dagger y) = -\log(y^\dagger x)\) fails on the principal branch cut, so a target with a \(-1\) eigenvalue (Hadamard, CNOT, Toffoli) would have the direction and the objective disagree by \(2\pi\) on that eigenphase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array
|
The base point |
required |
y
|
Array
|
The end point |
required |
key
|
Array | None
|
Unused by |
None
|
tangent_acceleration(point, v, w)
¤
\(\dot\Omega(0) = V^\dagger V + U^\dagger W\).
The derivative of \(\Omega(t) = U(t)^\dagger\dot U(t)\) by the product rule — the chart's bending, as opposed to the group's own curvature.
hessian_quadratic_form(point, a, omega)
¤
\(\bigl(\langle\Omega,\mathcal K_A\Omega\rangle_F,\ \rho\bigr)\) on \(\mathfrak{su}(d)\).
\(\mathcal K_A = \frac{\operatorname{ad}_A}{2}\coth(\frac{\operatorname{ad}_A}{2})\),
evaluated without forming the operator, plus the eigenphase spread \(\rho\)
from the same eigendecomposition. Bi-invariance makes it independent of
point, and the kernel is even in \(A\), so either sign convention for
a gives the same value. See
:func:geope.jax.su_hessian_quadratic_form.
cost_gradient(x, y)
¤
\(\partial C/\partial\bar x\) for the two unitary trace fidelities.
\(-y/(2d)\) phase-sensitively, \(-zy/(2d\lvert z\rvert)\) projectively, with
\(z = \mathrm{Tr}(y^\dagger x)\). See
geope.geometry.cost.trace_cost_gradient.
cost_hessian_form(x, y, u)
¤
The cost's own curvature — zero on \(\mathrm U(d)\), rank-structured on \(\mathrm{SU}(d)\).
\(\mathrm{Re}\,\mathrm{Tr}(y^\dagger x)\) is affine in \(x\), so the
phase-sensitive form vanishes and the whole Hessian is the chart's
bending; \(\lvert\mathrm{Tr}(y^\dagger x)\rvert\) is not, and contributes the
two rank-structured terms of
geope.geometry.cost.trace_cost_hessian_form.
ambient_inner(x, y)
¤
\(\mathrm{Re}\sum \bar x\,y\) over the ambient axes — the metric of \(\mathcal A\).
The default building block for inner, and correct as it stands for any
manifold whose metric is the one induced by the embedding — which
includes a bi-invariant group metric, where it is
\(\mathrm{Re}\,\mathrm{Tr}(x^\dagger y)\), and the round metric on the
state sphere. A manifold whose metric is not the ambient one must say
so: geope.geometry.stiefel.stiefel.Stiefel carries the canonical metric
\(\mathrm{Re}\,\mathrm{Tr}(x^\dagger W_Q y)\) instead, which is what gives
it different geodesics from the embedding's.
bind(*, target, generators, frame=None, columns=None, wrap_chart=None)
¤
Attach this problem's chart, coefficient frame and target.
The seam between the two layers this package is built on, and it holds no
mathematics of its own: geope.geometry.chart builds the ambient jet
\((\Phi,\ \mathrm D\Phi,\ \mathrm D^2\Phi)\) from generators and this
manifold's base_point, and everything else here is assembly.
Returns a new manifold — this one is frozen — so the unbound mathematical object stays reusable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
Array | ndarray | None
|
The point being synthesised, of shape |
required |
generators
|
Basis
|
The chart's generator sub- |
required |
frame
|
Basis | None
|
The ambient coefficient frame |
None
|
columns
|
ndarray | None
|
Boolean mask over the chart's coefficient columns selecting
those the geodesic solve may move. |
None
|
wrap_chart
|
Callable[[Callable], Callable] | None
|
An opaque reparametrisation of the chart's input, or
That it reparametrises the input is what lets it wrap the landed chart rather than the bare propagator: \(\mathrm{wrap}(\Phi)(\phi) = U(\tau(\phi))\,x_0\) either way, so the base point never has to be threaded through it. |
None
|
Returns:
| Type | Description |
|---|---|
Manifold
|
A bound |
Raises:
| Type | Description |
|---|---|
ValueError
|
If this manifold is already bound, or if |
context(free_params, delta_t=1.0)
¤
Open a GeometricContext at the pulse free_params.
Cheap: every quantity on the returned context is lazy, so this on its own
evaluates nothing. Build one per optimisation step, inside the jitted
update — see GeometricContext for why it must not leave that trace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
free_params
|
Array
|
The pulse, shape |
required |
delta_t
|
Array | float
|
The segment duration, threaded (as a traced scalar) into every chart evaluation the context performs. Defaults to 1.0. |
1.0
|
distance2(x, y, key=None)
¤
Half the squared geodesic distance, \(\tfrac12 d_g(x, y)^2\).
The objective the first- and second-order line searches minimise, and the
quantity whose derivatives a GeometricContext reports. Costs one log.
fidelity(x, y)
¤
The convergence score between two points: 1 when they agree.
The optimisers' stopping test and every logged trajectory read this, so it should be normalised to \(1\) at the target whatever the manifold. "Fidelity" is GEOPE's name for that score; a manifold is free to define it however its geometry suggests.
infidelity(x, y)
¤
The cost the optimisers minimise: 0 when the two points agree.
Declared separately from fidelity rather than derived from it as
1 - fidelity: which cost a space is optimised against is the
manifold's own business, and tying the two together here would impose a
relation that only happens to hold for the trace fidelities.
norm2(point, x)
¤
\(\lVert x\rVert^2_{\text{point}}\).
__delattr__(name)
¤
__init__(dim, *, base_point=None, target=None, compute_point=None, tangent=None)
¤
__repr__()
¤
__setattr__(name, value)
¤
geope.geometry.lie.groups.SpecialUnitaryGroup
¤
\(\mathrm{SU}(d)\) with the phase-invariant fidelity (the default).
The Lie algebra is \(\mathfrak{su}(d)\) (skew-Hermitian and traceless), so the
global phase is quotiented out: project removes it from every tangent vector
and the fidelity \(F_{\mathrm{proj}} = |\mathrm{Tr}(x^\dagger y)|/d \in [0, 1]\)
ignores it. This is projective=True.
Deliberately a sibling of UnitaryGroup rather than a subclass: it would
override every member anyway, and \(\mathrm{SU}(d)\subset\mathrm U(d)\) as
groups would make isinstance(m, UnitaryGroup) a misleading test for
"phase-sensitive". Test m.projective.
__dict__
class-attribute
¤
__weakref__
property
¤
list of weak references to the object
ambient_ndim
property
¤
The number of array axes one point has.
ambient_shape
property
¤
fidelity_at
cached
property
¤
phi -> the fidelity of the pulse phi against the target.
Compiled and memoised rather than evaluated eagerly, because the
host-side loops call it one trial pulse at a time: uncompiled, each
call re-lowers the chart's jax.lax.scan, which cost ~100 ms per
call on a 3-qubit, 20-step pulse and made geope.Geope's
Gram-Schmidt fallback more expensive than the whole geodesic step it
was replacing.
has_cost_gradient
property
¤
Whether this manifold overrides cost_gradient.
A host-side capability probe — an identity check on the bound method's
function, so nothing is traced and no exception has to be caught inside a
jax.jit. value_and_grad reads it to pick its path.
has_cost_hessian_form
property
¤
Whether this manifold overrides cost_hessian_form. See has_cost_gradient.
hessian
cached
property
¤
The infidelity Hessian (P, P) (used by GRAPE's Newton methods).
Analytic when this manifold supplies cost_hessian_form and the chart
has a second differential to offer
(geope.geometry.tangent.TangentBundle.hessian_vjp). The assembly is the
chain rule in two terms — the cost's own curvature and the chart's
bending —
the first from the hook and the second generic, since \(\hat G\) is just
cost_gradient. Falls back to hessian_autodiff otherwise.
The second term never forms \(\mathrm D^2\Phi\): the pullback splits the
pair table into a Gram matrix of two \(O(G)\)-propagated derivative
trajectories — see geope.jax.hessian_vjp_propagator — so a Newton step
costs \(O(GKd^3 + G^2K^2md)\) in flops and \(O(GKmd + (GK)^2)\) in memory
rather than the dense route's \(O(G^2K^2d^3)\) and \(O(G^2K^2d^2)\). That the
point comes back with the pullback keeps it to one pass over the pulse,
exactly as in value_and_grad.
The Jacobian is built only for the projective \(\zeta\) term; a
phase-sensitive cost's cost_hessian_form ignores its columns, and XLA
eliminates the whole computation.
hessian_autodiff
cached
property
¤
The infidelity Hessian (P, P) by forward-over-reverse HVPs.
The reference the analytic path is checked against, and the fallback
wherever the analytic one is unavailable — a manifold that declines
cost_hessian_form, or the param_transform chart, which has no
second differential to build one from.
Carries the same spurious imaginary part as value_and_grad_autodiff on
a complex128 pulse whose imaginary part is identically zero — it
differentiates the same holomorphic gradient. Its real part is right
in every case, and it is exact on the float64 pulses of the
param_transform path where it is actually used. Compare against it on
real input.
infidelity_at
cached
property
¤
phi -> the infidelity of the pulse phi — what GRAPE minimises.
Compiled and memoised, for the same reason as fidelity_at.
is_bound
property
¤
Whether a chart, tangent bundle and target are attached.
value_and_grad
cached
property
¤
phi -> (infidelity, dinfidelity/dphi) (used by GRAPE).
Analytic when this manifold supplies cost_gradient: one pass over
the pulse through geope.geometry.tangent.TangentBundle.vjp, which
returns the point and a pullback sharing the gate exponentials and their
partial products, then one ambient cost gradient through it,
which never forms the Jacobian. That the value comes back with the
pullback is what keeps it to one pass: the covector \(\hat G\) is a function
of the point, so a separate compute_point call would re-exponentiate
every gate. Falls back to value_and_grad_autodiff otherwise.
The gradient is real by construction and returned in the parameter's
own dtype, so it drops straight into geope.optimizers on the
complex128 pulse arrays geope.parameters.Parameters.free hands out.
value_and_grad_autodiff
cached
property
¤
phi -> (infidelity, dinfidelity/dphi) by reverse-mode autodiff.
The reference the analytic path is checked against, and the fallback for a
manifold that declines cost_gradient.
Note that differentiating infidelity_at holomorphically with respect to
a complex128 array whose imaginary part is identically zero gives a
gradient with a spurious imaginary part. value_and_grad does not.
__abstractmethods__
class-attribute
¤
frozenset() -> empty frozenset object frozenset(iterable) -> frozenset object
Build an immutable unordered collection of unique elements.
__annotations__
class-attribute
¤
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__dataclass_fields__
class-attribute
¤
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__dataclass_params__
class-attribute
¤
__doc__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__match_args__
class-attribute
¤
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
__module__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
manifold_dim
property
¤
\(\dim\mathfrak{su}(d) = d^2 - 1\).
name
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
projective
class-attribute
¤
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
project_algebra(x)
¤
Remove the global-phase generator: \(x - \tfrac{\mathrm{Tr}x}{d}\mathbb 1\).
Only the imaginary part of the trace is subtracted, so a skew-Hermitian argument stays exactly skew-Hermitian however much float error its trace has picked up.
fidelity(x, y)
¤
\(|\mathrm{Tr}(x^\dagger y)|/d \in [0, 1]\).
infidelity(x, y)
¤
\(1 - |\mathrm{Tr}(x^\dagger y)|/d \in [0, 1]\).
ambient_inner(x, y)
¤
\(\mathrm{Re}\sum \bar x\,y\) over the ambient axes — the metric of \(\mathcal A\).
The default building block for inner, and correct as it stands for any
manifold whose metric is the one induced by the embedding — which
includes a bi-invariant group metric, where it is
\(\mathrm{Re}\,\mathrm{Tr}(x^\dagger y)\), and the round metric on the
state sphere. A manifold whose metric is not the ambient one must say
so: geope.geometry.stiefel.stiefel.Stiefel carries the canonical metric
\(\mathrm{Re}\,\mathrm{Tr}(x^\dagger W_Q y)\) instead, which is what gives
it different geodesics from the embedding's.
bind(*, target, generators, frame=None, columns=None, wrap_chart=None)
¤
Attach this problem's chart, coefficient frame and target.
The seam between the two layers this package is built on, and it holds no
mathematics of its own: geope.geometry.chart builds the ambient jet
\((\Phi,\ \mathrm D\Phi,\ \mathrm D^2\Phi)\) from generators and this
manifold's base_point, and everything else here is assembly.
Returns a new manifold — this one is frozen — so the unbound mathematical object stays reusable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
Array | ndarray | None
|
The point being synthesised, of shape |
required |
generators
|
Basis
|
The chart's generator sub- |
required |
frame
|
Basis | None
|
The ambient coefficient frame |
None
|
columns
|
ndarray | None
|
Boolean mask over the chart's coefficient columns selecting
those the geodesic solve may move. |
None
|
wrap_chart
|
Callable[[Callable], Callable] | None
|
An opaque reparametrisation of the chart's input, or
That it reparametrises the input is what lets it wrap the landed chart rather than the bare propagator: \(\mathrm{wrap}(\Phi)(\phi) = U(\tau(\phi))\,x_0\) either way, so the base point never has to be threaded through it. |
None
|
Returns:
| Type | Description |
|---|---|
Manifold
|
A bound |
Raises:
| Type | Description |
|---|---|
ValueError
|
If this manifold is already bound, or if |
coefficients(point, tangent)
¤
Resolve skew-Hermitian algebra elements against the ambient frame.
Projection onto the generators \(E_k = \mathrm{basis\_convention} \cdot B_k\) the chart exponentiates:
the real coefficients with \(X = \sum_k c_k E_k\) (metric constant
\(c = 1/d\)). This is the outbound half of the sign convention; both
halves read geope.geometry.basis.Basis.basis_convention, so they
cannot disagree. point is unused: one frame serves every fibre.
The frame must be Hermitian and trace-orthogonal with
\(\mathrm{Tr}(B_j B_k) = d\,\delta_{jk}\) (every geope.utils basis is);
an incomplete frame simply projects onto its subspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Array
|
Unused. |
required |
tangent
|
Array
|
Skew-Hermitian |
required |
Returns:
| Type | Description |
|---|---|
Array
|
A real |
context(free_params, delta_t=1.0)
¤
Open a GeometricContext at the pulse free_params.
Cheap: every quantity on the returned context is lazy, so this on its own
evaluates nothing. Build one per optimisation step, inside the jitted
update — see GeometricContext for why it must not leave that trace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
free_params
|
Array
|
The pulse, shape |
required |
delta_t
|
Array | float
|
The segment duration, threaded (as a traced scalar) into every chart evaluation the context performs. Defaults to 1.0. |
1.0
|
cost_gradient(x, y)
¤
\(\partial C/\partial\bar x\) for the two unitary trace fidelities.
\(-y/(2d)\) phase-sensitively, \(-zy/(2d\lvert z\rvert)\) projectively, with
\(z = \mathrm{Tr}(y^\dagger x)\). See
geope.geometry.cost.trace_cost_gradient.
cost_hessian_form(x, y, u)
¤
The cost's own curvature — zero on \(\mathrm U(d)\), rank-structured on \(\mathrm{SU}(d)\).
\(\mathrm{Re}\,\mathrm{Tr}(y^\dagger x)\) is affine in \(x\), so the
phase-sensitive form vanishes and the whole Hessian is the chart's
bending; \(\lvert\mathrm{Tr}(y^\dagger x)\rvert\) is not, and contributes the
two rank-structured terms of
geope.geometry.cost.trace_cost_hessian_form.
distance2(x, y, key=None)
¤
Half the squared geodesic distance, \(\tfrac12 d_g(x, y)^2\).
The objective the first- and second-order line searches minimise, and the
quantity whose derivatives a GeometricContext reports. Costs one log.
hessian_quadratic_form(point, a, omega)
¤
\(\bigl(\langle\Omega,\mathcal K_A\Omega\rangle_F,\ \rho\bigr)\) on \(\mathfrak{su}(d)\).
\(\mathcal K_A = \frac{\operatorname{ad}_A}{2}\coth(\frac{\operatorname{ad}_A}{2})\),
evaluated without forming the operator, plus the eigenphase spread \(\rho\)
from the same eigendecomposition. Bi-invariance makes it independent of
point, and the kernel is even in \(A\), so either sign convention for
a gives the same value. See
:func:geope.jax.su_hessian_quadratic_form.
inner(point, x, y)
¤
\(\mathrm{Re}\,\mathrm{Tr}(x^\dagger y)\) — bi-invariant, so point is unused.
The ambient metric as it stands: a bi-invariant group metric is the one induced by the embedding in \(\mathbb C^{d\times d}\).
log(x, y, key=None)
¤
\(\mathrm{Log}_x(y) = \mathrm{proj}\bigl(\log_{\min}(x^\dagger y)\bigr)\).
The algebra element \(A\) with \(x\,e^{A} = y\): skew-Hermitian, and traceless on SU. The pipeline's only matrix logarithm — the geodesic search direction, the geodesic-distance objective and the line-search slope and curvature are all algebra on the single \(A\) a step takes from here.
Taking a second logarithm in the conjugate order is not a harmless convention: \(\log(x^\dagger y) = -\log(y^\dagger x)\) fails on the principal branch cut, so a target with a \(-1\) eigenvalue (Hadamard, CNOT, Toffoli) would have the direction and the objective disagree by \(2\pi\) on that eigenphase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array
|
The base point |
required |
y
|
Array
|
The end point |
required |
key
|
Array | None
|
Unused by |
None
|
norm2(point, x)
¤
\(\lVert x\rVert^2_{\text{point}}\).
tangent_acceleration(point, v, w)
¤
\(\dot\Omega(0) = V^\dagger V + U^\dagger W\).
The derivative of \(\Omega(t) = U(t)^\dagger\dot U(t)\) by the product rule — the chart's bending, as opposed to the group's own curvature.
to_tangent(point, ambient)
¤
Left-trivialise: \(\dot X \mapsto U^\dagger\dot X\), skew-Hermitian.
Doing this before projecting is what makes coefficients lossless. The
raw Jacobian columns \(\partial_{g,k}U\) are ambient, of the form
\(U\cdot(\text{skew-Hermitian})\), whose skew-Hermitian part rotates with
\(U\); projecting them directly would discard most of each matrix and make
the geodesic least squares minimise in a \(U\)-dependent seminorm rather
than in \(\langle\cdot,\cdot\rangle_F\). Left translation is itself an
isometry — it is the projection after it that would be lossy, which is
why the two cannot be commuted.
validate_point(point, what='point')
¤
Check membership of the group: \(UU^\dagger = \mathbb 1\).
Every geometric primitive here assumes it — log takes the logarithm
of \(U^\dagger V\) expecting a unitary (so logm_unitary's Schur form is
diagonal), and the fidelity normalisation assumes \(\lvert\mathrm{Tr}
\rvert \le d\). A non-unitary target produces plausible-looking numbers
rather than an error, so it is worth catching at configuration time.
Host-side and numpy; see geope.geometry.manifold.Manifold.validate_point.
__delattr__(name)
¤
__init__(dim, *, base_point=None, target=None, compute_point=None, tangent=None)
¤
__repr__()
¤
__setattr__(name, value)
¤
geope.geometry.lie.groups.UnitaryGroup
¤
\(\mathrm U(d)\) with the phase-sensitive fidelity.
The Lie algebra is all of \(\mathfrak u(d)\) (skew-Hermitian, trace included),
so the global phase is a controllable direction and the fidelity
\(F_{\mathrm{full}} = \mathrm{Re}\,\mathrm{Tr}(x^\dagger y)/d \in [-1, 1]\)
scores it. This is projective=False; see docs/user_guide.md for the
gotchas with traceless targets near the identity.
__dict__
class-attribute
¤
__weakref__
property
¤
list of weak references to the object
ambient_ndim
property
¤
The number of array axes one point has.
ambient_shape
property
¤
fidelity_at
cached
property
¤
phi -> the fidelity of the pulse phi against the target.
Compiled and memoised rather than evaluated eagerly, because the
host-side loops call it one trial pulse at a time: uncompiled, each
call re-lowers the chart's jax.lax.scan, which cost ~100 ms per
call on a 3-qubit, 20-step pulse and made geope.Geope's
Gram-Schmidt fallback more expensive than the whole geodesic step it
was replacing.
has_cost_gradient
property
¤
Whether this manifold overrides cost_gradient.
A host-side capability probe — an identity check on the bound method's
function, so nothing is traced and no exception has to be caught inside a
jax.jit. value_and_grad reads it to pick its path.
has_cost_hessian_form
property
¤
Whether this manifold overrides cost_hessian_form. See has_cost_gradient.
hessian
cached
property
¤
The infidelity Hessian (P, P) (used by GRAPE's Newton methods).
Analytic when this manifold supplies cost_hessian_form and the chart
has a second differential to offer
(geope.geometry.tangent.TangentBundle.hessian_vjp). The assembly is the
chain rule in two terms — the cost's own curvature and the chart's
bending —
the first from the hook and the second generic, since \(\hat G\) is just
cost_gradient. Falls back to hessian_autodiff otherwise.
The second term never forms \(\mathrm D^2\Phi\): the pullback splits the
pair table into a Gram matrix of two \(O(G)\)-propagated derivative
trajectories — see geope.jax.hessian_vjp_propagator — so a Newton step
costs \(O(GKd^3 + G^2K^2md)\) in flops and \(O(GKmd + (GK)^2)\) in memory
rather than the dense route's \(O(G^2K^2d^3)\) and \(O(G^2K^2d^2)\). That the
point comes back with the pullback keeps it to one pass over the pulse,
exactly as in value_and_grad.
The Jacobian is built only for the projective \(\zeta\) term; a
phase-sensitive cost's cost_hessian_form ignores its columns, and XLA
eliminates the whole computation.
hessian_autodiff
cached
property
¤
The infidelity Hessian (P, P) by forward-over-reverse HVPs.
The reference the analytic path is checked against, and the fallback
wherever the analytic one is unavailable — a manifold that declines
cost_hessian_form, or the param_transform chart, which has no
second differential to build one from.
Carries the same spurious imaginary part as value_and_grad_autodiff on
a complex128 pulse whose imaginary part is identically zero — it
differentiates the same holomorphic gradient. Its real part is right
in every case, and it is exact on the float64 pulses of the
param_transform path where it is actually used. Compare against it on
real input.
infidelity_at
cached
property
¤
phi -> the infidelity of the pulse phi — what GRAPE minimises.
Compiled and memoised, for the same reason as fidelity_at.
is_bound
property
¤
Whether a chart, tangent bundle and target are attached.
value_and_grad
cached
property
¤
phi -> (infidelity, dinfidelity/dphi) (used by GRAPE).
Analytic when this manifold supplies cost_gradient: one pass over
the pulse through geope.geometry.tangent.TangentBundle.vjp, which
returns the point and a pullback sharing the gate exponentials and their
partial products, then one ambient cost gradient through it,
which never forms the Jacobian. That the value comes back with the
pullback is what keeps it to one pass: the covector \(\hat G\) is a function
of the point, so a separate compute_point call would re-exponentiate
every gate. Falls back to value_and_grad_autodiff otherwise.
The gradient is real by construction and returned in the parameter's
own dtype, so it drops straight into geope.optimizers on the
complex128 pulse arrays geope.parameters.Parameters.free hands out.
value_and_grad_autodiff
cached
property
¤
phi -> (infidelity, dinfidelity/dphi) by reverse-mode autodiff.
The reference the analytic path is checked against, and the fallback for a
manifold that declines cost_gradient.
Note that differentiating infidelity_at holomorphically with respect to
a complex128 array whose imaginary part is identically zero gives a
gradient with a spurious imaginary part. value_and_grad does not.
__abstractmethods__
class-attribute
¤
frozenset() -> empty frozenset object frozenset(iterable) -> frozenset object
Build an immutable unordered collection of unique elements.
__annotations__
class-attribute
¤
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__dataclass_fields__
class-attribute
¤
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__dataclass_params__
class-attribute
¤
__doc__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__match_args__
class-attribute
¤
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
__module__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
manifold_dim
property
¤
\(\dim\mathfrak u(d) = d^2\).
name
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
projective
class-attribute
¤
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
project_algebra(x)
¤
Identity: every skew-Hermitian matrix is already in \(\mathfrak u(d)\).
fidelity(x, y)
¤
\(\mathrm{Re}\,\mathrm{Tr}(x^\dagger y)/d \in [-1, 1]\).
infidelity(x, y)
¤
\(1 - \mathrm{Re}\,\mathrm{Tr}(x^\dagger y)/d \in [0, 2]\).
ambient_inner(x, y)
¤
\(\mathrm{Re}\sum \bar x\,y\) over the ambient axes — the metric of \(\mathcal A\).
The default building block for inner, and correct as it stands for any
manifold whose metric is the one induced by the embedding — which
includes a bi-invariant group metric, where it is
\(\mathrm{Re}\,\mathrm{Tr}(x^\dagger y)\), and the round metric on the
state sphere. A manifold whose metric is not the ambient one must say
so: geope.geometry.stiefel.stiefel.Stiefel carries the canonical metric
\(\mathrm{Re}\,\mathrm{Tr}(x^\dagger W_Q y)\) instead, which is what gives
it different geodesics from the embedding's.
bind(*, target, generators, frame=None, columns=None, wrap_chart=None)
¤
Attach this problem's chart, coefficient frame and target.
The seam between the two layers this package is built on, and it holds no
mathematics of its own: geope.geometry.chart builds the ambient jet
\((\Phi,\ \mathrm D\Phi,\ \mathrm D^2\Phi)\) from generators and this
manifold's base_point, and everything else here is assembly.
Returns a new manifold — this one is frozen — so the unbound mathematical object stays reusable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
Array | ndarray | None
|
The point being synthesised, of shape |
required |
generators
|
Basis
|
The chart's generator sub- |
required |
frame
|
Basis | None
|
The ambient coefficient frame |
None
|
columns
|
ndarray | None
|
Boolean mask over the chart's coefficient columns selecting
those the geodesic solve may move. |
None
|
wrap_chart
|
Callable[[Callable], Callable] | None
|
An opaque reparametrisation of the chart's input, or
That it reparametrises the input is what lets it wrap the landed chart rather than the bare propagator: \(\mathrm{wrap}(\Phi)(\phi) = U(\tau(\phi))\,x_0\) either way, so the base point never has to be threaded through it. |
None
|
Returns:
| Type | Description |
|---|---|
Manifold
|
A bound |
Raises:
| Type | Description |
|---|---|
ValueError
|
If this manifold is already bound, or if |
coefficients(point, tangent)
¤
Resolve skew-Hermitian algebra elements against the ambient frame.
Projection onto the generators \(E_k = \mathrm{basis\_convention} \cdot B_k\) the chart exponentiates:
the real coefficients with \(X = \sum_k c_k E_k\) (metric constant
\(c = 1/d\)). This is the outbound half of the sign convention; both
halves read geope.geometry.basis.Basis.basis_convention, so they
cannot disagree. point is unused: one frame serves every fibre.
The frame must be Hermitian and trace-orthogonal with
\(\mathrm{Tr}(B_j B_k) = d\,\delta_{jk}\) (every geope.utils basis is);
an incomplete frame simply projects onto its subspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Array
|
Unused. |
required |
tangent
|
Array
|
Skew-Hermitian |
required |
Returns:
| Type | Description |
|---|---|
Array
|
A real |
context(free_params, delta_t=1.0)
¤
Open a GeometricContext at the pulse free_params.
Cheap: every quantity on the returned context is lazy, so this on its own
evaluates nothing. Build one per optimisation step, inside the jitted
update — see GeometricContext for why it must not leave that trace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
free_params
|
Array
|
The pulse, shape |
required |
delta_t
|
Array | float
|
The segment duration, threaded (as a traced scalar) into every chart evaluation the context performs. Defaults to 1.0. |
1.0
|
cost_gradient(x, y)
¤
\(\partial C/\partial\bar x\) for the two unitary trace fidelities.
\(-y/(2d)\) phase-sensitively, \(-zy/(2d\lvert z\rvert)\) projectively, with
\(z = \mathrm{Tr}(y^\dagger x)\). See
geope.geometry.cost.trace_cost_gradient.
cost_hessian_form(x, y, u)
¤
The cost's own curvature — zero on \(\mathrm U(d)\), rank-structured on \(\mathrm{SU}(d)\).
\(\mathrm{Re}\,\mathrm{Tr}(y^\dagger x)\) is affine in \(x\), so the
phase-sensitive form vanishes and the whole Hessian is the chart's
bending; \(\lvert\mathrm{Tr}(y^\dagger x)\rvert\) is not, and contributes the
two rank-structured terms of
geope.geometry.cost.trace_cost_hessian_form.
distance2(x, y, key=None)
¤
Half the squared geodesic distance, \(\tfrac12 d_g(x, y)^2\).
The objective the first- and second-order line searches minimise, and the
quantity whose derivatives a GeometricContext reports. Costs one log.
hessian_quadratic_form(point, a, omega)
¤
\(\bigl(\langle\Omega,\mathcal K_A\Omega\rangle_F,\ \rho\bigr)\) on \(\mathfrak{su}(d)\).
\(\mathcal K_A = \frac{\operatorname{ad}_A}{2}\coth(\frac{\operatorname{ad}_A}{2})\),
evaluated without forming the operator, plus the eigenphase spread \(\rho\)
from the same eigendecomposition. Bi-invariance makes it independent of
point, and the kernel is even in \(A\), so either sign convention for
a gives the same value. See
:func:geope.jax.su_hessian_quadratic_form.
inner(point, x, y)
¤
\(\mathrm{Re}\,\mathrm{Tr}(x^\dagger y)\) — bi-invariant, so point is unused.
The ambient metric as it stands: a bi-invariant group metric is the one induced by the embedding in \(\mathbb C^{d\times d}\).
log(x, y, key=None)
¤
\(\mathrm{Log}_x(y) = \mathrm{proj}\bigl(\log_{\min}(x^\dagger y)\bigr)\).
The algebra element \(A\) with \(x\,e^{A} = y\): skew-Hermitian, and traceless on SU. The pipeline's only matrix logarithm — the geodesic search direction, the geodesic-distance objective and the line-search slope and curvature are all algebra on the single \(A\) a step takes from here.
Taking a second logarithm in the conjugate order is not a harmless convention: \(\log(x^\dagger y) = -\log(y^\dagger x)\) fails on the principal branch cut, so a target with a \(-1\) eigenvalue (Hadamard, CNOT, Toffoli) would have the direction and the objective disagree by \(2\pi\) on that eigenphase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array
|
The base point |
required |
y
|
Array
|
The end point |
required |
key
|
Array | None
|
Unused by |
None
|
norm2(point, x)
¤
\(\lVert x\rVert^2_{\text{point}}\).
tangent_acceleration(point, v, w)
¤
\(\dot\Omega(0) = V^\dagger V + U^\dagger W\).
The derivative of \(\Omega(t) = U(t)^\dagger\dot U(t)\) by the product rule — the chart's bending, as opposed to the group's own curvature.
to_tangent(point, ambient)
¤
Left-trivialise: \(\dot X \mapsto U^\dagger\dot X\), skew-Hermitian.
Doing this before projecting is what makes coefficients lossless. The
raw Jacobian columns \(\partial_{g,k}U\) are ambient, of the form
\(U\cdot(\text{skew-Hermitian})\), whose skew-Hermitian part rotates with
\(U\); projecting them directly would discard most of each matrix and make
the geodesic least squares minimise in a \(U\)-dependent seminorm rather
than in \(\langle\cdot,\cdot\rangle_F\). Left translation is itself an
isometry — it is the projection after it that would be lossy, which is
why the two cannot be commuted.
validate_point(point, what='point')
¤
Check membership of the group: \(UU^\dagger = \mathbb 1\).
Every geometric primitive here assumes it — log takes the logarithm
of \(U^\dagger V\) expecting a unitary (so logm_unitary's Schur form is
diagonal), and the fidelity normalisation assumes \(\lvert\mathrm{Tr}
\rvert \le d\). A non-unitary target produces plausible-looking numbers
rather than an error, so it is worth catching at configuration time.
Host-side and numpy; see geope.geometry.manifold.Manifold.validate_point.
__delattr__(name)
¤
__init__(dim, *, base_point=None, target=None, compute_point=None, tangent=None)
¤
__repr__()
¤
__setattr__(name, value)
¤
The Stiefel family¤
Manifolds of orthonormal frames, \(\mathrm{St}_m(\mathbb{C}^N) = \{Q \in \mathbb{C}^{N\times m} : Q^\dagger Q = \mathbb 1_m\}\). These are homogeneous spaces \(\mathrm{U}(N)/\mathrm{U}(N-m)\), not groups, so they implement the point-based interface directly.
They are what to synthesise on when only an \(m\)-dimensional subspace of the target matters — a gate mediated by a bosonic mode, a subspace encoding, a state preparation. The rest of the unitary is redundancy, and quotienting it out is cheaper than optimising over it.
geope.geometry.stiefel.stiefel.Stiefel
¤
\(\mathrm{St}_m(\mathbb C^N) = \{Q \in \mathbb C^{N\times m} : Q^\dagger Q = \mathbb 1_m\}\).
A point is an orthonormal \(m\)-frame; the chart is the pulse's unitary acting on a fixed frame, \(\Phi(\phi) = U(\phi)E\), so the product-of-exponentials machinery carries over unchanged and the Jacobian and HVP are the group's composed with one matrix product.
Not a Lie group. \(\mathrm{St}_m(\mathbb C^N) = \mathrm U(N)/\mathrm U(N-m)\) is a homogeneous space: no identity, no left translation, no trivialisation identifying tangent spaces at different points. Everything here is genuinely point-dependent, the metric included.
Attributes:
| Name | Type | Description |
|---|---|---|
dim |
The ambient Hilbert-space dimension \(N\). |
|
frame |
The number of frame columns \(m\); a point is |
|
base_point |
The frame \(E\) the chart acts on, |
|
projective |
Whether a global phase is physical. |
|
log_tol |
Convergence tolerance \(\kappa\) of the iterative logarithm. |
|
log_max_iter |
Iteration cap of the iterative logarithm. |
__dict__
class-attribute
¤
__weakref__
property
¤
list of weak references to the object
ambient_ndim
property
¤
The number of array axes one point has.
fidelity_at
cached
property
¤
phi -> the fidelity of the pulse phi against the target.
Compiled and memoised rather than evaluated eagerly, because the
host-side loops call it one trial pulse at a time: uncompiled, each
call re-lowers the chart's jax.lax.scan, which cost ~100 ms per
call on a 3-qubit, 20-step pulse and made geope.Geope's
Gram-Schmidt fallback more expensive than the whole geodesic step it
was replacing.
has_cost_gradient
property
¤
Whether this manifold overrides cost_gradient.
A host-side capability probe — an identity check on the bound method's
function, so nothing is traced and no exception has to be caught inside a
jax.jit. value_and_grad reads it to pick its path.
has_cost_hessian_form
property
¤
Whether this manifold overrides cost_hessian_form. See has_cost_gradient.
hessian
cached
property
¤
The infidelity Hessian (P, P) (used by GRAPE's Newton methods).
Analytic when this manifold supplies cost_hessian_form and the chart
has a second differential to offer
(geope.geometry.tangent.TangentBundle.hessian_vjp). The assembly is the
chain rule in two terms — the cost's own curvature and the chart's
bending —
the first from the hook and the second generic, since \(\hat G\) is just
cost_gradient. Falls back to hessian_autodiff otherwise.
The second term never forms \(\mathrm D^2\Phi\): the pullback splits the
pair table into a Gram matrix of two \(O(G)\)-propagated derivative
trajectories — see geope.jax.hessian_vjp_propagator — so a Newton step
costs \(O(GKd^3 + G^2K^2md)\) in flops and \(O(GKmd + (GK)^2)\) in memory
rather than the dense route's \(O(G^2K^2d^3)\) and \(O(G^2K^2d^2)\). That the
point comes back with the pullback keeps it to one pass over the pulse,
exactly as in value_and_grad.
The Jacobian is built only for the projective \(\zeta\) term; a
phase-sensitive cost's cost_hessian_form ignores its columns, and XLA
eliminates the whole computation.
hessian_autodiff
cached
property
¤
The infidelity Hessian (P, P) by forward-over-reverse HVPs.
The reference the analytic path is checked against, and the fallback
wherever the analytic one is unavailable — a manifold that declines
cost_hessian_form, or the param_transform chart, which has no
second differential to build one from.
Carries the same spurious imaginary part as value_and_grad_autodiff on
a complex128 pulse whose imaginary part is identically zero — it
differentiates the same holomorphic gradient. Its real part is right
in every case, and it is exact on the float64 pulses of the
param_transform path where it is actually used. Compare against it on
real input.
infidelity_at
cached
property
¤
phi -> the infidelity of the pulse phi — what GRAPE minimises.
Compiled and memoised, for the same reason as fidelity_at.
is_bound
property
¤
Whether a chart, tangent bundle and target are attached.
value_and_grad
cached
property
¤
phi -> (infidelity, dinfidelity/dphi) (used by GRAPE).
Analytic when this manifold supplies cost_gradient: one pass over
the pulse through geope.geometry.tangent.TangentBundle.vjp, which
returns the point and a pullback sharing the gate exponentials and their
partial products, then one ambient cost gradient through it,
which never forms the Jacobian. That the value comes back with the
pullback is what keeps it to one pass: the covector \(\hat G\) is a function
of the point, so a separate compute_point call would re-exponentiate
every gate. Falls back to value_and_grad_autodiff otherwise.
The gradient is real by construction and returned in the parameter's
own dtype, so it drops straight into geope.optimizers on the
complex128 pulse arrays geope.parameters.Parameters.free hands out.
value_and_grad_autodiff
cached
property
¤
phi -> (infidelity, dinfidelity/dphi) by reverse-mode autodiff.
The reference the analytic path is checked against, and the fallback for a
manifold that declines cost_gradient.
Note that differentiating infidelity_at holomorphically with respect to
a complex128 array whose imaginary part is identically zero gives a
gradient with a spurious imaginary part. value_and_grad does not.
__abstractmethods__
class-attribute
¤
frozenset() -> empty frozenset object frozenset(iterable) -> frozenset object
Build an immutable unordered collection of unique elements.
__annotations__
class-attribute
¤
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__dataclass_fields__
class-attribute
¤
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__dataclass_params__
class-attribute
¤
__doc__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__match_args__
class-attribute
¤
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
__module__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
ambient_shape
property
¤
log_max_iter
class-attribute
¤
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal.
int('0b100', base=0) 4
log_tol
class-attribute
¤
Convert a string or number to a floating point number, if possible.
manifold_dim
property
¤
\(2Nm - m^2\), less one more when the global phase is quotiented out.
The same \(-1\) that separates \(\mathfrak{su}(d)\) from \(\mathfrak u(d)\).
name
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
projective
class-attribute
¤
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
__post_init__()
¤
validate_point(point, what='point')
¤
Check membership: \(Q^\dagger Q = \mathbb 1_m\).
Host-side and numpy; see geope.geometry.manifold.Manifold.validate_point.
to_tangent(point, ambient)
¤
Project onto \(T_Q = \{\Delta : Q^\dagger\Delta + \Delta^\dagger Q = 0\}\).
\(Z \mapsto Z - Q\,\mathrm{sym}(Q^\dagger Z)\): it removes only the
Hermitian part of \(Q^\dagger Z\), leaving the skew-Hermitian part, which
is the frame rotation. Contrast
geope.geometry.stiefel.sphere.StateSphere, which removes the whole
complex component and so lands in \(\mathbb{CP}^{n-1}\) rather than the
sphere.
inner(point, x, y)
¤
The canonical metric \(\mathrm{Re}\,\mathrm{Tr}(x^\dagger W_Q y)\).
With \(W_Q = \mathbb 1 - \tfrac12 QQ^\dagger\): the in-frame rotations carry half the weight of the leakage directions, which is what distinguishes this from the embedded Frobenius metric and gives it different geodesics.
coefficients(point, tangent)
¤
Real coordinates in which the canonical metric is the dot product.
\(\Delta \mapsto [\mathrm{Re}\,W_Q^{1/2}\Delta,\ \mathrm{Im}\,W_Q^{1/2}\Delta]\)
flattened, with \(W_Q^{1/2} = \mathbb 1 - (1 - \tfrac1{\sqrt2})QQ^\dagger\).
Then \(\sum_k c_k(u)c_k(v) = \mathrm{Re}\,\mathrm{Tr}(u^\dagger W_Q v) =
\langle u,v\rangle_Q\) exactly, so the Manifold.coefficients constant is
\(c = 1\).
This one hook is the whole canonical-metric story: because gammas and
omegas both pass through it, the geodesic least-squares problem is
automatically posed in the canonical norm, with no change to the
optimiser. It is the \(W_Q^{1/2}\) reweighting of the operands written once,
in the only place it belongs.
The image is a proper subspace — \(T_Q\) has real dimension \(2Nm - m^2\) inside \(2Nm\) coordinates — which the contract explicitly allows: the solve needs faithfulness, not surjectivity.
log(x, y, key=None)
¤
\(\mathrm{Log}_Q(Q_\star)\) by the Zimmermann–Hüper iteration.
Why the phase alignment matters. The canonical logarithm is not
phase-invariant — \(\mathrm{Log}_Q(e^{i\theta}Q_\star) \ne
\mathrm{Log}_Q(Q_\star)\), and its norm grows with \(\theta\) — while the
projective fidelity \(\lvert\mathrm{Tr}\rvert/m\) is. Left alone, the
distance objective the Armijo family minimises and the fidelity
convergence is tested on would disagree: the optimiser would be forced to
fix a physically meaningless global phase. With projective=True the
target is first rotated onto its horizontal lift, which makes the two
agree and reproduces StateSphere exactly at \(m = 1\).
What round-trips, in projective mode. exp(log(Q, Q_star)) recovers
\(Q_\star\) up to a global phase — to machine precision, and at fidelity
exactly 1 — but not the tangent that was exponentiated to reach it. The
alignment picks the overlap-real representative of the \(\mathrm U(1)\)
orbit, which coincides with the submersion's horizontal lift exactly at
\(m = 1\) and only to first order beyond it: \(\mathrm{Tr}(Q^\dagger\gamma(t))\)
acquires a small imaginary part along the geodesic even when
\(\mathrm{Tr}(Q^\dagger\Delta) = 0\). The gauge is smooth, phase-invariant
and consistent, which is all the algorithm needs; projective=False
round-trips the tangent itself exactly.
Beyond the injectivity radius this returns the minimal geodesic, which
need not be the one an exp was taken along — the usual cut-locus
caveat, empirically biting around \(\lVert\Delta\rVert \gtrsim 2\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array
|
The base frame |
required |
y
|
Array
|
The end frame |
required |
key
|
Array | None
|
Unused; accepted for interface parity. |
None
|
exp(point, tangent)
¤
\(\mathrm{Exp}_Q(\Delta) = (Q\,|\,Q_\perp)\exp(S)(\mathbb 1_m; 0)^\intercal\).
With \(A = Q^\dagger\Delta\), \(Q_\perp R = (\mathbb 1 - QQ^\dagger)\Delta\) by QR, and \(S = \bigl(\begin{smallmatrix} A & -R^\dagger\\ R & 0\end{smallmatrix}\bigr) \in \mathfrak u(2m)\) — a \(2m\times2m\) exponential rather than the \(N\times N\) one the naive form would need.
Not a Manifold hook: the pipeline never needs to move along a
geodesic, only to read its initial tangent. This exists so that log can
be tested by round trip, which is the only convincing way to validate an
iterative solver.
tangent_acceleration(point, v, w)
¤
\(\dot\Omega(0) = W - V\,\mathrm{sym}(Q^\dagger V) - Q\,\mathrm{sym}(V^\dagger V + Q^\dagger W)\).
The product-rule derivative of \(\Omega(t) = \dot X - X\,\mathrm{sym} (X^\dagger\dot X)\) along the chart's curve — the projection's own bending, which on a group would instead be \(V^\dagger V + U^\dagger W\).
hessian_quadratic_form(point, a, omega)
¤
The block-Jacobi form \(\langle Z, E_{12}^{-1}E_{11}Z\rangle\) — phase-blind only.
There is no eigenangle formula: a general Stiefel manifold is normal
homogeneous but not symmetric, so neither the group's
\(\frac{\mathrm{ad}}{2}\coth\frac{\mathrm{ad}}{2}\) nor the sphere's
\(\theta\cot\theta\) applies. What does exist is exact — the Jacobi
equation has constant coefficients in a homogeneous moving frame, so
\(\mathcal K^{\mathrm{St}}_S\) is read off the blocks of one operator
exponential. See geope.jax.stiefel_hessian_quadratic_form.
Note the negation. The context hands over a = -Log_Q(Q_star),
pointing away from the target, and unlike \(\mathfrak{su}(d)\) this form
is genuinely not even in its argument — \(-\Delta\) addresses the
geodesic reflection of the target, a different Hessian. Only at \(m = N\)
does evenness return, because there the manifold is the group.
Unavailable when projective. Phase alignment inside log makes
the objective the squared distance on the \(\mathrm U(1)\) quotient
\(\mathrm{St}_m(\mathbb C^N)/\mathrm U(1)\), whose Hessian carries an
O'Neill term this construction does not have; measured against a finite
difference of distance2, the total-space form is off by up to a few
percent there. Rather than let ApproximateQuadraticArmijo quietly stop
being exact, this fails — the same way a missing TangentBundle.hvp does
under param_transform. The other three line searches run in both
modes, and geope.line_searches.QuadraticArmijo builds its curvature
from ctx.q, which uses the radial surrogate \(\lVert\Omega\rVert^2\)
and never calls this.
fidelity(x, y)
¤
\(\lvert\mathrm{Tr}(y^\dagger x)\rvert/m\), or \(\mathrm{Re}\,\mathrm{Tr}/m\).
The subspace fidelity: it scores only how the frames overlap, and is blind to whatever the pulse does outside the \(m\) columns — which is the redundancy this manifold exists to exploit.
infidelity(x, y)
¤
\(1 - F(x, y)\).
cost_gradient(x, y)
¤
\(\partial C/\partial\bar x\) for the subspace fidelity, \(\kappa = m\).
Note this is the ambient gradient of the cost, not a Riemannian one —
the canonical metric enters through coefficients, not here, because the
chain rule out of the chart is metric-free. See
geope.geometry.cost.trace_cost_gradient.
cost_hessian_form(x, y, u)
¤
The cost's own curvature: zero when phase-sensitive, the projective pair otherwise.
Unlike hessian_quadratic_form, this is available in both modes: it
is a derivative of the fidelity, which is defined either way, not of the
geodesic distance on the \(\mathrm U(1)\) quotient.
ambient_inner(x, y)
¤
\(\mathrm{Re}\sum \bar x\,y\) over the ambient axes — the metric of \(\mathcal A\).
The default building block for inner, and correct as it stands for any
manifold whose metric is the one induced by the embedding — which
includes a bi-invariant group metric, where it is
\(\mathrm{Re}\,\mathrm{Tr}(x^\dagger y)\), and the round metric on the
state sphere. A manifold whose metric is not the ambient one must say
so: geope.geometry.stiefel.stiefel.Stiefel carries the canonical metric
\(\mathrm{Re}\,\mathrm{Tr}(x^\dagger W_Q y)\) instead, which is what gives
it different geodesics from the embedding's.
bind(*, target, generators, frame=None, columns=None, wrap_chart=None)
¤
Attach this problem's chart, coefficient frame and target.
The seam between the two layers this package is built on, and it holds no
mathematics of its own: geope.geometry.chart builds the ambient jet
\((\Phi,\ \mathrm D\Phi,\ \mathrm D^2\Phi)\) from generators and this
manifold's base_point, and everything else here is assembly.
Returns a new manifold — this one is frozen — so the unbound mathematical object stays reusable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
Array | ndarray | None
|
The point being synthesised, of shape |
required |
generators
|
Basis
|
The chart's generator sub- |
required |
frame
|
Basis | None
|
The ambient coefficient frame |
None
|
columns
|
ndarray | None
|
Boolean mask over the chart's coefficient columns selecting
those the geodesic solve may move. |
None
|
wrap_chart
|
Callable[[Callable], Callable] | None
|
An opaque reparametrisation of the chart's input, or
That it reparametrises the input is what lets it wrap the landed chart rather than the bare propagator: \(\mathrm{wrap}(\Phi)(\phi) = U(\tau(\phi))\,x_0\) either way, so the base point never has to be threaded through it. |
None
|
Returns:
| Type | Description |
|---|---|
Manifold
|
A bound |
Raises:
| Type | Description |
|---|---|
ValueError
|
If this manifold is already bound, or if |
context(free_params, delta_t=1.0)
¤
Open a GeometricContext at the pulse free_params.
Cheap: every quantity on the returned context is lazy, so this on its own
evaluates nothing. Build one per optimisation step, inside the jitted
update — see GeometricContext for why it must not leave that trace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
free_params
|
Array
|
The pulse, shape |
required |
delta_t
|
Array | float
|
The segment duration, threaded (as a traced scalar) into every chart evaluation the context performs. Defaults to 1.0. |
1.0
|
distance2(x, y, key=None)
¤
Half the squared geodesic distance, \(\tfrac12 d_g(x, y)^2\).
The objective the first- and second-order line searches minimise, and the
quantity whose derivatives a GeometricContext reports. Costs one log.
norm2(point, x)
¤
\(\lVert x\rVert^2_{\text{point}}\).
__delattr__(name)
¤
__init__(dim, frame, *, base_point=None, target=None, compute_point=None, tangent=None, projective=True, log_tol=1e-13, log_max_iter=100)
¤
__repr__()
¤
__setattr__(name, value)
¤
geope.geometry.stiefel.sphere.StateSphere
¤
\(\mathbb{CP}^{n-1}\): unit states in \(\mathbb C^n\), up to a global phase.
A point is a normalised state vector; the chart is the pulse's unitary acting on a fixed initial state, \(\Phi(\phi) = U(\phi)\lvert\psi_0\rangle\), so the whole product-of-exponentials machinery carries over unchanged and the Jacobian and HVP are the group's composed with one matrix-vector product.
Not a Lie group. \(\mathrm{St}(n,1) = \mathrm U(n)/\mathrm U(n-1)\) is a
homogeneous space: no identity, no left translation, and therefore no
trivialisation identifying the tangent spaces at different points. Everything
here is genuinely point-dependent — to_tangent is a projection rather than a
translation, and log is a great-circle formula rather than a matrix
logarithm.
Phase invariance. The geometry is the Fubini–Study one: log first rotates
the target's phase so that \(\langle x, y\rangle \ge 0\), which is the
horizontal lift of the Hopf fibration, and the fidelity is
\(\lvert\langle x, y\rangle\rvert\) — matching
geope.geometry.lie.groups.SpecialUnitaryGroup's convention that a global
phase is not physical. A phase-sensitive \(S^{2n-1}\) variant is a subclass
overriding log and fidelity to drop that alignment.
The cut locus is the antipode, \(\lvert\langle x,y\rangle\rvert = 0\): there the
minimal geodesic is not unique and log returns the degenerate 0, the
same measure-zero caveat the matrix logarithm has at \(\theta = 2\pi\).
Attributes:
| Name | Type | Description |
|---|---|---|
dim |
The Hilbert-space dimension \(n\); a point is an |
|
base_point |
The initial state \(\lvert\psi_0\rangle\) the chart acts on;
must be a unit vector of shape |
__dict__
class-attribute
¤
__weakref__
property
¤
list of weak references to the object
ambient_ndim
property
¤
The number of array axes one point has.
fidelity_at
cached
property
¤
phi -> the fidelity of the pulse phi against the target.
Compiled and memoised rather than evaluated eagerly, because the
host-side loops call it one trial pulse at a time: uncompiled, each
call re-lowers the chart's jax.lax.scan, which cost ~100 ms per
call on a 3-qubit, 20-step pulse and made geope.Geope's
Gram-Schmidt fallback more expensive than the whole geodesic step it
was replacing.
has_cost_gradient
property
¤
Whether this manifold overrides cost_gradient.
A host-side capability probe — an identity check on the bound method's
function, so nothing is traced and no exception has to be caught inside a
jax.jit. value_and_grad reads it to pick its path.
has_cost_hessian_form
property
¤
Whether this manifold overrides cost_hessian_form. See has_cost_gradient.
hessian
cached
property
¤
The infidelity Hessian (P, P) (used by GRAPE's Newton methods).
Analytic when this manifold supplies cost_hessian_form and the chart
has a second differential to offer
(geope.geometry.tangent.TangentBundle.hessian_vjp). The assembly is the
chain rule in two terms — the cost's own curvature and the chart's
bending —
the first from the hook and the second generic, since \(\hat G\) is just
cost_gradient. Falls back to hessian_autodiff otherwise.
The second term never forms \(\mathrm D^2\Phi\): the pullback splits the
pair table into a Gram matrix of two \(O(G)\)-propagated derivative
trajectories — see geope.jax.hessian_vjp_propagator — so a Newton step
costs \(O(GKd^3 + G^2K^2md)\) in flops and \(O(GKmd + (GK)^2)\) in memory
rather than the dense route's \(O(G^2K^2d^3)\) and \(O(G^2K^2d^2)\). That the
point comes back with the pullback keeps it to one pass over the pulse,
exactly as in value_and_grad.
The Jacobian is built only for the projective \(\zeta\) term; a
phase-sensitive cost's cost_hessian_form ignores its columns, and XLA
eliminates the whole computation.
hessian_autodiff
cached
property
¤
The infidelity Hessian (P, P) by forward-over-reverse HVPs.
The reference the analytic path is checked against, and the fallback
wherever the analytic one is unavailable — a manifold that declines
cost_hessian_form, or the param_transform chart, which has no
second differential to build one from.
Carries the same spurious imaginary part as value_and_grad_autodiff on
a complex128 pulse whose imaginary part is identically zero — it
differentiates the same holomorphic gradient. Its real part is right
in every case, and it is exact on the float64 pulses of the
param_transform path where it is actually used. Compare against it on
real input.
infidelity_at
cached
property
¤
phi -> the infidelity of the pulse phi — what GRAPE minimises.
Compiled and memoised, for the same reason as fidelity_at.
is_bound
property
¤
Whether a chart, tangent bundle and target are attached.
value_and_grad
cached
property
¤
phi -> (infidelity, dinfidelity/dphi) (used by GRAPE).
Analytic when this manifold supplies cost_gradient: one pass over
the pulse through geope.geometry.tangent.TangentBundle.vjp, which
returns the point and a pullback sharing the gate exponentials and their
partial products, then one ambient cost gradient through it,
which never forms the Jacobian. That the value comes back with the
pullback is what keeps it to one pass: the covector \(\hat G\) is a function
of the point, so a separate compute_point call would re-exponentiate
every gate. Falls back to value_and_grad_autodiff otherwise.
The gradient is real by construction and returned in the parameter's
own dtype, so it drops straight into geope.optimizers on the
complex128 pulse arrays geope.parameters.Parameters.free hands out.
value_and_grad_autodiff
cached
property
¤
phi -> (infidelity, dinfidelity/dphi) by reverse-mode autodiff.
The reference the analytic path is checked against, and the fallback for a
manifold that declines cost_gradient.
Note that differentiating infidelity_at holomorphically with respect to
a complex128 array whose imaginary part is identically zero gives a
gradient with a spurious imaginary part. value_and_grad does not.
__abstractmethods__
class-attribute
¤
frozenset() -> empty frozenset object frozenset(iterable) -> frozenset object
Build an immutable unordered collection of unique elements.
__annotations__
class-attribute
¤
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__dataclass_fields__
class-attribute
¤
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
__dataclass_params__
class-attribute
¤
__doc__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__match_args__
class-attribute
¤
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
__module__
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
ambient_shape
property
¤
manifold_dim
property
¤
\(\dim_{\mathbb R}\mathbb{CP}^{n-1} = 2n - 2\).
name
class-attribute
¤
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
projective
class-attribute
¤
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
__post_init__()
¤
validate_point(point, what='point')
¤
Check membership of the sphere: \(\lVert x\rVert = 1\).
Every geodesic formula here assumes it — log reads \(\arccos\lvert
\langle x,y\rangle\rvert\) as an angle, which is only a distance on the
unit sphere.
Host-side and numpy; see geope.geometry.manifold.Manifold.validate_point.
to_tangent(point, ambient)
¤
Project onto \(T_x = \{z : \langle x, z\rangle = 0\}\): \(z - x\langle x,z\rangle\).
Removes the whole complex component along \(x\), i.e. both the radial direction and the phase direction — which is exactly the horizontal space of the Hopf fibration, and so the right tangent space for the projective geometry.
inner(point, x, y)
¤
\(\mathrm{Re}\langle x, y\rangle\) — the round metric, inherited from \(\mathbb C^n\).
coefficients(point, tangent)
¤
Split into real and imaginary parts: \(u \mapsto (\mathrm{Re}\,u, \mathrm{Im}\,u)\).
There is no global frame to resolve against on a non-parallelisable
manifold, and none is needed: this is a faithful real-linear map with
\(\sum_k c_k(u)c_k(v) = \mathrm{Re}\langle u,v\rangle\) exactly, so the
Manifold.coefficients constant is \(c = 1\). Its image is a hyperplane
(tangency is one real constraint), which the contract explicitly allows —
the least-squares problem needs faithfulness, not surjectivity.
log(x, y, key=None)
¤
\(\mathrm{Log}_x(y) = \theta\,\hat u\) along the great circle through \(x\) and \(y\).
With the target phase-aligned so \(c = \langle x,y\rangle \ge 0\), \(\theta = \arccos c\) is the Fubini–Study distance and \(\hat u = (y - xc)/\lVert y - xc\rVert\) the unit tangent toward it. Since \(\lVert y - xc\rVert = \sin\theta\), the returned \(\theta/\sin\theta\) scale tends to \(1\) as the states coincide, which is the limit taken below.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array
|
The base state, unit |
required |
y
|
Array
|
The end state, unit |
required |
key
|
Array | None
|
Unused; accepted for interface parity. |
None
|
tangent_acceleration(point, v, w)
¤
\(\dot\Omega(0) = W - V\langle x,V\rangle - x(\langle V,V\rangle + \langle x,W\rangle)\).
The product-rule derivative of \(\Omega(t) = \dot c - c\langle c,\dot c\rangle\) along the chart's curve — the projection's own bending, which on a group would instead be \(V^\dagger V + U^\dagger W\).
hessian_quadratic_form(point, a, omega)
¤
\(\lVert\Omega_\parallel\rVert^2 + 2\theta\cot2\theta\,\lVert\Omega_J\rVert^2 + \theta\cot\theta\,\lVert\Omega_\perp\rVert^2\).
\(\mathbb{CP}^{n-1}\) is a symmetric space, so the Riemannian Hessian of \(\tfrac12 d^2\) is \(\sqrt{\mathcal R}\cot\sqrt{\mathcal R}\) with \(\mathcal R\) the curvature operator along the geodesic. Its spectrum is not that of a round sphere. Fubini–Study sectional curvature is \(1\) on most planes but \(4\) on the complex line \(\mathrm{span}(\hat A, i\hat A)\), so the Hessian splits three ways: eigenvalue \(1\) along the radial \(\hat A\), \(2\theta\cot2\theta\) along \(i\hat A\), and \(\theta\cot\theta\) on the rest. Treating \(i\hat A\) like any other perpendicular direction is wrong by up to a factor of several, and gets the sign wrong past \(\theta = \pi/4\), where \(2\theta\cot2\theta\) turns negative while \(\theta\cot\theta\) is still positive.
Returns \(\theta\) as the cut-locus diagnostic. It diverges at
\(\theta = \pi/2\) — the whole diameter of \(\mathbb{CP}^{n-1}\), the
antipode of the projective space rather than of the sphere above it,
and the largest value log's \(\arccos\lvert\langle x,y\rangle\rvert\) can
return.
fidelity(x, y)
¤
\(\lvert\langle x, y\rangle\rvert \in [0, 1]\) — the state fidelity.
infidelity(x, y)
¤
\(1 - \lvert\langle x, y\rangle\rvert \in [0, 1]\).
cost_gradient(x, y)
¤
\(\partial C/\partial\bar x = -z\,y / (2\lvert z\rvert)\), with \(z = \langle y, x\rangle\).
The same trace cost as everywhere else in the library, with \(\kappa = 1\):
the state fidelity is already normalised. See
geope.geometry.cost.trace_cost_gradient.
cost_hessian_form(x, y, u)
¤
The cost's own curvature — the projective pair, with \(\kappa = 1\).
ambient_inner(x, y)
¤
\(\mathrm{Re}\sum \bar x\,y\) over the ambient axes — the metric of \(\mathcal A\).
The default building block for inner, and correct as it stands for any
manifold whose metric is the one induced by the embedding — which
includes a bi-invariant group metric, where it is
\(\mathrm{Re}\,\mathrm{Tr}(x^\dagger y)\), and the round metric on the
state sphere. A manifold whose metric is not the ambient one must say
so: geope.geometry.stiefel.stiefel.Stiefel carries the canonical metric
\(\mathrm{Re}\,\mathrm{Tr}(x^\dagger W_Q y)\) instead, which is what gives
it different geodesics from the embedding's.
bind(*, target, generators, frame=None, columns=None, wrap_chart=None)
¤
Attach this problem's chart, coefficient frame and target.
The seam between the two layers this package is built on, and it holds no
mathematics of its own: geope.geometry.chart builds the ambient jet
\((\Phi,\ \mathrm D\Phi,\ \mathrm D^2\Phi)\) from generators and this
manifold's base_point, and everything else here is assembly.
Returns a new manifold — this one is frozen — so the unbound mathematical object stays reusable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
Array | ndarray | None
|
The point being synthesised, of shape |
required |
generators
|
Basis
|
The chart's generator sub- |
required |
frame
|
Basis | None
|
The ambient coefficient frame |
None
|
columns
|
ndarray | None
|
Boolean mask over the chart's coefficient columns selecting
those the geodesic solve may move. |
None
|
wrap_chart
|
Callable[[Callable], Callable] | None
|
An opaque reparametrisation of the chart's input, or
That it reparametrises the input is what lets it wrap the landed chart rather than the bare propagator: \(\mathrm{wrap}(\Phi)(\phi) = U(\tau(\phi))\,x_0\) either way, so the base point never has to be threaded through it. |
None
|
Returns:
| Type | Description |
|---|---|
Manifold
|
A bound |
Raises:
| Type | Description |
|---|---|
ValueError
|
If this manifold is already bound, or if |
context(free_params, delta_t=1.0)
¤
Open a GeometricContext at the pulse free_params.
Cheap: every quantity on the returned context is lazy, so this on its own
evaluates nothing. Build one per optimisation step, inside the jitted
update — see GeometricContext for why it must not leave that trace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
free_params
|
Array
|
The pulse, shape |
required |
delta_t
|
Array | float
|
The segment duration, threaded (as a traced scalar) into every chart evaluation the context performs. Defaults to 1.0. |
1.0
|
distance2(x, y, key=None)
¤
Half the squared geodesic distance, \(\tfrac12 d_g(x, y)^2\).
The objective the first- and second-order line searches minimise, and the
quantity whose derivatives a GeometricContext reports. Costs one log.
norm2(point, x)
¤
\(\lVert x\rVert^2_{\text{point}}\).