mimiqcircuits.operations.entanglement

Entanglement measures (BondDim, VonNeumannEntropy, etc.).

Classes

BondDim()

Record the MPS bond dimension at a cut of the system in a z-variable.

SchmidtRank()

Record the Schmidt rank of a bipartition in a z-variable.

VonNeumannEntropy()

Record the bipartite von Neumann entanglement entropy in a z-variable.

class BondDim[source]

Bases: Operation

Record the MPS bond dimension at a cut of the system in a z-variable.

The bond dimension is only defined for a matrix-product state (MPS), so it is only meaningful with the MPS simulator. An MPS can be written as

\[|\psi \rangle = \sum_{s_1,s_2,\ldots=1}^2 \sum_{i_1}^{\chi_1} \sum_{i_2}^{\chi_2} \ldots \sum_{i_N}^{\chi_N} A^{(s_1)}_{i_0i_1} A^{(s_2)}_{i_1 i_2} A^{(s_3)}_{i_2 i_3} \ldots A^{(s_N)}_{i_{N-1}i_N} | s_1, s_2, s_3, \ldots, s_N \rangle .\]

where \(\chi_k\) is the bond dimension, the dimension of the index \(i_k\). The first and last bond dimensions are dummies, \(\chi_0=\chi_N=1\). A bond dimension of 1 means there is no entanglement between the two sides of the cut.

The instruction takes one qubit k and one z-variable. It records the dimension of the bond between qubits k - 1 and k, that is between qubits 0, ..., k - 1 and k, ..., N - 1. For k = 0 the result is always 1. The quantum state is not changed.

Examples

>>> from mimiqcircuits import *
>>> # bond dimension between qubits 4 and 5, stored in z-variable 1
>>> k = 5
>>> c = Circuit()
>>> c.push(BondDim(), k, 1)
6-qubit, 2-zvar circuit with 1 instruction:
└── BondDim @ q[5], z[1]
property num_qubits

Number of qubits the operation acts on.

Read-only: assigning to it raises ValueError.

property parnames

Names of the operation’s parameters, as a tuple of strings.

Read-only: assigning to it raises ValueError.

iswrapper()[source]

Whether the operation wraps another operation.

True for composite operations such as Control, Power, Inverse, Parallel or IfStatement, False otherwise.

Returns:

bool

inverse()[source]

Return a new BondDim: it does not change the state.

power(p)[source]

Not supported.

Raises:

TypeError – Always.

control(num_qubits)[source]

Not supported.

Raises:

TypeError – Always.

static isunitary()[source]

Whether the operation acts unitarily on the quantum state.

Returns:

True for gates, annotations, Barrier, and the operations that only read the state into a z-variable, such as ExpectationValue or Amplitude. False for everything else: measurements, resets, noise channels, classical operations, and containers such as Block or IfStatement.

Return type:

bool

class VonNeumannEntropy[source]

Bases: Operation

Record the bipartite von Neumann entanglement entropy in a z-variable.

For a pure state \(\rho = | \psi \rangle\langle \psi |\) split into subsystems \(A\) and \(B\), the entanglement entropy is

\[\mathcal{S}(\rho_A) = - \mathrm{Tr}(\rho_A \log_2 \rho_A) = - \mathrm{Tr}(\rho_B \log_2 \rho_B) = \mathcal{S}(\rho_B),\]

where \(\rho_A = \mathrm{Tr}_B(\rho)\) is the reduced density matrix. A product state has \(\mathcal{S}(\rho_A)=0\) and a maximally entangled pair of qubits gives \(\mathcal{S}(\rho_A)=1\).

The instruction takes one qubit k and one z-variable. The bipartition is \(A = \{0, \ldots, k-1\}\) and \(B = \{k, \ldots, N-1\}\), where \(N\) is the number of qubits. For k = 0, \(A\) is empty and the result is always 0. The quantum state is not changed.

With noise and quantum trajectories, the entropy of the pure state of each trajectory is recorded.

See also

BondDim, SchmidtRank

Examples

>>> from mimiqcircuits import *
>>> # entropy between qubits 0-4 and qubits 5 onwards, in z-variable 1
>>> k = 5
>>> c = Circuit()
>>> c.push(VonNeumannEntropy(), k, 1)
6-qubit, 2-zvar circuit with 1 instruction:
└── VonNeumannEntropy @ q[5], z[1]
property num_qubits

Number of qubits the operation acts on.

Read-only: assigning to it raises ValueError.

property parnames

Names of the operation’s parameters, as a tuple of strings.

Read-only: assigning to it raises ValueError.

iswrapper()[source]

Whether the operation wraps another operation.

True for composite operations such as Control, Power, Inverse, Parallel or IfStatement, False otherwise.

Returns:

bool

inverse()[source]

Return a new VonNeumannEntropy: it does not change the state.

power(p)[source]

Not supported.

Raises:

TypeError – Always.

control(num_qubits)[source]

Not supported.

Raises:

TypeError – Always.

static isunitary()[source]

Whether the operation acts unitarily on the quantum state.

Returns:

True for gates, annotations, Barrier, and the operations that only read the state into a z-variable, such as ExpectationValue or Amplitude. False for everything else: measurements, resets, noise channels, classical operations, and containers such as Block or IfStatement.

Return type:

bool

class SchmidtRank[source]

Bases: Operation

Record the Schmidt rank of a bipartition in a z-variable.

The Schmidt decomposition of a pure state split into subsystems \(A\) and \(B\) is

\[|\psi\rangle = \sum_{i=1}^{r} s_i |\alpha_i\rangle \otimes |\beta_i\rangle,\]

where \(|\alpha_i\rangle\) (\(|\beta_i\rangle\)) are orthonormal states of \(A\) (\(B\)). The Schmidt rank is the number of terms \(r\). A product state gives \(r=1\), and \(r>1\) signals entanglement.

The instruction takes one qubit k and one z-variable. The bipartition is \(A = \{0, \ldots, k-1\}\) and \(B = \{k, \ldots, N-1\}\), where \(N\) is the number of qubits. For k = 0, \(A\) is empty and the result is always 1. The quantum state is not changed.

For a matrix-product state that is optimally compressed, the Schmidt rank equals the bond dimension (see BondDim).

Examples

>>> from mimiqcircuits import *
>>> # Schmidt rank between qubits 0-4 and qubits 5 onwards, in z-variable 1
>>> k = 5
>>> c = Circuit()
>>> c.push(SchmidtRank(), k, 1)
6-qubit, 2-zvar circuit with 1 instruction:
└── SchmidtRank @ q[5], z[1]
property num_qubits

Number of qubits the operation acts on.

Read-only: assigning to it raises ValueError.

property parnames

Names of the operation’s parameters, as a tuple of strings.

Read-only: assigning to it raises ValueError.

iswrapper()[source]

Whether the operation wraps another operation.

True for composite operations such as Control, Power, Inverse, Parallel or IfStatement, False otherwise.

Returns:

bool

inverse()[source]

Return a new SchmidtRank: it does not change the state.

power(p)[source]

Not supported.

Raises:

TypeError – Always.

control(num_qubits)[source]

Not supported.

Raises:

TypeError – Always.

static isunitary()[source]

Whether the operation acts unitarily on the quantum state.

Returns:

True for gates, annotations, Barrier, and the operations that only read the state into a z-variable, such as ExpectationValue or Amplitude. False for everything else: measurements, resets, noise channels, classical operations, and containers such as Block or IfStatement.

Return type:

bool