qiskit-hackathon-korea-21 icon indicating copy to clipboard operation
qiskit-hackathon-korea-21 copied to clipboard

EntangledMeasurementGrouper (Qiskit-Terra/OperatorFlow)

Open ikkoham opened this issue 4 years ago • 12 comments

Abstract

Reduction of the number of measurements is one of the most important topic for variational quantum algorithms. In Qiskit, Abelian grouper was implemented for the evaluations of expectation values by joint measurement of tensor product basis (TPB). This project enhances the grouper by using entangled measurements.

Description

This project aims to implement a part of our research for Qiskit and improve the research. The number of measurements can be reduced by entangled measurements. For example, Bell measurement is a joint measurement of XX, YY, and ZZ. image We use the entangled joint measurements to improve the grouper. Very recently, I have added the parameter grouping_type for this purpose.https://github.com/Qiskit/qiskit-terra/blob/master/qiskit/opflow/primitive_ops/pauli_sum_op.py#L39

Milestone

  • [x] Fork Qiskit-Terra and make a branch
  • [x] Enhance the grouper
  • [ ] Implement the entangled measurement circuits
  • [ ] [Optional] Remove the unnecessary measurements
  • [ ] [Optional] Experiment with the real quantum devices
  • [ ] [Optional] Benchmark the performance
  • [ ] [Optional] Improve the algorithms
  • [ ] Make a presentation!

References

  • https://www.nature.com/articles/s41534-020-0284-2
  • https://github.com/Qiskit/qiskit-terra/blob/master/qiskit/opflow/converters/abelian_grouper.py
  • https://github.com/Qiskit/qiskit-terra/blob/master/qiskit/quantum_info/synthesis/clifford_decompose.py

Members

  • @githubhandle
  • @githubhandle - Slack: @slackhandle email: [email protected]
  • Qiskit Coach: @ikkoham

Deliverable

  • Make Pull Requests to Operator Flow in Qiskit Terra.
  • [Optional] Jupyter notebook or short paper?

GitHub repo

ikkoham avatar Feb 16 '21 02:02 ikkoham

Hello, I want to participate in this project. Can I join the team?

KIMJAEHEE0821 avatar Feb 17 '21 04:02 KIMJAEHEE0821

I'm interested in this project. Could I join this team?

physicman96 avatar Feb 17 '21 04:02 physicman96

I am also interested in this project!!

YubeenKim avatar Feb 17 '21 04:02 YubeenKim

It seems very interesting. I want to reduce measurement too. Can I join this project?

sky-born avatar Feb 17 '21 04:02 sky-born

it is very groundbreaking idea! Can i participate?

ghost avatar Feb 17 '21 04:02 ghost

Dev Environment

  1. Fork Qiskit-Terra

  2. Make your branch to work

For CLI

git clone https://github.com/Qiskit/qiskit-terra.git
git remote add sky-born https://github.com/sky-born/qiskit-terra
git fetch sky-born
git switch -c qiskit_korea_hackerthon sky-born/qiskit_korea_hackerthon

Launch Jupyter Notebook with dev env

ikkoham avatar Feb 18 '21 01:02 ikkoham

It may be better to prepare the molecule for benchmark.

ikkoham avatar Feb 18 '21 04:02 ikkoham

I saw LiH, BeH2, H2O, NH3, HCl is in the paper. Should we use that??

YubeenKim avatar Feb 18 '21 04:02 YubeenKim

You can choose it. You can use same molecules with the paper, or it may be interesting to study and compare other molecules. Note that the paper uses Ancillary files in https://arxiv.org/abs/1701.08213. if you want to use Ancillary files, you need to parse the data and make PauliSumOp from them.

ikkoham avatar Feb 18 '21 04:02 ikkoham

How can I extract Pauli string from PaulisumOp operator?

sky-born avatar Feb 18 '21 05:02 sky-born

and SummedOp too, It's not easy to extract Pauli string operators from PaulisumOp and SummedOp class

sky-born avatar Feb 18 '21 05:02 sky-born

This is a hint for creating Pauli graph. https://github.com/Qiskit/qiskit-terra/pull/5299/files

Hint for _anti_commutation_graph(ops: PauliSumOp) -> List[Tuple[int, int]]: For TPB (qubit-wise anti-commutation graph),

# convert a Pauli operator into int vector where {I: 0, X: 2, Y: 3, Z: 1}
mat1 = np.array(
    [op.primitive.table.Z[0] + 2 * op.primitive.table.X[0] for op in observable],
    dtype=np.int8,
)
mat2 = mat1[:, None]
# mat3[i, j] is True if i and j are commutable with TPB
mat3 = (mat1 * mat2) * (mat1 - mat2)
mat4 = (mat3 == 0).all(axis=2)
# return [(i, j) if mat3[i, j] is False and i < j]
return list(zip(*np.where(np.triu(np.logical_not(mat4), k=1))))

For ALL, (general anti-commutation graph),

# convert a Pauli operator into int vector where {I: 0, X: 2, Y: 3, Z: 1}
mat1 = np.array(
    [op.primitive.table.Z[0] + 2 * op.primitive.table.X[0] for op in observable],
    dtype=np.int8,
)
mat2 = mat1[:, None]
# mat3[i, j] is True if i and j are commutable with TPB
mat3 = (mat1 * mat2) * (mat1 - mat2)
mat4 = mat3.copy()
mat4[mat3 == 0] = 1
mat4[mat3 != 0] = -1
mat5 = np.multiply.reduce(mat4, axis=2) == 1
return list(zip(*np.where(np.triu(np.logical_not(mat5), k=1))))

This algorithm is too difficult because I use numpy technique for performance.

ikkoham avatar Feb 18 '21 06:02 ikkoham