7
7
import numpy as np
8
8
import numpy .typing as npt
9
9
from qibo import gates
10
- from qibo .backends import get_backend
11
- from qibo .config import raise_error
10
+ from qibo .backends import construct_backend
12
11
from qibo .models import Circuit
13
12
from qibolab .platform import Platform
14
13
from qibolab .qubits import QubitId , QubitPairId
19
18
execute_transpiled_circuit ,
20
19
execute_transpiled_circuits ,
21
20
)
22
- from qibocal .config import raise_error
23
- from qibocal .protocols .randomized_benchmarking import noisemodels
24
21
from qibocal .protocols .randomized_benchmarking .dict_utils import (
25
22
SINGLE_QUBIT_CLIFFORDS_NAMES ,
26
23
calculate_pulses_clifford ,
@@ -118,7 +115,6 @@ def random_circuits(
118
115
targets : list [Union [QubitId , QubitPairId ]],
119
116
niter ,
120
117
rb_gen ,
121
- noise_model = None ,
122
118
inverse_layer = True ,
123
119
single_qubit = True ,
124
120
file_inv = pathlib .Path (),
@@ -134,8 +130,6 @@ def random_circuits(
134
130
if inverse_layer :
135
131
add_inverse_layer (circuit , rb_gen , single_qubit , file_inv )
136
132
add_measurement_layer (circuit )
137
- if noise_model is not None :
138
- circuit = noise_model .apply (circuit )
139
133
circuits .append (circuit )
140
134
indexes [target ].append (random_index )
141
135
@@ -341,30 +335,17 @@ def setup(
341
335
interleave : Optional [str ] = None ,
342
336
):
343
337
"""
344
- Set up the randomized benchmarking experiment backend, noise model and data class.
338
+ Set up the randomized benchmarking experiment backend and data class.
345
339
346
340
Args:
347
341
params (Parameters): The parameters for the experiment.
348
342
single_qubit (bool, optional): Flag indicating whether the experiment is for a single qubit or two qubits. Defaults to True.
349
343
interleave: (str, optional): The type of interleaving to apply. Defaults to None.
350
344
351
345
Returns:
352
- tuple: A tuple containing the experiment data, noise model, and backend.
346
+ tuple: A tuple containing the experiment data and backend.
353
347
"""
354
-
355
- backend = get_backend ()
356
- backend .platform = platform
357
- # For simulations, a noise model can be added.
358
- noise_model = None
359
- if params .noise_model is not None :
360
- if backend .name == "qibolab" :
361
- raise_error (
362
- ValueError ,
363
- "Backend qibolab (%s) does not perform noise models simulation. " ,
364
- )
365
-
366
- noise_model = getattr (noisemodels , params .noise_model )(params .noise_params )
367
- params .noise_params = noise_model .params .tolist ()
348
+ backend = construct_backend (backend = "qibolab" , platform = platform )
368
349
# Set up the scan (here an iterator of circuits of random clifford gates with an inverse).
369
350
if single_qubit :
370
351
cls = RBData
@@ -380,12 +361,10 @@ def setup(
380
361
niter = params .niter ,
381
362
)
382
363
383
- return data , noise_model , backend
364
+ return data , backend
384
365
385
366
386
- def get_circuits (
387
- params , targets , add_inverse_layer , interleave , noise_model , single_qubit = True
388
- ):
367
+ def get_circuits (params , targets , add_inverse_layer , interleave , single_qubit = True ):
389
368
"""
390
369
Generate randomized benchmarking circuits.
391
370
@@ -394,7 +373,6 @@ def get_circuits(
394
373
targets (list): List of target qubit IDs.
395
374
add_inverse_layer (bool): Flag indicating whether to add an inverse layer to the circuits.
396
375
interleave (str): String indicating whether to interleave the circuits with the given gate.
397
- noise_model (str): Noise model string.
398
376
single_qubit (bool, optional): Flag indicating whether to generate single qubit circuits.
399
377
400
378
Returns:
@@ -421,7 +399,6 @@ def get_circuits(
421
399
qubits_ids ,
422
400
params .niter ,
423
401
rb_gen ,
424
- noise_model ,
425
402
add_inverse_layer ,
426
403
single_qubit ,
427
404
inv_file ,
@@ -455,6 +432,7 @@ def execute_circuits(circuits, targets, params, backend, single_qubit=True):
455
432
456
433
"""
457
434
# Execute the circuits
435
+ platform = backend .platform
458
436
transpiler = dummy_transpiler (backend )
459
437
qubit_maps = (
460
438
[[i ] for i in targets ] * (len (params .depths ) * params .niter )
@@ -503,9 +481,9 @@ def rb_acquisition(
503
481
Returns:
504
482
RBData: The depths, samples, and ground state probability of each experiment in the scan.
505
483
"""
506
- data , noise_model , backend = setup (params , platform , single_qubit = True )
484
+ data , backend = setup (params , platform , single_qubit = True )
507
485
circuits , indexes , npulses_per_clifford = get_circuits (
508
- params , targets , add_inverse_layer , interleave , noise_model , single_qubit = True
486
+ params , targets , add_inverse_layer , interleave , single_qubit = True
509
487
)
510
488
executed_circuits = execute_circuits (circuits , targets , params , backend )
511
489
@@ -549,10 +527,10 @@ def twoq_rb_acquisition(
549
527
Returns:
550
528
RB2QData: The acquired data for two qubit randomized benchmarking.
551
529
"""
552
-
553
- data , noise_model , backend = setup (params , platform , single_qubit = False )
530
+ targets = [ tuple ( pair ) if isinstance ( pair , list ) else pair for pair in targets ]
531
+ data , backend = setup (params , platform , single_qubit = False )
554
532
circuits , indexes , npulses_per_clifford = get_circuits (
555
- params , targets , add_inverse_layer , interleave , noise_model , single_qubit = False
533
+ params , targets , add_inverse_layer , interleave , single_qubit = False
556
534
)
557
535
executed_circuits = execute_circuits (
558
536
circuits , targets , params , backend , single_qubit = False
0 commit comments