tensorcircuit.channels#
Some common noise quantum channels.
- class tensorcircuit.channels.KrausList(iterable, name, is_unitary)[源代码]#
基类:
list
- append(object, /)#
Append object to the end of the list.
- clear()#
Remove all items from list.
- copy()#
Return a shallow copy of the list.
- count(value, /)#
Return number of occurrences of value.
- extend(iterable, /)#
Extend list by appending elements from the iterable.
- index(value, start=0, stop=9223372036854775807, /)#
Return first index of value.
Raises ValueError if the value is not present.
- insert(index, object, /)#
Insert object before index.
- pop(index=- 1, /)#
Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
- remove(value, /)#
Remove first occurrence of value.
Raises ValueError if the value is not present.
- reverse()#
Reverse IN PLACE.
- sort(*, key=None, reverse=False)#
Sort the list in ascending order and return None.
The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).
If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.
The reverse flag can be set to sort in descending order.
- tensorcircuit.channels.amplitudedampingchannel(gamma: float, p: float) Sequence[tensorcircuit.gates.Gate] [源代码]#
Return an amplitude damping channel. Notice: Amplitude damping corrspondings to p = 1.
\[\begin{split}\sqrt{p} \begin{bmatrix} 1 & 0\\ 0 & \sqrt{1-\gamma}\\ \end{bmatrix}\qquad \sqrt{p} \begin{bmatrix} 0 & \sqrt{\gamma}\\ 0 & 0\\ \end{bmatrix}\qquad \sqrt{1-p} \begin{bmatrix} \sqrt{1-\gamma} & 0\\ 0 & 1\\ \end{bmatrix}\qquad \sqrt{1-p} \begin{bmatrix} 0 & 0\\ \sqrt{\gamma} & 0\\ \end{bmatrix}\end{split}\]- Example
>>> cs = amplitudedampingchannel(0.25, 0.3) >>> tc.channels.single_qubit_kraus_identity_check(cs)
- 参数
gamma (float) -- the damping parameter of amplitude (\(\gamma\))
p (float) -- \(p\)
- 返回
An amplitude damping channel with given \(\gamma\) and \(p\)
- 返回类型
Sequence[Gate]
- tensorcircuit.channels.check_rep_transformation(kraus: Sequence[tensorcircuit.gates.Gate], density_matrix: Any, verbose: bool = False)[源代码]#
Check the convertation between those representations.
- 参数
kraus (Sequence[Gate]) -- A sequence of Gate
density_matrix (Matrix) -- Initial density matrix
verbose (bool, optional) -- Whether print Kraus and new Kraus operators, defaults to False
- tensorcircuit.channels.choi_to_kraus(choi: Any, truncation_rules: Optional[Dict[str, Any]] = None) Any [源代码]#
Convert the Choi matrix representation to Kraus operator representation.
This can be done by firstly geting eigen-decomposition of Choi-matrix
\[\Lambda = \sum_k \gamma_k \vert \phi_k \rangle \langle \phi_k \vert\]Then define Kraus operators
\[K_k = \sqrt{\gamma_k} V_k\]where \(\gamma_k\geq0\) and \(\phi_k\) is the col-val vectorization of \(V_k\) .
- Examples
>>> kraus = tc.channels.phasedampingchannel(0.2) >>> superop = tc.channels.kraus_to_choi(kraus) >>> kraus_new = tc.channels.choi_to_kraus(superop, truncation_rules={"max_singular_values":3})
- 参数
choi (Matrix) -- Choi matrix
truncation_rules (Dictionary) -- A dictionary to restrict the calculation of kraus matrices. The restriction can be the number of kraus terms, which is jitable. It can also be the truncattion error, which is not jitable.
- 返回
A list of Kraus operators
- 返回类型
Sequence[Matrix]
- tensorcircuit.channels.choi_to_super(choi: Any) Any [源代码]#
Convert from Choi representation to Superoperator representation.
- 参数
choi (Matrix) -- Choi matrix
- 返回
Superoperator
- 返回类型
Matrix
- tensorcircuit.channels.composedkraus(kraus1: tensorcircuit.channels.KrausList, kraus2: tensorcircuit.channels.KrausList) tensorcircuit.channels.KrausList [源代码]#
Compose the noise channels
- tensorcircuit.channels.depolarizingchannel(px: float, py: float, pz: float) Sequence[tensorcircuit.gates.Gate] [源代码]#
Return a Depolarizing Channel
\[\begin{split}\sqrt{1-p_x-p_y-p_z} \begin{bmatrix} 1 & 0\\ 0 & 1\\ \end{bmatrix}\qquad \sqrt{p_x} \begin{bmatrix} 0 & 1\\ 1 & 0\\ \end{bmatrix}\qquad \sqrt{p_y} \begin{bmatrix} 0 & -1j\\ 1j & 0\\ \end{bmatrix}\qquad \sqrt{p_z} \begin{bmatrix} 1 & 0\\ 0 & -1\\ \end{bmatrix}\end{split}\]- Example
>>> cs = depolarizingchannel(0.1, 0.15, 0.2) >>> tc.channels.single_qubit_kraus_identity_check(cs)
- 参数
px (float) -- \(p_x\)
py (float) -- \(p_y\)
pz (float) -- \(p_z\)
- 返回
Sequences of Gates
- 返回类型
Sequence[Gate]
- tensorcircuit.channels.evol_kraus(density_matrix: Any, kraus_list: Sequence[Any]) Any [源代码]#
The dynamic evolution according to Kraus operators.
\[\rho' = \sum_{k} K_k \rho K_k^{\dagger}\]- Examples
>>> density_matrix = np.array([[0.5,0.5],[0.5,0.5]]) >>> kraus = tc.channels.phasedampingchannel(0.2) >>> evol_kraus(density_matrix,kraus)
- 参数
density_matrix (Matrix) -- Initial density matrix
kraus_list (Sequence[Matrix]) -- A list of Kraus operator
- 返回
Final density matrix
- 返回类型
Matrix
- tensorcircuit.channels.evol_superop(density_matrix: Any, superop: Any) Any [源代码]#
The dynamic evolution according to Superoperator.
- Examples
>>> density_matrix = np.array([[0.5,0.5],[0.5,0.5]]) >>> kraus = tc.channels.phasedampingchannel(0.2) >>> superop = kraus_to_super(kraus) >>> evol_superop(density_matrix,superop)
- 参数
density_matrix (Matrix) -- Initial density matrix
superop (Sequence[Matrix]) -- Superoperator
- 返回
Final density matrix
- 返回类型
Matrix
- tensorcircuit.channels.generaldepolarizingchannel(p: Union[float, Sequence[float]], num_qubits: int = 1) Sequence[tensorcircuit.gates.Gate] [源代码]#
Return a depolarizing channel. If \(p\) is a float number, the one qubit channel is
\[\mathcal{E}(\rho) = (1 - 3p)\rho + p(X\rho X + Y\rho Y + Z\rho Z)\]Or alternatively
\[\mathcal{E}(\rho) = 4p \frac{I}{2} + (1 - 4p) \rho\]注解
The definition of
p
in this method is different fromisotropicdepolarizingchannel()
.And if \(p\) is a sequence, the one qubit channel is
\[\mathcal{E}(\rho) = (1 - \sum_i p_i) \rho + p_1 X\rho X + p_2 Y\rho Y + p_3 \rho Z\]The logic for two-qubit or more-qubit channel follows similarly.
- Example
>>> cs = tc.channels.generaldepolarizingchannel([0.1,0.1,0.1],1) >>> tc.channels.kraus_identity_check(cs) >>> cs = tc.channels.generaldepolarizingchannel(0.02,2) >>> tc.channels.kraus_identity_check(cs)
- 参数
p (Union[float, Sequence]) -- parameter for each Pauli channel
num_qubits (int, optional) -- number of qubits, defaults 1
- 返回
Sequences of Gates
- 返回类型
Sequence[Gate]
- tensorcircuit.channels.is_hermitian_matrix(mat: Any, rtol: float = 1e-08, atol: float = 1e-05)[源代码]#
Test if an array is a Hermitian matrix
- 参数
mat (Matrix) -- Matrix
rtol (float, optional) -- _description_, defaults to 1e-8
atol (float, optional) -- _description_, defaults to 1e-5
- 返回
_description_
- 返回类型
_type_
- tensorcircuit.channels.isotropicdepolarizingchannel(p: float, num_qubits: int = 1) Sequence[tensorcircuit.gates.Gate] [源代码]#
Return an isotropic depolarizing channel.
\[\mathcal{E}(\rho) = (1 - p)\rho + p/(4^n-1)\sum_j P_j \rho P_j\]where $n$ is the number of qubits and $P_j$ are $n$-qubit Pauli strings except $I$. Or alternatively
\[\mathcal{E}(\rho) = \frac{4^n}{4^n-1}p \frac{I}{2} + (1 - \frac{4^n}{4^n-1}p) \rho\]注解
The definition of
p
in this method is different fromgeneraldepolarizingchannel()
.- Example
>>> cs = tc.channels.isotropicdepolarizingchannel(0.30,2) >>> tc.channels.kraus_identity_check(cs)
- 参数
p (float) -- error probability
num_qubits (int, optional) -- number of qubits, defaults 1
- 返回
Sequences of Gates
- 返回类型
Sequence[Gate]
- tensorcircuit.channels.kraus_identity_check(kraus: Sequence[tensorcircuit.gates.Gate]) None [源代码]#
Check identity of Kraus operators.
\[\sum_{k}^{} K_k^{\dagger} K_k = I\]- Examples
>>> cs = resetchannel() >>> tc.channels.kraus_identity_check(cs)
- 参数
kraus (Sequence[Gate]) -- List of Kraus operators.
- tensorcircuit.channels.kraus_to_choi(kraus_list: Sequence[Any]) Any [源代码]#
Convert from Kraus representation to Choi representation.
- 参数
kraus_list (Sequence[Matrix]) -- A list Kraus operators
- 返回
Choi matrix
- 返回类型
Matrix
- tensorcircuit.channels.kraus_to_super(kraus_list: Sequence[Any]) Any [源代码]#
Convert Kraus operator representation to Louivile-Superoperator representation.
In the col-vec basis, the evolution of a state \(\rho\) in terms of tensor components of superoperator \(\varepsilon\) can be expressed as
\[\rho'_{mn} = \sum_{\mu \nu}^{} \varepsilon_{nm,\nu \mu} \rho_{\mu \nu}\]The superoperator \(\varepsilon\) must make the dynamic map from \(\rho\) to \(\rho'\) to satisfy hermitian-perserving (HP), trace-preserving (TP), and completely positive (CP).
We can construct the superoperator from Kraus operators by
\[\varepsilon = \sum_{k} K_k^{*} \otimes K_k\]- Examples
>>> kraus = resetchannel() >>> tc.channels.kraus_to_super(kraus)
- 参数
kraus_list (Sequence[Gate]) -- A sequence of Gate
- 返回
The corresponding Tensor of Superoperator
- 返回类型
Matrix
- tensorcircuit.channels.kraus_to_super_gate(kraus_list: Sequence[tensorcircuit.gates.Gate]) Any [源代码]#
Convert Kraus operators to one Tensor (as one Super Gate).
\[\sum_{k}^{} K_k \otimes K_k^{*}\]- 参数
kraus_list (Sequence[Gate]) -- A sequence of Gate
- 返回
The corresponding Tensor of the list of Kraus operators
- 返回类型
Tensor
- tensorcircuit.channels.krausgate_to_krausmatrix(kraus_list: Sequence[tensorcircuit.gates.Gate]) Sequence[Any] [源代码]#
Convert Kraus of Gate form to Matrix form.
- 参数
kraus_list (Sequence[Gate]) -- A list of Kraus
- 返回
A list of Kraus operators
- 返回类型
Sequence[Matrix]
- tensorcircuit.channels.krausmatrix_to_krausgate(kraus_list: Sequence[Any]) Sequence[tensorcircuit.gates.Gate] [源代码]#
Convert Kraus of Matrix form to Gate form.
- 参数
kraus_list (Sequence[Matrix]) -- A list of Kraus
- 返回
A list of Kraus operators
- 返回类型
Sequence[Gate]
- tensorcircuit.channels.phasedampingchannel(gamma: float) Sequence[tensorcircuit.gates.Gate] [源代码]#
Return a phase damping channel with given \(\gamma\)
\[\begin{split}\begin{bmatrix} 1 & 0\\ 0 & \sqrt{1-\gamma}\\ \end{bmatrix}\qquad \begin{bmatrix} 0 & 0\\ 0 & \sqrt{\gamma}\\ \end{bmatrix}\end{split}\]- Example
>>> cs = phasedampingchannel(0.6) >>> tc.channels.single_qubit_kraus_identity_check(cs)
- 参数
gamma (float) -- The damping parameter of phase (\(\gamma\))
- 返回
A phase damping channel with given \(\gamma\)
- 返回类型
Sequence[Gate]
- tensorcircuit.channels.resetchannel() Sequence[tensorcircuit.gates.Gate] [源代码]#
Reset channel
\[\begin{split}\begin{bmatrix} 1 & 0\\ 0 & 0\\ \end{bmatrix}\qquad \begin{bmatrix} 0 & 1\\ 0 & 0\\ \end{bmatrix}\end{split}\]- Example
>>> cs = resetchannel() >>> tc.channels.single_qubit_kraus_identity_check(cs)
- 返回
Reset channel
- 返回类型
Sequence[Gate]
- tensorcircuit.channels.reshuffle(op: Any, order: Sequence[int]) Any [源代码]#
Reshuffle the dimension index of a matrix.
- 参数
op (Matrix) -- Input matrix
order (Tuple) -- required order
- 返回
Reshuffled matrix
- 返回类型
Matrix
- tensorcircuit.channels.single_qubit_kraus_identity_check(kraus: Sequence[tensorcircuit.gates.Gate]) None #
Check identity of Kraus operators.
\[\sum_{k}^{} K_k^{\dagger} K_k = I\]- Examples
>>> cs = resetchannel() >>> tc.channels.kraus_identity_check(cs)
- 参数
kraus (Sequence[Gate]) -- List of Kraus operators.
- tensorcircuit.channels.super_to_choi(superop: Any) Any [源代码]#
Convert Louivile-Superoperator representation to Choi representation.
In the col-vec basis, the evolution of a state \(\rho\) in terms of Choi matrix \(\Lambda\) can be expressed as
\[\rho'_{mn} = \sum_{\mu,\nu}^{} \Lambda_{\mu m,\nu n} \rho_{\mu \nu}\]The Choi matrix \(\Lambda\) must make the dynamic map from \(\rho\) to \(\rho'\) to satisfy hermitian-perserving (HP), trace-preserving (TP), and completely positive (CP).
Interms of tensor components we have the relationship of Louivile-Superoperator representation and Choi representation
\[\Lambda_{mn,\mu \nu} = \varepsilon_{\nu n,\mu m}\]- Examples
>>> kraus = resetchannel() >>> superop = tc.channels.kraus_to_super(kraus) >>> tc.channels.super_to_choi(superop)
- 参数
superop (Matrix) -- Superoperator
- 返回
Choi matrix
- 返回类型
Matrix
- tensorcircuit.channels.super_to_kraus(superop: Any) Any [源代码]#
Convert from Superoperator representation to Kraus representation.
- 参数
superop (Matrix) -- Superoperator
- 返回
A list of Kraus operator
- 返回类型
Matrix
- tensorcircuit.channels.thermalrelaxationchannel(t1: float, t2: float, time: float, method: str = 'ByChoi', excitedstatepopulation: float = 0.0) Sequence[tensorcircuit.gates.Gate] [源代码]#
Return a thermal_relaxation_channel
- Example
>>> cs = thermalrelaxationchannel(100,200,100,"AUTO",0.1) >>> tc.channels.single_qubit_kraus_identity_check(cs)
- 参数
t1 (float) -- the T1 relaxation time.
t2 (float) -- the T2 dephasing time.
time (str) -- gate time
method -- method to express error (default: "ByChoi"). When \(T1>T2\), choose method "ByKraus" or "ByChoi" for jit. When \(T1<T2\),choose method "ByChoi" for jit. Users can also set method as "AUTO" and never mind the relative magnitude of \(T1,T2\), which is not jitable.
excitedstatepopulation -- the population of state \(|1\rangle\) at equilibrium (default: 0)
- 返回
A thermal_relaxation_channel
- 返回类型
Sequence[Gate]