quairkit.database.representation

Representations of channels

quairkit.database.representation.bit_flip_kraus(prob)

Kraus representation of a bit flip channel with form

\[E_0 = \sqrt{1-p} I, E_1 = \sqrt{p} X.\]
Parameters:
prob : ndarray | Tensor | Iterable[float] | float

probability \(p\).

dtype

data type. Defaults to be None.

Returns:

a list of Kraus operators

Return type:

List[ndarray | Tensor]

prob = torch.tensor([0.5])
kraus_operators = bit_flip_kraus(prob)
print(f'The Kraus operators are:\n{kraus_operators}')
The Kraus operators are:
tensor([[[0.7071+0.j, 0.0000+0.j],
        [0.0000+0.j, 0.7071+0.j]],

        [[0.0000+0.j, 0.7071+0.j],
        [0.7071+0.j, 0.0000+0.j]]], dtype=torch.complex128)
quairkit.database.representation.phase_flip_kraus(prob)

Kraus representation of a phase flip channel with form

\[E_0 = \sqrt{1 - p} I, E_1 = \sqrt{p} Z.\]
Parameters:
prob : ndarray | Tensor | Iterable[float] | float

probability \(p\).

dtype

data type. Defaults to be None.

Returns:

a list of Kraus operators

Return type:

List[ndarray | Tensor]

prob = torch.tensor([0.1])
kraus_operators = phase_flip_kraus(prob)
print(f'The Kraus operators are:\n{kraus_operators}')
The Kraus operators are:
tensor([[[ 0.9487+0.j,  0.0000+0.j],
        [ 0.0000+0.j,  0.9487+0.j]],

        [[ 0.3162+0.j,  0.0000+0.j],
        [ 0.0000+0.j, -0.3162+0.j]]], dtype=torch.complex128)
quairkit.database.representation.bit_phase_flip_kraus(prob)

Kraus representation of a bit-phase flip channel with form

\[E_0 = \sqrt{1 - p} I, E_1 = \sqrt{p} Y.\]
Parameters:
prob : ndarray | Tensor | Iterable[float] | float

probability \(p\).

dtype

data type. Defaults to be None.

Returns:

a list of Kraus operators

Return type:

List[ndarray | Tensor]

prob = torch.tensor([0.1])
kraus_operators = bit_phase_flip_kraus(prob)
print(f'The Kraus operators are:\n{kraus_operators}')
The Kraus operators are:
tensor([[[0.9487+0.0000j, 0.0000+0.0000j],
        [0.0000+0.0000j, 0.9487+0.0000j]],

        [[0.0000+0.0000j, 0.0000-0.3162j],
        [0.0000+0.3162j, 0.0000+0.0000j]]], dtype=torch.complex128)
quairkit.database.representation.amplitude_damping_kraus(gamma)

Kraus representation of an amplitude damping channel with form

\[\begin{split}E_0 = \begin{bmatrix} 1 & 0 \\ 0 & \sqrt{1-\gamma} \end{bmatrix}, E_1 = \begin{bmatrix} 0 & \sqrt{\gamma} \\ 0 & 0 \end{bmatrix}.\end{split}\]
Parameters:
gamma : ndarray | Tensor | Iterable[float] | float

coefficient \(\gamma\).

dtype

data type. Defaults to be None.

Returns:

a list of Kraus operators

Return type:

List[ndarray | Tensor]

gamma = torch.tensor(0.2)
kraus_operators = amplitude_damping_kraus(gamma)
print(f'The Kraus operators are:\n{kraus_operators}')
The Kraus operators are:
tensor([[[1.0000+0.j, 0.0000+0.j],
        [0.0000+0.j, 0.8944+0.j]],

        [[0.0000+0.j, 0.4472+0.j],
        [0.0000+0.j, 0.0000+0.j]]], dtype=torch.complex128)
quairkit.database.representation.generalized_amplitude_damping_kraus(gamma, prob)

Kraus representation of a generalized amplitude damping channel with form

\[\begin{split}E_0 = \sqrt{p} \begin{bmatrix} 1 & 0 \\ 0 & \sqrt{1-\gamma} \end{bmatrix}, E_1 = \sqrt{p} \begin{bmatrix} 0 & \sqrt{\gamma} \\ 0 & 0 \end{bmatrix},\\ E_2 = \sqrt{1-p} \begin{bmatrix} \sqrt{1-\gamma} & 0 \\ 0 & 1 \end{bmatrix}, E_3 = \sqrt{1-p} \begin{bmatrix} 0 & 0 \\ \sqrt{\gamma} & 0 \end{bmatrix}.\end{split}\]
Parameters:
gamma : ndarray | Tensor | Iterable[float] | float

coefficient \(\gamma\).

prob : ndarray | Tensor | Iterable[float] | float

probability \(p\).

dtype

data type. Defaults to be None.

Returns:

a list of Kraus operators

Return type:

List[ndarray | Tensor]

gamma = torch.tensor(0.2)
prob = torch.tensor(0.1)
kraus_operators = generalized_amplitude_damping_kraus(gamma,prob)
print(f'The Kraus operators are:\n{kraus_operators}')
The Kraus operators are:
tensor([[[0.3162+0.j, 0.0000+0.j],
        [0.0000+0.j, 0.2828+0.j]],

        [[0.0000+0.j, 0.1414+0.j],
        [0.0000+0.j, 0.0000+0.j]],

        [[0.8485+0.j, 0.0000+0.j],
        [0.0000+0.j, 0.9487+0.j]],

        [[0.0000+0.j, 0.0000+0.j],
        [0.4243+0.j, 0.0000+0.j]]], dtype=torch.complex128)
quairkit.database.representation.phase_damping_kraus(gamma)

Kraus representation of a phase damping channel with form

\[\begin{split}E_0 = \begin{bmatrix} 1 & 0 \\ 0 & \sqrt{1-\gamma} \end{bmatrix}, E_1 = \begin{bmatrix} 0 & 0 \\ 0 & \sqrt{\gamma} \end{bmatrix}.\end{split}\]
Parameters:
gamma : ndarray | Tensor | Iterable[float] | float

coefficient \(\gamma\).

dtype

data type. Defaults to be None.

Returns:

a list of Kraus operators

Return type:

List[ndarray | Tensor]

gamma = torch.tensor(0.2)
kraus_operators = phase_damping_kraus(gamma)
print(f'The Kraus operators are:\n{kraus_operators}')
The Kraus operators are:
tensor([[[1.0000+0.j, 0.0000+0.j],
        [0.0000+0.j, 0.8944+0.j]],

        [[0.0000+0.j, 0.0000+0.j],
        [0.0000+0.j, 0.4472+0.j]]], dtype=torch.complex128)
quairkit.database.representation.depolarizing_kraus(prob)

Kraus representation of a depolarizing channel with form

\[E_0 = \sqrt{1-3p/4} I, E_1 = \sqrt{p/4} X, E_2 = \sqrt{p/4} Y, E_3 = \sqrt{p/4} Z.\]
Parameters:
prob : ndarray | Tensor | Iterable[float] | float

probability \(p\).

dtype

data type. Defaults to be None.

Returns:

a list of Kraus operators

Return type:

List[ndarray | Tensor]

prob = torch.tensor(0.1)
kraus_operators = depolarizing_kraus(prob)
print(f'The Kraus operators are:\n{kraus_operators}')
The Kraus operators are:
tensor([[[ 0.9618+0.0000j,  0.0000+0.0000j],
        [ 0.0000+0.0000j,  0.9618+0.0000j]],

        [[ 0.0000+0.0000j,  0.1581+0.0000j],
        [ 0.1581+0.0000j,  0.0000+0.0000j]],

        [[ 0.0000+0.0000j,  0.0000-0.1581j],
        [ 0.0000+0.1581j,  0.0000+0.0000j]],

        [[ 0.1581+0.0000j,  0.0000+0.0000j],
        [ 0.0000+0.0000j, -0.1581+0.0000j]]], dtype=torch.complex128)
quairkit.database.representation.generalized_depolarizing_kraus(prob, num_qubits, dtype=torch.complex128)

Kraus representation of a generalized depolarizing channel with form

\[E_0 = \sqrt{1-(D - 1)p/D} I, \text{ where } D = 4^n, E_k = \sqrt{p/D} \sigma_k, \text{ for } 0 < k < D.\]
Parameters:
prob : ndarray | Tensor | Iterable[float] | float

probability \(p\).

num_qubits : int

number of qubits \(n\) of this channel.

dtype : dtype

data type. Defaults to be None.

Returns:

a list of Kraus operators

Return type:

List[ndarray | Tensor]

prob = torch.tensor(0.1)
num_qubits=1
kraus_operators = generalized_depolarizing_kraus(prob,num_qubits)
print(f'The Kraus operators are:\n{kraus_operators}')
The Kraus operators are:
tensor([[[ 1.3601+0.0000j,  0.0000+0.0000j],
        [ 0.0000+0.0000j,  1.3601+0.0000j]],

        [[ 0.0000+0.0000j,  0.2236+0.0000j],
        [ 0.2236+0.0000j,  0.0000+0.0000j]],

        [[ 0.0000+0.0000j,  0.0000-0.2236j],
        [ 0.0000+0.2236j,  0.0000+0.0000j]],

        [[ 0.2236+0.0000j,  0.0000+0.0000j],
        [ 0.0000+0.0000j, -0.2236+0.0000j]]])
quairkit.database.representation.pauli_kraus(prob)

Kraus representation of a pauli channel

Parameters:
prob : ndarray | Tensor | Iterable[float] | float

a list of three probabilities corresponding to X, Y, Z gate \(p\).

dtype

data type. Defaults to be None.

Returns:

a list of Kraus operators

Return type:

List[ndarray | Tensor]

prob_list = torch.tensor([0.1, 0.2, 0.3])
kraus_operators = pauli_kraus(prob_list)
print(f'The Kraus operators are:\n{kraus_operators}')
The Kraus operators are:
tensor([[[ 0.6325+0.0000j,  0.0000+0.0000j],
        [ 0.0000+0.0000j,  0.6325+0.0000j]],

        [[ 0.0000+0.0000j,  0.3162+0.0000j],
        [ 0.3162+0.0000j,  0.0000+0.0000j]],

        [[ 0.0000+0.0000j,  0.0000-0.4472j],
        [ 0.0000+0.4472j,  0.0000+0.0000j]],

        [[ 0.5477+0.0000j,  0.0000+0.0000j],
        [ 0.0000+0.0000j, -0.5477+0.0000j]]], dtype=torch.complex128)
quairkit.database.representation.reset_kraus(prob)

Kraus representation of a reset channel with form

\[\begin{split}E_0 = \begin{bmatrix} \sqrt{p} & 0 \\ 0 & 0 \end{bmatrix}, E_1 = \begin{bmatrix} 0 & \sqrt{p} \\ 0 & 0 \end{bmatrix},\\ E_2 = \begin{bmatrix} 0 & 0 \\ \sqrt{q} & 0 \end{bmatrix}, E_3 = \begin{bmatrix} 0 & 0 \\ 0 & \sqrt{q} \end{bmatrix},\\ E_4 = \sqrt{1-p-q} I.\end{split}\]
Parameters:
prob : ndarray | Tensor | Iterable[float] | float

list of two probabilities of resetting to state \(|0\rangle\) and \(|1\rangle\).

dtype

data type. Defaults to be None.

Returns:

a list of Kraus operators

Return type:

List[ndarray | Tensor]

prob_list = torch.tensor([0.1, 0.2])
kraus_operators = reset_kraus(prob_list)
print(f'The Kraus operators are:\n{kraus_operators}')
The Kraus operators are:
tensor([[[0.3162+0.j, 0.0000+0.j],
        [0.0000+0.j, 0.0000+0.j]],

        [[0.0000+0.j, 0.3162+0.j],
        [0.0000+0.j, 0.0000+0.j]],

        [[0.0000+0.j, 0.0000+0.j],
        [0.4472+0.j, 0.0000+0.j]],

        [[0.0000+0.j, 0.0000+0.j],
        [0.0000+0.j, 0.4472+0.j]],

        [[0.8367+0.j, 0.0000+0.j],
        [0.0000+0.j, 0.8367+0.j]]], dtype=torch.complex128)
quairkit.database.representation.thermal_relaxation_kraus(const_t, exec_time)

Kraus representation of a thermal relaxation channel

Parameters:
const_t : ndarray | Tensor | Iterable[float] | float

list of \(T_1\) and \(T_2\) relaxation time in microseconds.

exec_time : ndarray | Tensor | Iterable[float] | float

quantum gate execution time in the process of relaxation in nanoseconds.

dtype

data type. Defaults to be None.

Returns:

a list of Kraus operators.

Return type:

List[ndarray | Tensor]

const_t = torch.tensor([50, 30])
exec_time = torch.tensor([100])
kraus_operators = thermal_relaxation_kraus(const_t, exec_time)
print(f'The Kraus operators are:\n{kraus_operators}')
The Kraus operators are:
tensor([[[ 0.9987+0.j,  0.0000+0.j],
        [ 0.0000+0.j,  0.9987+0.j]],

        [[ 0.0258+0.j,  0.0000+0.j],
        [ 0.0000+0.j, -0.0258+0.j]],

        [[ 0.0447+0.j,  0.0000+0.j],
        [ 0.0000+0.j,  0.0000+0.j]],

        [[ 0.0000+0.j,  0.0447+0.j],
        [ 0.0000+0.j,  0.0000+0.j]]], dtype=torch.complex128)
quairkit.database.representation.replacement_choi(sigma)

Choi representation of a replacement channel

Parameters:
sigma : ndarray | Tensor | State

output state of this channel.

dtype

data type. Defaults to be None.

Returns:

a Choi operator.

Return type:

ndarray | Tensor | State

sigma= torch.tensor([[0.8, 0.0], [0.0, 0.2]])
choi_operator = replacement_choi(sigma)
print(f'The Choi operator is :\n{choi_operator}')
The Choi operator is :
tensor([[0.8000+0.j, 0.0000+0.j, 0.0000+0.j, 0.0000+0.j],
        [0.0000+0.j, 0.2000+0.j, 0.0000+0.j, 0.0000+0.j],
        [0.0000+0.j, 0.0000+0.j, 0.8000+0.j, 0.0000+0.j],
        [0.0000+0.j, 0.0000+0.j, 0.0000+0.j, 0.2000+0.j]], dtype=torch.complex128)