Stim Simulation#
- stimulate(func=None)[source]#
This function leverages the Stim simulator to evaluate a Jasp-traceable function containing only Clifford gates. Stim is a popular tool to simulate quantum error correction codes.
Note
To use this simulator, you need stim installed, which can be achieved via
pip install stim
.- Parameters:
- funccallable
The function to simulate.
- Returns:
- callable
A function performing the simulation.
Examples
We simulate a function creating a simple GHZ state:
from qrisp import * from qrisp.jasp import * @stimulate def main(): qf = QuantumFloat(5) h(qf[0]) for i in range(1, 5): cx(qf[0], qf[i]) return measure(qf) print(main()) # Yields either 0 or 31
The
stimulate
decorator can also simulate real-time features:@stimulate def main(): qf = QuantumFloat(5) h(qf[0]) cl_bl = measure(qf[0]) with control(cl_bl): for i in range(1, 5): x(qf[i]) return measure(qf) print(main()) # Yields either 0 or 31