Quantum Channels API
Quantum Channels
- class graphcalc.quantum.channels.QuantumChannel(choi: Sequence[Sequence[complex]] | ndarray, *, input_dim: int, output_dim: int, validate: bool = True, tol: float = 1e-09)[source]
Bases:
objectFinite-dimensional quantum channel represented by its Choi operator.
The channel is stored as a triple
(J, input_dim, output_dim)whereJis the Choi matrix of shape(input_dim * output_dim, input_dim * output_dim).Conventions
the Choi matrix is defined by
J(Phi) = sum_{i,j} |i><j| \otimes Phi(|i><j|)the input subsystem appears first and the output subsystem second
complete positivity is equivalent to positive semidefiniteness of
Jtrace preservation is equivalent to the partial trace over the output subsystem equaling the identity on the input space
unitality is equivalent to the partial trace over the input subsystem equaling the identity on the output space
- param choi:
Choi matrix of the channel.
- type choi:
array-like
- param input_dim:
Input Hilbert-space dimension.
- type input_dim:
int
- param output_dim:
Output Hilbert-space dimension.
- type output_dim:
int
- param validate:
Whether to validate the input as a completely positive trace-preserving map.
- type validate:
bool, default=True
- param tol:
Numerical tolerance used in validation.
- type tol:
float, default=1e-9
Notes
The internal Choi matrix is stored privately as
_choi. Public access is provided through a read-only property that returns a copy.- apply(state: QuantumState) QuantumState[source]
Apply the channel to a quantum state.
- Parameters:
state (QuantumState) – Input state. Its total dimension must equal
input_dim.- Returns:
Output state on a single subsystem of dimension
output_dim.- Return type:
Notes
The action is computed from a Kraus decomposition:
Phi(rho) = sum_a K_a rho K_a^dagger.
- property choi: ndarray
Return a copy of the Choi matrix.
- property choi_rank: int
Return the rank of the Choi matrix.
- compose(other: QuantumChannel) QuantumChannel[source]
Return the composition
self ∘ other.- Parameters:
other (QuantumChannel) – Channel applied first.
Notes
If
other : A -> Bandself : B -> C, then the result is a channelA -> Cdefined byrho |-> self(other(rho)).
- copy() QuantumChannel[source]
Return a copy of the channel.
- property dimension: int
Return the dimension of the Choi matrix.
- classmethod from_choi(choi: Sequence[Sequence[complex]] | ndarray, *, input_dim: int, output_dim: int, validate: bool = True, tol: float = 1e-09) QuantumChannel[source]
Construct a quantum channel from a Choi matrix.
- classmethod from_kraus(operators: Iterable[Sequence[Sequence[complex]] | ndarray], *, input_dim: int | None = None, output_dim: int | None = None, validate: bool = True, tol: float = 1e-09) QuantumChannel[source]
Construct a quantum channel from Kraus operators.
- Parameters:
operators (iterable of array-like) – Kraus operators
K_aof shape(output_dim, input_dim).input_dim (int | None, default=None) – Optional input dimension. If omitted, inferred from the operators.
output_dim (int | None, default=None) – Optional output dimension. If omitted, inferred from the operators.
validate (bool, default=True) – Whether to validate the resulting channel as CPTP.
tol (float, default=1e-9) – Numerical tolerance used in validation.
- classmethod identity(dim: int, *, tol: float = 1e-09) QuantumChannel[source]
Return the identity channel on a
dim-dimensional system.
- is_completely_positive() bool[source]
Return whether the channel is completely positive.
Notes
With the Choi representation, complete positivity is equivalent to positive semidefiniteness of the Choi matrix.
- is_trace_preserving() bool[source]
Return whether the channel is trace preserving.
Notes
For the adopted Choi convention, trace preservation is equivalent to
Tr_output(J) = I_input.
- is_unital() bool[source]
Return whether the channel is unital.
Notes
For the adopted Choi convention, unitality is equivalent to
Tr_input(J) = I_output.
- kraus_operators() list[ndarray][source]
Return a Kraus representation of the channel.
Notes
If
J = sum_a |K_a><K_a|is a spectral decomposition of the Choi matrix, then the Kraus operators are obtained by reshaping the eigenvectors into matrices using column-major order.
- tensor(other: QuantumChannel) QuantumChannel[source]
Return the tensor product channel
self ⊗ other.