@@ -142,6 +142,7 @@ def generate_all_benchmarks(
142
142
file_precheck : bool ,
143
143
) -> None :
144
144
"""Generate all benchmarks for a given benchmark."""
145
+ self .generate_alg_levels (file_precheck , lib , parameter_space )
145
146
self .generate_indep_levels (file_precheck , lib , parameter_space )
146
147
self .generate_native_gates_levels (file_precheck , lib , parameter_space )
147
148
self .generate_mapped_levels (file_precheck , lib , parameter_space )
@@ -154,104 +155,124 @@ def generate_mapped_levels(
154
155
) -> None :
155
156
"""Generate mapped level benchmarks for a given benchmark."""
156
157
for provider in get_available_providers ():
157
- for device in provider .get_available_devices ():
158
- for opt_level in [0 , 1 , 2 , 3 ]:
158
+ for qasm_format in ["qasm2" , "qasm3" ]:
159
+ for device in provider .get_available_devices ():
160
+ for opt_level in [0 , 1 , 2 , 3 ]:
161
+ for parameter_instance in parameter_space :
162
+ qc = timeout_watcher (lib .create_circuit , self .timeout , parameter_instance )
163
+ if not qc :
164
+ break
165
+ assert isinstance (qc , QuantumCircuit )
166
+ if qc .num_qubits <= device .num_qubits :
167
+ res = timeout_watcher (
168
+ qiskit_helper .get_mapped_level ,
169
+ self .timeout ,
170
+ [
171
+ qc ,
172
+ qc .num_qubits ,
173
+ device ,
174
+ opt_level ,
175
+ file_precheck ,
176
+ False ,
177
+ self .qasm_output_path ,
178
+ qasm_format ,
179
+ ],
180
+ )
181
+ if not res :
182
+ break
183
+ else :
184
+ break
185
+
159
186
for parameter_instance in parameter_space :
160
187
qc = timeout_watcher (lib .create_circuit , self .timeout , parameter_instance )
161
188
if not qc :
162
189
break
163
190
assert isinstance (qc , QuantumCircuit )
164
191
if qc .num_qubits <= device .num_qubits :
165
192
res = timeout_watcher (
166
- qiskit_helper .get_mapped_level ,
193
+ tket_helper .get_mapped_level ,
167
194
self .timeout ,
168
- [
169
- qc ,
170
- qc .num_qubits ,
171
- device ,
172
- opt_level ,
173
- file_precheck ,
174
- False ,
175
- self .qasm_output_path ,
176
- ],
195
+ [qc , qc .num_qubits , device , file_precheck , False , self .qasm_output_path , qasm_format ],
177
196
)
178
197
if not res :
179
198
break
180
199
else :
181
200
break
182
201
183
- for parameter_instance in parameter_space :
184
- qc = timeout_watcher (lib .create_circuit , self .timeout , parameter_instance )
185
- if not qc :
186
- break
187
- assert isinstance (qc , QuantumCircuit )
188
- if qc .num_qubits <= device .num_qubits :
202
+ def generate_native_gates_levels (
203
+ self ,
204
+ file_precheck : bool ,
205
+ lib : ModuleType ,
206
+ parameter_space : list [tuple [int , str ]] | list [int ] | list [str ] | range ,
207
+ ) -> None :
208
+ """Generate native gates level benchmarks for a given benchmark."""
209
+ for provider in get_available_providers ():
210
+ for qasm_format in ["qasm2" , "qasm3" ]:
211
+ for opt_level in [0 , 1 , 2 , 3 ]:
212
+ for parameter_instance in parameter_space :
213
+ qc = timeout_watcher (lib .create_circuit , self .timeout , parameter_instance )
214
+ if not qc :
215
+ break
216
+ assert isinstance (qc , QuantumCircuit )
189
217
res = timeout_watcher (
190
- tket_helper . get_mapped_level ,
218
+ qiskit_helper . get_native_gates_level ,
191
219
self .timeout ,
192
220
[
193
221
qc ,
222
+ provider ,
194
223
qc .num_qubits ,
195
- device ,
224
+ opt_level ,
196
225
file_precheck ,
197
226
False ,
198
227
self .qasm_output_path ,
228
+ qasm_format ,
199
229
],
200
230
)
201
231
if not res :
202
232
break
203
- else :
204
- break
205
233
206
- def generate_native_gates_levels (
207
- self ,
208
- file_precheck : bool ,
209
- lib : ModuleType ,
210
- parameter_space : list [tuple [int , str ]] | list [int ] | list [str ] | range ,
211
- ) -> None :
212
- """Generate native gates level benchmarks for a given benchmark."""
213
- for provider in get_available_providers ():
214
- for opt_level in [0 , 1 , 2 , 3 ]:
215
234
for parameter_instance in parameter_space :
216
235
qc = timeout_watcher (lib .create_circuit , self .timeout , parameter_instance )
217
236
if not qc :
218
237
break
219
238
assert isinstance (qc , QuantumCircuit )
220
239
res = timeout_watcher (
221
- qiskit_helper .get_native_gates_level ,
240
+ tket_helper .get_native_gates_level ,
222
241
self .timeout ,
223
242
[
224
243
qc ,
225
244
provider ,
226
245
qc .num_qubits ,
227
- opt_level ,
228
246
file_precheck ,
229
247
False ,
230
248
self .qasm_output_path ,
249
+ qasm_format ,
231
250
],
232
251
)
233
252
if not res :
234
253
break
235
254
255
+ def generate_alg_levels (
256
+ self ,
257
+ file_precheck : bool ,
258
+ lib : ModuleType ,
259
+ parameter_space : list [tuple [int , str ]] | list [int ] | list [str ] | range ,
260
+ ) -> None :
261
+ """Generate algorithm level benchmarks for a given benchmark."""
262
+ for function in [qiskit_helper .get_alg_level ]:
236
263
for parameter_instance in parameter_space :
237
- qc = timeout_watcher (lib .create_circuit , self .timeout , parameter_instance )
238
- if not qc :
239
- break
240
- assert isinstance (qc , QuantumCircuit )
241
- res = timeout_watcher (
242
- tket_helper .get_native_gates_level ,
243
- self .timeout ,
244
- [
245
- qc ,
246
- provider ,
247
- qc .num_qubits ,
248
- file_precheck ,
249
- False ,
250
- self .qasm_output_path ,
251
- ],
252
- )
253
- if not res :
254
- break
264
+ for qasm_format in ["qasm3" ]:
265
+ qc = timeout_watcher (lib .create_circuit , self .timeout , parameter_instance )
266
+ if not qc :
267
+ break
268
+ assert isinstance (qc , QuantumCircuit )
269
+ res = timeout_watcher (
270
+ function ,
271
+ self .timeout ,
272
+ [qc , qc .num_qubits , file_precheck , False , self .qasm_output_path , qasm_format ],
273
+ )
274
+ if not res :
275
+ break
255
276
256
277
def generate_indep_levels (
257
278
self ,
@@ -262,17 +283,18 @@ def generate_indep_levels(
262
283
"""Generate independent level benchmarks for a given benchmark."""
263
284
for function in [qiskit_helper .get_indep_level , tket_helper .get_indep_level ]:
264
285
for parameter_instance in parameter_space :
265
- qc = timeout_watcher (lib .create_circuit , self .timeout , parameter_instance )
266
- if not qc :
267
- break
268
- assert isinstance (qc , QuantumCircuit )
269
- res = timeout_watcher (
270
- function ,
271
- self .timeout ,
272
- [qc , qc .num_qubits , file_precheck , False , self .qasm_output_path ],
273
- )
274
- if not res :
275
- break
286
+ for qasm_format in ["qasm2" , "qasm3" ]:
287
+ qc = timeout_watcher (lib .create_circuit , self .timeout , parameter_instance )
288
+ if not qc :
289
+ break
290
+ assert isinstance (qc , QuantumCircuit )
291
+ res = timeout_watcher (
292
+ function ,
293
+ self .timeout ,
294
+ [qc , qc .num_qubits , file_precheck , False , self .qasm_output_path , qasm_format ],
295
+ )
296
+ if not res :
297
+ break
276
298
277
299
278
300
@overload
0 commit comments