-
Notifications
You must be signed in to change notification settings - Fork 80
/
qem_dqas.py
68 lines (57 loc) · 1.27 KB
/
qem_dqas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""
DQAS for QFT QEM circuit design, deprecated DQAS implementation
"""
import sys
sys.path.insert(0, "../")
from functools import partial
import cirq
import numpy as np
import tensorflow as tf
from tensorcircuit.applications.vags import qft_qem_vag
from tensorcircuit.applications.dqas import (
set_op_pool,
DQAS_search,
verbose_output,
)
def main_3():
qft_3 = partial(qft_qem_vag, n=3)
set_op_pool([cirq.X, cirq.Y, cirq.Z, cirq.I, cirq.T, cirq.S])
DQAS_search(
qft_3,
nnp_initial_value=tf.zeros([6, 6]),
p=6,
prethermal=0,
batch=32,
verbose=False,
epochs=30,
)
def main_4():
qft_4 = partial(qft_qem_vag, n=4)
set_op_pool(
[
cirq.I,
cirq.X,
cirq.Y,
cirq.Z,
cirq.H,
cirq.rx(np.pi / 3),
cirq.rx(np.pi * 2.0 / 3),
cirq.rz(np.pi / 3),
cirq.rz(np.pi * 2.0 / 3),
cirq.S,
cirq.T,
]
)
DQAS_search(
qft_4,
nnp_initial_value=tf.zeros([12, 11]),
p=12,
prethermal=0,
batch=32,
verbose=False,
verbose_func=verbose_output,
epochs=6,
)
if __name__ == "__main__":
# main_3()
main_4()