Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

原生论文任务 #181

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions research/arxiv_papers/GROVER-OP/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

# 基于MindSpore的精确多目标量子搜索算法的优化
# The optimization of exact multi-target quantum search algorithm based on MindSpore

Grover’s search algorithm has attracted great attention due to its quadratic speedup over classical algorithms in unsorted database search problems. However, Grover’s algorithm is inefficient in multi-target search problems, except in the case of 1/4 of the data in the database satisfying the search conditions. Long presented a modified version of Grover’s search algorithm by introducing a phase-matching condition, which can search for the target state with zero theoretical failure rate. In this work, we present an optimized exact multi-target search algorithm based on the modified Grover’s algorithm, by transforming the canonical diffusion operator to a more efficient diffusion operator, which can solve the multi-target search problem with a 100% success rate while requiring fewer gate counts and shallower circuit depth. After that, the optimized multi-target algorithm for four different items, including 2-qubit with 2 targets, 5-qubit with 2 targets, 5-qubit with 4 targets, and 6-qubit with 3 targets, are implemented on a quantum computing framework MindQuantum. The experimental results show that, compared with Grover’s algorithm and the modified Grover’s algorithm, the proposed algorithm can reduce the quantum gate count by at least 21.1% and the depth of the quantum circuit by at least 11.4% and maintain a 100% success probability.

Keywords: Quantum computing , Grover's algorithm , Optimized multi-target search algorithm

Folder: GROVER-Grover's algorithm, OP-Optimized
## Test Environment:

```python
- Mindquantum 0.9.11
- scipy 1.9.3
- numpy 1.24.2
- Python 3.9.11
- OS Linux x86_64
- CPU Max Thread 64
```


## Installation

Install Mindquantum with pip.
```bash
pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.6.1/MindQuantum/x86_64/mindquantum-0.5.0-cp37-cp37m-win_amd64.whl
```
Verify if the installation was successful
```bash
python -c 'import mindquantum'.
```

## Acknowledgements

- [Thank you to the MindSpore community for your support!](https://www.mindspore.cn/)


44 changes: 44 additions & 0 deletions research/arxiv_papers/GROVER-OP/code/2-2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from mindquantum import *


circ = Circuit()
n_qubits = 2
circ += UN(H, n_qubits)


circ += BarrierGate(True)

circ += X.on(1)
circ += X.on(0)
circ += PhaseShift(1.5708).on(1,0)
circ += X.on(0)
circ += X.on(1)

circ += BarrierGate(True)
circ += X.on(1)
circ += PhaseShift(1.5708).on(1,0)
circ += X.on(1)



circ += BarrierGate(True)
circ += UN(RY(1.5708), n_qubits)
circ += PhaseShift(1.5708).on(1,0)
circ += UN(RY(-1.5708), n_qubits)
circ += BarrierGate(True)







circ += Measure().on(0)
circ += Measure().on(1)

sim = Simulator("mqvector", circ.n_qubits)
res = sim.sampling(circ, shots=10000)


print(circ)
circ.svg()
86 changes: 86 additions & 0 deletions research/arxiv_papers/GROVER-OP/code/5-2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
from mindquantum import *


circ = Circuit()
n_qubits = 5
circ += UN(H, n_qubits)

circ += BarrierGate(True)
circ += X.on(3)
circ += X.on(4)
circ += X.on(1)
circ += PhaseShift(2.1951).on(4,[1,0,2,3])
circ += X.on(3)
circ += X.on(4)
circ += X.on(1)




circ += BarrierGate(True)
circ += X.on(3)
circ += PhaseShift(2.1951).on(4,[1,0,2,3])
circ += X.on(3)

circ += BarrierGate(True)
circ += UN(RY(1.5708), n_qubits)
circ += PhaseShift(2.1951).on(4,[1,0,2,3])
circ += UN(RY(-1.5708), n_qubits)
circ += BarrierGate(True)

circ += X.on(3)
circ += X.on(4)
circ += X.on(1)
circ += PhaseShift(2.1951).on(4,[1,0,2,3])
circ += X.on(3)
circ += X.on(4)
circ += X.on(1)




circ += BarrierGate(True)
circ += X.on(3)
circ += PhaseShift(2.1951).on(4,[1,0,2,3])
circ += X.on(3)


circ += BarrierGate(True)
circ += UN(RY(1.5708), n_qubits)
circ += PhaseShift(2.1951).on(4,[1,0,2,3])
circ += UN(RY(-1.5708), n_qubits)
circ += BarrierGate(True)

circ += X.on(3)
circ += X.on(4)
circ += X.on(1)
circ += PhaseShift(2.1951).on(4,[1,0,2,3])
circ += X.on(3)
circ += X.on(4)
circ += X.on(1)




circ += BarrierGate(True)
circ += X.on(3)
circ += PhaseShift(2.1951).on(4,[1,0,2,3])
circ += X.on(3)


circ += BarrierGate(True)
circ += UN(RY(1.5708), n_qubits)
circ += PhaseShift(2.1951).on(4,[1,0,2,3])
circ += UN(RY(-1.5708), n_qubits)
circ += BarrierGate(True)

circ += Measure().on(0)
circ += Measure().on(1)
circ += Measure().on(2)
circ += Measure().on(3)
circ += Measure().on(4)
sim = Simulator("mqvector", circ.n_qubits)
res = sim.sampling(circ, shots=10000)

print(res)
circ.svg()
98 changes: 98 additions & 0 deletions research/arxiv_papers/GROVER-OP/code/5-4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
from mindquantum import *


circ = Circuit()
n_qubits = 5
circ += UN(H, n_qubits)

circ += BarrierGate(True)
circ += X.on(3)
circ += X.on(2)
circ += X.on(1)
circ += PhaseShift(2.1269).on(4,[1,0,2,3])
circ += X.on(3)
circ += X.on(2)
circ += X.on(1)




circ += BarrierGate(True)
circ += X.on(2)
circ += X.on(4)
circ += PhaseShift(2.1269).on(4,[1,0,2,3])
circ += X.on(2)
circ += X.on(4)


circ += BarrierGate(True)
circ += X.on(1)
circ += PhaseShift(2.1269).on(4,[1,0,2,3])
circ += X.on(1)

circ += BarrierGate(True)
circ += X.on(0)
circ += X.on(3)
circ += PhaseShift(2.1269).on(4,[1,0,2,3])
circ += X.on(0)
circ += X.on(3)




circ += BarrierGate(True)
circ += UN(RY(1.5708), n_qubits)
circ += PhaseShift(2.1269).on(4,[1,0,2,3])
circ += UN(RY(-1.5708), n_qubits)
circ += BarrierGate(True)

circ += X.on(3)
circ += X.on(2)
circ += X.on(1)
circ += PhaseShift(2.1269).on(4,[1,0,2,3])
circ += X.on(3)
circ += X.on(2)
circ += X.on(1)




circ += BarrierGate(True)
circ += X.on(2)
circ += X.on(4)
circ += PhaseShift(2.1269).on(4,[1,0,2,3])
circ += X.on(2)
circ += X.on(4)


circ += BarrierGate(True)
circ += X.on(1)
circ += PhaseShift(2.1269).on(4,[1,0,2,3])
circ += X.on(1)

circ += BarrierGate(True)
circ += X.on(0)
circ += X.on(3)
circ += PhaseShift(2.1269).on(4,[1,0,2,3])
circ += X.on(0)
circ += X.on(3)




circ += BarrierGate(True)
circ += UN(RY(1.5708), n_qubits)
circ += PhaseShift(2.1269).on(4,[1,0,2,3])
circ += UN(RY(-1.5708), n_qubits)
circ += BarrierGate(True)

circ += Measure().on(0)
circ += Measure().on(1)
circ += Measure().on(2)
circ += Measure().on(3)
circ += Measure().on(4)
sim = Simulator("mqvector", circ.n_qubits)
res = sim.sampling(circ, shots=10000)

print(res)
circ.svg()
Loading