Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

PR

Just a small problem.

I can fix it online!

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

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 2x orbitals, where x0. 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:

bi=[βn]i,jfj,

where βn is the N×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+p,qhp,qapaq+p,q,r,shp,q,r,sapaqaras

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.

ajσjXi=0j1σiZajσj+Xi=0j1σiZ,

where the σ+=σX+iσY and σ=σXiσ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:

|fM1,fM2,,f0|qM1,qM2,,q0,

where

qm=|(i=0m1fi)mod 2

Basically, this formular could be written as this,

pi=[πn]i,jfj,

where πn is the N×N square matrix, N is the total qubit number. The operator changes follows the following equation as:

aj12(i=j+1N(σiXX))(σjXiσjY)Xσj1Zaj12(i=j+1N(σiXX))(σjX+iσjY)Xσj1Z
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.