@@ -27,6 +27,7 @@ API references for stable versions are kept on the [stim github wiki](https://gi
27
27
- [ ` stim.Circuit.compile_sampler ` ] ( #stim.Circuit.compile_sampler )
28
28
- [ ` stim.Circuit.copy ` ] ( #stim.Circuit.copy )
29
29
- [ ` stim.Circuit.count_determined_measurements ` ] ( #stim.Circuit.count_determined_measurements )
30
+ - [ ` stim.Circuit.decomposed ` ] ( #stim.Circuit.decomposed )
30
31
- [ ` stim.Circuit.detecting_regions ` ] ( #stim.Circuit.detecting_regions )
31
32
- [ ` stim.Circuit.detector_error_model ` ] ( #stim.Circuit.detector_error_model )
32
33
- [ ` stim.Circuit.diagram ` ] ( #stim.Circuit.diagram )
@@ -1273,6 +1274,78 @@ def count_determined_measurements(
1273
1274
"""
1274
1275
```
1275
1276
1277
+ <a name =" stim.Circuit.decomposed " ></a >
1278
+ ``` python
1279
+ # stim.Circuit.decomposed
1280
+
1281
+ # (in class stim.Circuit)
1282
+ def decomposed (
1283
+ self ,
1284
+ ) -> stim.Circuit:
1285
+ """ Recreates the circuit using (mostly) the {H,S,CX,M,R} gate set.
1286
+
1287
+ The intent of this method is to simplify the circuit to use fewer gate types,
1288
+ so it's easier for other tools to consume. Currently, this method performs the
1289
+ following simplifications:
1290
+
1291
+ - Single qubit cliffords are decomposed into {H,S}.
1292
+ - Multi-qubit cliffords are decomposed into {H,S,CX}.
1293
+ - Single qubit dissipative gates are decomposed into {H,S,M,R}.
1294
+ - Multi-qubit dissipative gates are decomposed into {H,S,CX,M,R}.
1295
+
1296
+ Currently, the following types of gate *aren't* simplified, but they may be
1297
+ in the future:
1298
+
1299
+ - Noise instructions (like X_ERROR, DEPOLARIZE2, and E).
1300
+ - Annotations (like TICK, DETECTOR, and SHIFT_COORDS).
1301
+ - The MPAD instruction.
1302
+ - Repeat blocks are not flattened.
1303
+
1304
+ Returns:
1305
+ A `stim.Circuit` whose function is equivalent to the original circuit,
1306
+ but with most gates decomposed into the {H,S,CX,M,R} gate set.
1307
+
1308
+ Examples:
1309
+ >>> import stim
1310
+
1311
+ >>> stim.Circuit('''
1312
+ ... SWAP 0 1
1313
+ ... ''').decomposed()
1314
+ stim.Circuit('''
1315
+ CX 0 1 1 0 0 1
1316
+ ''')
1317
+
1318
+ >>> stim.Circuit('''
1319
+ ... ISWAP 0 1 2 1
1320
+ ... TICK
1321
+ ... MPP !X1*Y2*Z3
1322
+ ... ''').decomposed()
1323
+ stim.Circuit('''
1324
+ H 0
1325
+ CX 0 1 1 0
1326
+ H 1
1327
+ S 1 0
1328
+ H 2
1329
+ CX 2 1 1 2
1330
+ H 1
1331
+ S 1 2
1332
+ TICK
1333
+ H 1 2
1334
+ S 2
1335
+ H 2
1336
+ S 2 2
1337
+ CX 2 1 3 1
1338
+ M !1
1339
+ CX 2 1 3 1
1340
+ H 2
1341
+ S 2
1342
+ H 2
1343
+ S 2 2
1344
+ H 1
1345
+ ''')
1346
+ """
1347
+ ```
1348
+
1276
1349
<a name =" stim.Circuit.detecting_regions " ></a >
1277
1350
``` python
1278
1351
# stim.Circuit.detecting_regions
0 commit comments