mindquantum.core.gates.GroupedPauliChannel

View Source On Gitee
class mindquantum.core.gates.GroupedPauliChannel(probs: npt.NDArray[np.float64], **kwargs)[source]

A group of pauli channels.

This quantum channel is equivalent to a list of pauli channels, but will evaluate much faster than apply them one by one. For detail of pauli channel, please refers to PauliChannel.

\[\epsilon(\rho) = \otimes_i \epsilon_\text{pauli}^i(\rho)\]
Parameters

probs (numpy.ndarray) – The error probabilities of pauli channel. It has dimension of (n, 3), where the first dimension n is the qubit number or the number of pauli channels represented by this quantum channel . The second dimension 3 represents the probability of applying \(X\), \(Y\) or \(Z\) gate.

Examples

>>> import numpy as np
>>> from mindquantum.core.gates import GroupedPauliChannel
>>> from mindquantum.core.circuit import Circuit
>>> from mindquantum.simulator import Simulator
>>> probs = np.array([[1.0, 0.0, 0.0], [0.0, 0.3, 0.0]])
>>> circ = Circuit([GroupedPauliChannel(probs).on([0, 1])]).measure_all()
>>> circ
      ╭ ╔═══Grouped Pauli Channel     ╮ ┍━━━━━━┑
q0: ──┤─╢ PC(px=1, py=0, pz=0) ╟──────├─┤ M q0 ├───
      │ ╚══════════════════════╝      │ ┕━━━━━━┙
      │ ╔═════════════════════════╗   │ ┍━━━━━━┑
q1: ──┤─╢ PC(px=0, py=3/10, pz=0) ╟───├─┤ M q1 ├───
      ╰ ╚═════════════════════════╝   ╯ ┕━━━━━━┙
>>> Simulator('mqvector', circ.n_qubits).sampling(circ, shots=1000, seed=42)
shots: 1000
Keys: q1 q0│0.00   0.177       0.355       0.532        0.71       0.887
───────────┼───────────┴───────────┴───────────┴───────────┴───────────┴
         01│▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓

         11│▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

{'01': 710, '11': 290}
get_cpp_obj()[source]

Get underlying C++ object.

matrix()[source]

Kraus operator of the quantum channel.

Returns

list, contains all Kraus operators of every pauli channel.