You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/quick_start/circuits/index.md
+45-2Lines changed: 45 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,8 +46,7 @@ While it is possible to write your own compiler passes and optimizations - for t
46
46
## Pick your backend: simulation and hardware
47
47
48
48
Once you have your program written and optimized to a point at which you are satisfied, it is time to think about execution.
49
-
Bloqade Digital is a hardware-first SDK, which means that simulation tries to mirror execution on hardware as closely as possible.
50
-
Choosing the hardware you want to run on is therefore mostly interchangeable with simulator backends.
49
+
51
50
52
51
### Simulation with PyQrack
53
52
@@ -66,6 +65,50 @@ There are also some things available in the simulator which cannot be obtained w
66
65
sim.state_vector(ghz, args=(4,))
67
66
```
68
67
68
+
### Simulation with STIM and TSIM
69
+
70
+
71
+
For QEC workflows, it may be required to sample millions or billions of shots from the same kernel.
72
+
For this, bloqade-circuit provides tight integration with the [STIM](https://github.com/quantumlib/Stim) and [TSIM](https://github.com/QuEraComputing/tsim) libraries.
73
+
74
+
STIM is a sampling simulator for Clifford circuits. TSIM is a sampling simulator for universal quantum circuits
75
+
that contain few non-Clifford gates. Both simulators support Pauli noise channels. TSIM optionally provides GPU acceleration. For more information, please refer to the [TSIM documentation](https://queracomputing.github.io/tsim/latest/).
76
+
77
+
To use these simulators, first instantiate a `Circuit` object from your kernel. Then compile the circuit into a sampler. This step enables efficient sampling of millions or billions of shots:
78
+
```python
79
+
from bloqade.tsim import Circuit
80
+
81
+
@squin.kernel
82
+
defmain():
83
+
q = squin.qalloc(2)
84
+
squin.h(q[0])
85
+
squin.t(q[0])
86
+
squin.broadcast.depolarize(0.01, q)
87
+
squin.cx(q[0], q[1])
88
+
bits = squin.broadcast.measure(q)
89
+
squin.set_detector(bits, coordinates=[0, 1])
90
+
squin.set_observable([bits[0]], idx=0)
91
+
92
+
93
+
circuit = Circuit(main)
94
+
sampler = circuit.compile_sampler()
95
+
sampler.sample(shots=1_000_000, batch_size=100_000) # On GPU, large batch size improves performance
96
+
```
97
+
98
+
TSIM and STIM provide two types of samplers that are created via the `compile_sampler` and `compile_detector_sampler` methods, respectively. The regular sampler ignores any `set_detector` and `set_observable` statements and returns measurement bits for each `measure` instruction in the order
99
+
of measurement. The detector sampler samples detector and observable bits.
A detailed tutorial of how to use TSIM for QEC workflows is available [here](https://bloqade.quera.com/latest/digital/examples/tsim/magic_state_distillation/).
0 commit comments