Stim Compiler¶
Pattern to stim compiler.
This module provides:
stim_compile: Function to compile a pattern into stim format.
- graphqomb.stim_compiler.stim_compile(pattern, *, emit_qubit_coords=True, noise_models=None, tick_duration=1.0)[source]¶
Compile a pattern to stim format.
- Parameters:
pattern (
Pattern) – The pattern to compile.emit_qubit_coords (
bool, optional) – Whether to emit QUBIT_COORDS instructions for nodes with coordinates, by default True.noise_models (
collections.abc.Sequence[NoiseModel] |None, optional) – Custom noise models for injecting Stim noise instructions, by default None. UseDepolarizingNoiseModelfor gate noise andMeasurementFlipNoiseModelfor measurement errors.tick_duration (
float, optional) – Duration associated with each TICK for idle noise, by default 1.0.
- Returns:
The compiled stim string.
- Return type:
Notes
Stim only supports Clifford gates, therefore this compiler only supports Pauli measurements (X, Y, Z basis) which correspond to Clifford operations. Non-Pauli measurements will raise a ValueError. Patterns containing X or Z correction commands will raise a NotImplementedError.
Examples
Basic compilation without noise:
>>> # stim_str = stim_compile(pattern)
With depolarizing and measurement flip noise:
>>> from graphqomb.noise_model import DepolarizingNoiseModel, MeasurementFlipNoiseModel >>> # stim_str = stim_compile( >>> # pattern, >>> # noise_models=[ >>> # DepolarizingNoiseModel(p1=0.001, p2=0.01), >>> # MeasurementFlipNoiseModel(p=0.001) >>> # ] >>> # )