geope.geometry.basis¤
The frame the pulse model is built on, and the projector that resolves against
it. Despite the Pauli-algebra flavour this is not Lie-specific — it is the
ambient coefficient frame, which both Stiefel manifolds take too — so it lives
at the root of geope.geometry rather than under lie. The group manifolds
live on the Manifolds page.
geope.geometry.basis.Basis
¤
A frame for the ambient matrix space, and the pulse's generators.
Wraps a rank-3 tensor of Hermitian basis matrices together with associated labels, interaction metadata, and convenience utilities for building and manipulating Lie-algebraic decompositions.
Two roles, one class. A Basis is a real-orthogonal frame for the
Hermitian matrices in the ambient space \(\mathbb C^{d\times d}\) — the Paulis
span that space over \(\mathbb C\), the Hermitian matrices in it over
\(\mathbb R\), and, multiplied by basis_convention, the algebra
\(\mathfrak u(d)\) over \(\mathbb R\). The pipeline uses that in two different
places and at two different sizes:
- as the chart's generators —
params.proj_drift_basis, whosealgebraarray the pulse is a product of exponentials in (geope.geometry.chart); - as the ambient coefficient frame —
params.basis, whatgeope.geometry.manifold.Manifold.coefficientsresolves a tangent vector against, stored ongeope.geometry.TangentBundle.frame— seegeope.geometry.lie.groups.MatrixLieGroup.coefficients, the inverse direction of the same dictionary.
Completeness is not required in either role: an incomplete frame simply projects onto a subspace, which the spin-boson bases rely on. Nor is a manifold obliged to coordinatise through a frame at all — both Stiefel manifolds use a real/imaginary split of the ambient array instead.
Attributes:
| Name | Type | Description |
|---|---|---|
basis_convention |
The sign convention relating the Hermitian frame
to the algebra generators — one of |
|
algebra |
The skew-Hermitian generator array \(E_k = \mathrm{basis\_convention}\cdot B_k\) this frame induces. |
|
basis |
Array of shape |
|
labels |
List of Pauli-string labels, e.g. |
|
plot_labels |
LaTeX-formatted labels for plotting. |
|
interaction_labels |
Compact lower-case interaction labels. |
|
interaction_qubits |
Tuple of qubit indices involved in each basis element. |
|
interaction_graph |
List of qubit-pair tuples representing interactions. |
|
interaction_map |
Dictionary mapping qubit tuples to interaction labels. |
|
n |
Number of qubits (\(\\log_2 d\)). |
|
local_dim |
Local Hilbert-space dimension (default 2). |
|
dim |
Total Hilbert-space dimension \(d\). |
|
lie_algebra_dim |
Number of basis elements \(K\). |
|
shape |
Shape of the underlying basis tensor |
__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)
__dict__
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'.
__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'.
__weakref__
property
¤
list of weak references to the object
algebra
property
¤
The algebra generators this frame induces: \(E_k = \mathrm{basis\_convention}\cdot B_k\).
basis
property
¤
The rank-3 array of basis matrices.
basis_convention
class-attribute
¤
Create a complex number from a real part and an optional imaginary part.
This is equivalent to (real + imag*1j) where imag defaults to 0.
dim
property
¤
Total Hilbert-space dimension.
interaction_graph
property
¤
List of qubit-pair tuples representing interactions.
interaction_labels
property
¤
Compact lower-case interaction labels.
interaction_map
property
¤
Dictionary mapping qubit tuples to interaction labels.
interaction_qubits
property
¤
Tuple of qubit indices for each basis element.
labels
property
¤
String labels for each basis element, or None.
lie_algebra_dim
property
¤
Number of basis elements.
local_dim
property
¤
Local Hilbert-space dimension.
n
property
¤
Number of qubits.
plot_labels
property
¤
LaTeX-formatted labels for plotting.
shape
property
¤
Shape of the basis tensor (K, d, d).
__init__(basis, labels=None, local_dim=2, n_qubits=None, interaction_graph=None, interaction_map=None)
¤
Initialise a Basis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
basis
|
ndarray
|
Rank-3 |
required |
labels
|
list[str] | None
|
Optional list of string labels for each basis element.
Defaults to |
None
|
local_dim
|
int
|
Local Hilbert-space dimension. Defaults to 2. |
2
|
n_qubits
|
int | None
|
Optional override for the number of qubits. Useful
when the Hilbert-space dimension is not \(2^n\) (e.g. a
direct sum of single-qubit blocks). When |
None
|
interaction_graph
|
list[tuple[int, ...]] | None
|
Optional list of qubit-index tuples restricting which interactions to keep. |
None
|
interaction_map
|
dict[tuple[int, ...], list[str]] | None
|
Optional dictionary mapping qubit tuples to lists of interaction labels to keep. |
None
|
linear_span(parameters)
¤
Compute the linear combination of basis matrices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
ndarray
|
Coefficient |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
A |
overlap(other)
¤
Compute the overlap mask between this basis and another.
Uses trace inner products to determine which elements of
other have non-zero overlap with elements of this basis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Basis
|
Another |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
A boolean |
ndarray
|
that is |
verify()
¤
Verify that the basis elements are orthogonal under the trace inner product.
Returns:
| Type | Description |
|---|---|
bool
|
|
bool
|
|
apply_interaction_graph(interaction_graph)
¤
Apply an interaction graph to the basis.
Removes any multi-body basis elements whose qubit indices are not present in the supplied interaction graph. Single-body terms are always retained.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
interaction_graph
|
list[tuple[int, ...]]
|
A list of tuples or lists, each containing
the qubit indices of an allowed interaction
(e.g. |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[int, ...]]
|
The applied interaction graph as a list of tuples. |
apply_interaction_map(interaction_map)
¤
Apply an interaction map to the basis.
Removes basis elements whose qubit-index tuple is not a key in the map, or whose interaction label is not in the corresponding value list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
interaction_map
|
dict[tuple[int, ...], list[str]]
|
Dictionary mapping qubit-index tuples to lists of allowed interaction label strings. |
required |
Returns:
| Type | Description |
|---|---|
dict[tuple[int, ...], list[str]]
|
The applied interaction map dictionary. |
__len__()
¤
Return the number of basis elements.
generate_parameter_list(parameter_map)
¤
Generate a parameter vector from a human-readable parameter map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameter_map
|
dict[int | tuple[int, ...], dict[str, float]]
|
Dictionary whose keys are qubit indices (int) or qubit-index tuples, and whose values are dictionaries mapping interaction labels to parameter values. |
required |
Returns:
| Type | Description |
|---|---|
list[float]
|
A list of parameter values aligned with the basis ordering. |
generate_bounds(bounds_map, piecewise_steps)
¤
Generate lower and upper parameter bounds from a bounds map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bounds_map
|
dict[str, tuple[float, float]]
|
Dictionary whose keys are interaction label strings
and whose values are |
required |
piecewise_steps
|
int
|
Number of piecewise gate segments. |
required |
Returns:
| Type | Description |
|---|---|
list[list[float]]
|
A tuple |
list[list[float]]
|
nested list of shape |
The coefficient projector¤
Resolving a batch of ambient matrices against the frame,
\(c_i = \mathrm{Re}\,\mathrm{Tr}(G_i X)/d\). Above 5 qubits the on-the-fly projector
get_project_omegas_fn_otf builds the Pauli strings on the fly to avoid
materialising the full \((K, d, d)\) frame.
geope.geometry.basis.project_omegas(x, basis, dim)
¤
Project a batch of matrices onto a Lie algebra basis.
Computes the trace inner product of each matrix in x with
each basis element, normalised by the Hilbert-space dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Array
|
|
required |
basis
|
Array
|
Basis tensor |
required |
dim
|
int
|
Hilbert-space dimension \(d\). |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Real |
geope.geometry.basis.get_project_omegas_fn(basis)
¤
Create a partial projection function with a fixed basis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
basis
|
Basis
|
A |
required |
Returns:
| Type | Description |
|---|---|
Callable[[Array], Array]
|
A |
Callable[[Array], Array]
|
matrices and returns the projected coefficients. |
geope.geometry.basis.get_kron_chain(n)
¤
Build a JIT-compiled Kronecker product chain function.
Constructs the four single-qubit Pauli matrices and returns a function that builds an \(n\)-qubit Pauli string via iterated Kronecker products.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of qubits. |
required |
Returns:
| Type | Description |
|---|---|
Callable[[Array], Array]
|
A JIT-compiled |
Callable[[Array], Array]
|
combination index array of length |
Callable[[Array], Array]
|
returns the corresponding |
geope.geometry.basis.get_project_omegas_fn_otf(basis, batch_size=None)
¤
Create an on-the-fly omega projection function.
Instead of storing the full basis in memory, Pauli strings are constructed on the fly via Kronecker products. Useful when the number of qubits exceeds 5.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
basis
|
Basis
|
A |
required |
batch_size
|
int | None
|
Optional number of batches to split the
Pauli combinations into. If |
None
|
Returns:
| Type | Description |
|---|---|
Callable[[Array], Array]
|
A vmapped |
Callable[[Array], Array]
|
of matrices and returns projected coefficients. |