forked from PennyLaneAI/plugin-test-matrix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile.py
More file actions
184 lines (167 loc) · 6.53 KB
/
compile.py
File metadata and controls
184 lines (167 loc) · 6.53 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
from textwrap import dedent
from jinja2 import FileSystemLoader, Environment
workflows = [
{
"plugin": "qiskit",
"gh_user": "PennyLaneAI",
"which": ["latest", "stable"],
"requirements": ["qiskit", "pyscf==1.7.2"],
"device_tests": [
"--device=qiskit.basicaer --tb=short --skip-ops --shots=20000 --device-kwargs backend=qasm_simulator",
"--device=qiskit.aer --tb=short --skip-ops --shots=20000",
"--device=qiskit.basicaer --tb=short --skip-ops --shots=None --device-kwargs backend=statevector_simulator",
"--device=qiskit.aer --tb=short --skip-ops --shots=None --device-kwargs backend=aer_simulator_unitary",
],
},
{
"plugin": "cirq",
"gh_user": "PennyLaneAI",
"which": ["latest", "stable"],
"requirements": ["cirq", "qsimcirq"],
"device_tests": [
"--device=cirq.simulator --tb=short --skip-ops --shots=None",
"--device=cirq.simulator --tb=short --skip-ops --shots=20000",
"--device=cirq.mixedsimulator --tb=short --skip-ops --shots=None",
"--device=cirq.mixedsimulator --tb=short --skip-ops --shots=20000",
# Pasqal doesn't work, says
# qubits = [pasqal.ThreeDQubit(wire * control_radius / 2, 0, 0) for wire in range(wires)]
# E TypeError: unsupported operand type(s) for /: 'str' and 'int'
# "--device=cirq.pasqal --tb=short --skip-ops --analytic=False --shots=20000 --device-kwargs control_radius=2.",
"--device=cirq.qsim --tb=short --skip-ops --analytic=False --shots=20000",
],
},
{
"plugin": "qulacs",
"gh_user": "PennyLaneAI",
"which": ["stable", "latest"],
"requirements": ["qulacs"],
"device_tests": [
"--device=qulacs.simulator --tb=short --skip-ops --shots=None",
"--device=qulacs.simulator --tb=short --skip-ops --shots=20000",
],
},
{
"plugin": "sf",
"gh_user": "PennyLaneAI",
"which": ["stable", "latest"],
"requirements": ["strawberryfields", "tensorflow"],
"device_tests": [],
},
{
"plugin": "rigetti",
"gh_user": "PennyLaneAI",
"which": ["stable", "latest"],
"requirements": ["pyquil==2.28.2"],
"device_tests": [
"--device=rigetti.numpy_wavefunction --tb=short --skip-ops --shots=None",
"--device=rigetti.wavefunction --tb=short --skip-ops --shots=20000",
# "--device=rigetti.qvm --tb=short --skip-ops --shots=20000 --device-kwargs device=4q-qvm",
],
"additional_setup": dedent("""
- name: Run Rigetti Quilc
run: docker run --rm -d -p 5555:5555 rigetti/quilc:1.23.0 -R
- name: Run Rigetti QVM
run: docker run --rm -d -p 5000:5000 rigetti/qvm -S"""
)
},
{
"plugin": "aqt",
"gh_user": "PennyLaneAI",
"which": ["stable", "latest"],
"requirements": [],
"device_tests": [],
},
{
"plugin": "honeywell",
"gh_user": "PennyLaneAI",
"which": ["stable", "latest"],
"requirements": [],
"device_tests": [],
},
{
"plugin": "ionq",
"gh_user": "PennyLaneAI",
"which": ["stable", "latest"],
"requirements": [],
"device_tests": ["--device=ionq.simulator --tb=short --skip-ops --shots=10000"],
},
{
"plugin": "pq",
"gh_user": "PennyLaneAI",
"which": ["stable", "latest"],
"requirements": ["projectq"],
"device_tests": [],
},
{
"plugin": "lightning",
"gh_user": "PennyLaneAI",
"which": ["stable", "latest"],
"requirements": ["pybind11"],
"device_tests": [
"--device lightning.qubit --shots=None --skip-ops",
"--device lightning.qubit --skip-ops --shots=20000",
],
"additional_setup": dedent("""
- name: Install Eigen
run: |
sudo apt install libeigen3-dev"""
)
},
{
"plugin": "orquestra",
"gh_user": "PennyLaneAI",
"which": ["stable", "latest"],
"requirements": [],
"device_tests": [],
"test_kwargs": ["-k 'not e2e'"],
"branch": "main",
},
{
"plugin": "braket",
"plugin_repo": "amazon-braket-pennylane-plugin-python",
"plugin_package": "amazon-braket-pennylane-plugin",
"gh_user": "aws",
"which": ["stable", "latest"],
"requirements": [],
"device_tests": [],
"branch": "main",
"device_tests": [
"--device=braket.local.qubit --tb=short --skip-ops --shots=20000 -k 'not no_0_shots'",
"--device=braket.local.qubit --tb=short --skip-ops -k 'not Sample and not no_0_shots'",
],
"tests_loc": "test/unit_tests",
},
]
def render_from_template(template, **kwargs):
loader = FileSystemLoader(".")
env = Environment(loader=loader)
template = env.get_template(template)
return template.render(**kwargs)
def render_templates():
for wf in workflows:
if "plugin_package" not in wf:
plugin_name = wf["plugin"]
wf["plugin_package"] = "pennylane_" + plugin_name
if "plugin_repo" not in wf:
plugin_name = wf["plugin"]
wf["plugin_repo"] = "pennylane-" + plugin_name
if "tests_loc" not in wf:
wf["tests_loc"] = "tests"
# PennyLane stable tests
for i in wf["which"]:
with open(f".github/workflows/{wf['plugin']}-{i}-stable.yml", "w") as f:
f.write(render_from_template("workflow-template-stable.yml", latest=i == "latest", **wf))
# PennyLane latest tests
for i in wf["which"]:
with open(f".github/workflows/{wf['plugin']}-{i}-latest.yml", "w") as f:
f.write(
render_from_template("workflow-template-latest.yml", latest=i == "latest", **wf)
)
# PennyLane release candidate tests
for i in wf["which"]:
with open(f".github/workflows/{wf['plugin']}-latest-rc.yml", "w") as f:
f.write(
render_from_template("workflow-template-release-candidate.yml", latest=True, **wf)
)
if __name__ == "__main__":
render_templates()