mindquantum.algorithm.nisq.Transform

View Source On Gitee
class mindquantum.algorithm.nisq.Transform(operator, n_qubits=None)[source]

Class for transforms of fermionic and qubit operators.

jordan_wigner, parity, bravyi_kitaev, bravyi_kitaev_tree, bravyi_kitaev_superfast will transform FermionOperator to QubitOperator. reversed_jordan_wigner will transform QubitOperator to FermionOperator.

Parameters
  • operator (Union[FermionOperator, QubitOperator]) – The input FermionOperator or QubitOperator that need to do transform.

  • n_qubits (int) – The total qubits of given operator. If None, then we will count it automatically. Default: None.

Examples

>>> from mindquantum.core.operators import FermionOperator
>>> op1 = FermionOperator('1^')
>>> op1
1.0 [1^]
>>> op_transform = Transform(op1)
>>> from mindquantum.algorithm.nisq import Transform
>>> op_transform.jordan_wigner()
0.5 [Z0 X1] +
-0.5j [Z0 Y1]
>>> op_transform.parity()
0.5 [Z0 X1] +
-0.5j [Y1]
>>> op_transform.bravyi_kitaev()
0.5 [Z0 X1] +
-0.5j [Y1]
>>> op_transform.ternary_tree()
0.5 [X0 Z1] +
-0.5j [Y0 X2]
>>> op2 = FermionOperator('1^', 'a')
>>> Transform(op2).jordan_wigner()
0.5*a [Z0 X1] +
-0.5*I*a [Z0 Y1]
bravyi_kitaev()[source]

Apply Bravyi-Kitaev transform.

The Bravyi-Kitaev basis is a middle between Jordan-Wigner and parity transform. That is, it balances the locality of occupation and parity information for improved simulation efficiency. In this scheme, qubits store the parity of a set of \(2^x\) orbitals, where \(x \ge 0\). A qubit of index \(j\) always stores orbital \(j\). For even values of \(j\), this is the only orbital that it stores, but for odd values of \(j\), it also stores a certain set of adjacent orbitals with index less than \(j\). For the occupation transformation, we follow the formular:

\[b_{i} = \sum{[\beta_{n}]_{i,j}} f_{j},\]

where \(\beta_{n}\) is the \(N\times N\) square matrix, \(N\) is the total qubit number. The qubits index are divide into three sets, the parity set, the update set and flip set. The parity of this set of qubits has the same parity as the set of orbitals with index less than \(j\), and so we will call this set of qubit indices the "parity set" of index \(j\), or \(P(j)\).

The update set of index \(j\), or \(U(j)\) contains the set of qubits (other than qubit \(j\)) that must be updated when the occupation of orbital \(j\)

The flip set of index \(j\), or \(F(j)\) contains the set of BravyiKitaev qubits determines whether qubit \(j\) has the same parity or inverted parity with respect to orbital \(j\).

Please see some detail explanation in the paper The Bravyi-Kitaev transformation for quantum computation of electronic structure.

Implementation from Fermionic quantum computation and A New Data Structure for Cumulative Frequency Tables by Peter M. Fenwick.

Returns

QubitOperator, qubit operator after bravyi_kitaev transformation.

bravyi_kitaev_superfast()[source]

Apply Bravyi-Kitaev Superfast transform.

Implementation from Bravyi-Kitaev Superfast simulation of fermions on a quantum computer.

Note that only hermitian operators of form will be transformed.

\[C + \sum_{p, q} h_{p, q} a^\dagger_p a_q + \sum_{p, q, r, s} h_{p, q, r, s} a^\dagger_p a^\dagger_q a_r a_s\]

where \(C\) is a constant.

Returns

QubitOperator, qubit operator after bravyi_kitaev_superfast.

jordan_wigner()[source]

Apply Jordan-Wigner transform.

The Jordan-Wigner transform holds the initial occupation number locally, which change the formular of fermion operator into qubit operator following the equation.

\[ \begin{align}\begin{aligned}a^\dagger_{j}\rightarrow \sigma^{-}_{j} X \prod_{i=0}^{j-1}\sigma^{Z}_{i}\\a_{j}\rightarrow \sigma^{+}_{j} X \prod_{i=0}^{j-1}\sigma^{Z}_{i},\end{aligned}\end{align} \]

where the \(\sigma_{+} = \sigma^{X} + i \sigma^{Y}\) and \(\sigma_{-} = \sigma^{X} - i\sigma^{Y}\) is the Pauli spin raising and lowring operator.

Returns

QubitOperator, qubit operator after jordan_wigner transformation.

parity()[source]

Apply parity transform.

The parity transform stores the initial occupation number nonlocally, with the formular:

\[\left|f_{M-1}, f_{M-2},\cdots, f_0\right> \rightarrow \left|q_{M-1}, q_{M-2},\cdots, q_0\right>,\]

where

\[q_{m} = \left|\left(\sum_{i=0}^{m-1}f_{i}\right) mod\ 2 \right>\]

Basically, this formular could be written as this,

\[p_{i} = \sum{[\pi_{n}]_{i,j}} f_{j},\]

where \(\pi_{n}\) is the \(N\times N\) square matrix, \(N\) is the total qubit number. The operator changes follows the following equation as:

\[ \begin{align}\begin{aligned}a^\dagger_{j}\rightarrow\frac{1}{2}\left(\prod_{i=j+1}^N \left(\sigma_i^X X\right)\right)\left( \sigma^{X}_{j}-i\sigma_j^Y\right) X \sigma^{Z}_{j-1}\\a_{j}\rightarrow\frac{1}{2}\left(\prod_{i=j+1}^N \left(\sigma_i^X X\right)\right)\left( \sigma^{X}_{j}+i\sigma_j^Y\right) X \sigma^{Z}_{j-1}\end{aligned}\end{align} \]
Returns

QubitOperator, qubits operator after parity transformation.

reversed_jordan_wigner()[source]

Apply reversed Jordan-Wigner transform.

Returns

FermionOperator, fermion operator after reversed_jordan_wigner transformation.

ternary_tree()[source]

Apply Ternary tree transform.

Implementation from Optimal fermion-to-qubit mapping via ternary trees with applications to reduced quantum states learning.

Returns

QubitOperator, qubit operator after ternary_tree transformation.