@@ -196,7 +196,8 @@ def propagate_errorgens(self, circuit, multi_gate_dict=None, include_spam=True):
196
196
return propagated_errorgen_layers
197
197
198
198
199
- def propagate_errorgens_bch (self , circuit , bch_order = 1 , bch_layerwise = False , multi_gate_dict = None ):
199
+ def propagate_errorgens_bch (self , circuit , bch_order = 1 , bch_layerwise = False , multi_gate_dict = None ,
200
+ include_spam = True ):
200
201
"""
201
202
Propagate all of the error generators for each circuit to the end,
202
203
performing approximation/recombination either along the way (layerwise)
@@ -222,6 +223,10 @@ def propagate_errorgens_bch(self, circuit, bch_order=1, bch_layerwise=False, mul
222
223
multi_gate_dict : dict, optional (default None)
223
224
An optional dictionary mapping between gate name aliases and their
224
225
standard name counterparts.
226
+
227
+ include_spam : bool, optional (default True)
228
+ If True then we include in the propagation the error generators associated
229
+ with state preparation and measurement.
225
230
"""
226
231
227
232
msg = 'When bch_layerwise is True this can take the values of either 1 or 2.' \
@@ -235,13 +240,14 @@ def propagate_errorgens_bch(self, circuit, bch_order=1, bch_layerwise=False, mul
235
240
236
241
#if not doing layerwise BCH then we can re-use `propagate_errorgens` fully.
237
242
if not bch_layerwise :
238
- propagated_errorgen_layers = self .propagate_errorgens (circuit , multi_gate_dict )
243
+ propagated_errorgen_layers = self .propagate_errorgens (circuit , multi_gate_dict ,
244
+ include_spam = include_spam )
239
245
#otherwise we need to do the error generator layer propagation slightly
240
246
#differently.
241
247
else :
242
248
#start by converting the input circuit into a list of stim Tableaus with the
243
249
#first element dropped.
244
- stim_layers = self .construct_stim_layers (circuit , multi_gate_dict , drop_first_layer = True )
250
+ stim_layers = self .construct_stim_layers (circuit , multi_gate_dict , drop_first_layer = not include_spam )
245
251
246
252
#We next want to construct a new set of Tableaus corresponding to the cumulative products
247
253
#of each of the circuit layers with those that follow. These Tableaus correspond to the
@@ -253,11 +259,12 @@ def propagate_errorgens_bch(self, circuit, bch_order=1, bch_layerwise=False, mul
253
259
#to the error generators for a particular gate layer.
254
260
#TODO: Add proper inferencing for number of qubits:
255
261
assert circuit .line_labels is not None and circuit .line_labels != ('*' ,)
256
- errorgen_layers = self .construct_errorgen_layers (circuit , len (circuit .line_labels ))
262
+ errorgen_layers = self .construct_errorgen_layers (circuit , len (circuit .line_labels ), include_spam )
257
263
258
264
#propagate the errorgen_layers through the propagation_layers to get a list
259
265
#of end of circuit error generator dictionaries.
260
- propagated_errorgen_layers = self ._propagate_errorgen_layers_bch (errorgen_layers , propagation_layers )
266
+ propagated_errorgen_layers = self ._propagate_errorgen_layers_bch (errorgen_layers , propagation_layers ,
267
+ include_spam = include_spam )
261
268
262
269
return propagated_errorgen_layers
263
270
@@ -527,7 +534,7 @@ def _propagate_errorgen_layers(self, errorgen_layers, propagation_layers, includ
527
534
return fully_propagated_layers
528
535
529
536
#TODO: Add an option to return the results with the different BCH order combined.
530
- def _propagate_errorgen_layers_bch (self , errorgen_layers , propagation_layers , bch_order = 1 ):
537
+ def _propagate_errorgen_layers_bch (self , errorgen_layers , propagation_layers , bch_order = 1 , include_spam = True ):
531
538
"""
532
539
Propagates the error generator layers through each of the corresponding propagation layers
533
540
(i.e. the clifford operations for the remainder of the circuit). In this version we
@@ -551,6 +558,11 @@ def _propagate_errorgen_layers_bch(self, errorgen_layers, propagation_layers, bc
551
558
bch_order : int, optional (default 1)
552
559
Order of the BCH approximation to use.
553
560
561
+ include_spam : bool, optional (default True)
562
+ If True then include the error generators for state preparation and measurement
563
+ are included in errogen_layers, and the state preparation error generator should
564
+ be propagated through (the measurement one is simply appended at the end).
565
+
554
566
Returns
555
567
-------
556
568
@@ -570,7 +582,14 @@ def _propagate_errorgen_layers_bch(self, errorgen_layers, propagation_layers, bc
570
582
if len (errorgen_layers )> 0 :
571
583
combined_err_layer = errorgen_layers [0 ]
572
584
573
- for i in range (len (errorgen_layers )- 1 ):
585
+ #the stopping index in errorgen_layers will depend on whether the measurement error
586
+ #generator is included or not.
587
+ if include_spam :
588
+ stopping_idx = len (errorgen_layers )- 2
589
+ else :
590
+ stopping_idx = len (errorgen_layers )- 1
591
+
592
+ for i in range (stopping_idx ):
574
593
#err_layer = errorgen_layers[i]
575
594
prop_layer = propagation_layers [i ]
576
595
new_err_layer = []
0 commit comments