Base¶
AbstractOp
¶
Bases: Module
An abstract base class for all quantum objects, including states, gates, channels, and measurements. It provides a common interface for various quantum objects, ensuring consistency and reusability across different types of quantum operations.
Attributes:
Name | Type | Description |
---|---|---|
wires |
tuple[int, ...]
|
A tuple of nonnegative integers representing the quantum wires on which the operation acts. Each wire corresponds to a specific subsystem in the composite quantum system. |
Source code in src/squint/ops/base.py
__init__(wires: Sequence[WiresTypes])
¶
Initializes the AbstractOp instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wires
|
tuple[int, ...]
|
A tuple of nonnegative integers representing the quantum wires on which the operation acts. Defaults to (0, 1). |
required |
Raises:
Type | Description |
---|---|
TypeError
|
If any wire in the provided tuple is not a nonnegative integer. |
Source code in src/squint/ops/base.py
unwrap()
¶
A base method for unwrapping an operator into constituent parts, important in, e.g., shared weights across operators.
This method can be overridden by subclasses to provide additional unwrapping functionality, such as decomposing composite operations into their components.
Returns:
Name | Type | Description |
---|---|---|
ops |
tuple[AbstractOp]
|
A tuple of AbstractOp which represent the constituent ops. |
Source code in src/squint/ops/base.py
AbstractState
¶
Bases: AbstractOp
An abstract base class for all quantum states.
Source code in src/squint/ops/base.py
AbstractPureState
¶
Bases: AbstractState
An abstract base class for all pure quantum states, equivalent to the state vector formalism.
Pure states are associated with a Hilbert space of size,
\(\ket{\rho} \in \mathcal{H}^{d_1 \times \dots \times d_w}\)
and \(w=\) len(wires)
and \(d\) is assigned at compile time.
Source code in src/squint/ops/base.py
AbstractMixedState
¶
Bases: AbstractState
An abstract base class for all mixed quantum states, equivalent to the density matrix formalism.
Mixed states are associated with a Hilbert space of size,
\(\rho \in \mathcal{H}^{d_1 \times \dots \times d_w \times d_1 \times \dots \times d_w}\)
and \(w=\) len(wires)
and \(d\) is assigned at compile time.
Source code in src/squint/ops/base.py
AbstractGate
¶
Bases: AbstractOp
An abstract base class for all unitary quantum gates, which transform an input state in a reversible way.
$ U \in \mathcal{H}^{d_1 \times \dots \times d_w \times d_1 \times \dots \times d_w}$
and \(w=\) len(wires)
and \(d\) is assigned at compile time.
Source code in src/squint/ops/base.py
AbstractChannel
¶
Bases: AbstractOp
An abstract base class for quantum channels, including channels expressed as Kraus operators, erasure (partial trace), and others.
Source code in src/squint/ops/base.py
AbstractMeasurement
¶
Bases: AbstractOp
An abstract base class for quantum measurements. Currently, this is not supported, and measurements are projective measurements in the computational basis.
Source code in src/squint/ops/base.py
SharedGate
¶
Bases: AbstractGate
A class representing a shared quantum gate, which allows for the sharing of parameters or attributes across multiple copies of a quantum operation. This is useful for scenarios where multiple gates share the same underlying structure or parameters, such as in variational quantum circuits. This is most commonly used when applying the same parameterized gate across different wires, e.g., phase gates, for studying phase estimation protocols.
Attributes:
Name | Type | Description |
---|---|---|
op |
AbstractOp
|
The base quantum operation that is shared across multiple copies. |
copies |
Sequence[AbstractOp]
|
A sequence of copies of the base operation, each acting on different wires. |
where |
Callable
|
A function that determines which attributes of the operation are shared across copies. |
get |
Callable
|
A function that retrieves the shared attributes from the base operation. |
Source code in src/squint/ops/base.py
unwrap()
¶
Unwraps the shared ops for compilation and contractions.
AbstractKrausChannel
¶
Bases: AbstractChannel
An abstract base class for quantum channels expressed as Kraus operators.
The channel \(K\) is of shape \((d_1 \times \dots \times d_w \times d_1 \times \dots \times d_w)\)
and \(w=\) len(wires)
and \(d\) is assigned at compile time.
Source code in src/squint/ops/base.py
AbstractErasureChannel
¶
Bases: AbstractChannel
This channel traces out the local Hilbert space associated with the wires
Source code in src/squint/ops/base.py
Block
¶
Bases: Module
A block operation that represents a sequence of operations.
Source code in src/squint/ops/base.py
add(op: AbstractOp, key: str = None) -> None
¶
Add an operator to the block. Operators are added sequential along the wires.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
op
|
AbstractOp
|
The operator instance to add to the circuit. |
required |
key
|
Optional[str]
|
A string key for indexing into the circuit PyTree instance. Defaults to |
None
|
Source code in src/squint/ops/base.py
unwrap() -> tuple[AbstractOp]
¶
Unwrap all operators in the circuit by recursively calling the op.unwrap()
method.
create(dim)
cached
¶
Returns the create operator for a Hilbert space of dimension dim
.
The create operator is a matrix that adds one excitation to a quantum system,
effectively increasing the energy level by one.
Args:
dim (int): The dimension of the Hilbert space.
Returns:
jnp.ndarray: A 2D array of shape (dim, dim) representing the create operator.
Source code in src/squint/ops/base.py
destroy(dim)
cached
¶
Returns the destroy operator for a Hilbert space of dimension dim
.
The destroy operator is a matrix that annihilates one excitation of a quantum system,
effectively reducing the energy level by one.
Args:
dim (int): The dimension of the Hilbert space.
Returns:
jnp.ndarray: A 2D array of shape (dim, dim) representing the destroy operator.
Source code in src/squint/ops/base.py
eye(dim)
cached
¶
Returns the identity operator for a Hilbert space of dimension dim
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dim
|
int
|
The dimension of the Hilbert space. |
required |
Returns: jnp.ndarray: A 2D array of shape (dim, dim) representing the identity operator.
Source code in src/squint/ops/base.py
bases(dim)
cached
¶
Returns the computational basis indices for a Hilbert space of dimension dim
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dim
|
int
|
The dimension of the Hilbert space. |
required |
Returns:
Type | Description |
---|---|
jnp.ndarray: A 1D array of shape (dim,) containing the indices of the computational bases. |
Source code in src/squint/ops/base.py
dft(dim)
cached
¶
Returns the discrete Fourier transform matrix of dimension dim
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dim
|
int
|
The dimension of the DFT matrix. |
required |
Returns:
Type | Description |
---|---|
jnp.ndarray: A 2D array of shape (dim, dim) representing the DFT matrix. |
Source code in src/squint/ops/base.py
basis_operators(dim)
cached
¶
Return a basis of orthogonal Hermitian operators on a Hilbert space of dimension \(d\), with the identity element in the last place. i.e., the Gell-Mann operators (for dim=2, these are the four Pauli operators).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dim
|
int
|
The dimension of the Hilbert space. |
required |
Returns:
Type | Description |
---|---|
jnp.ndarray: A 3D array of shape (n_operators, dim, dim) containing the basis operators. |