{"id":7758,"library":"stim","title":"Stim: Quantum Stabilizer Circuits","description":"Stim is a fast Python library for high-performance simulation and analysis of quantum stabilizer circuits, particularly those used in quantum error correction (QEC). It focuses on providing low-level, fast building blocks for simulating circuits with thousands of qubits and millions of operations, enabling rapid Monte Carlo sampling. The library maintains a regular release cadence, with minor versions typically released every few months, ensuring active development and improvements.","status":"active","version":"1.15.0","language":"python","source_language":"en","source_url":"https://github.com/quantumlib/stim","tags":["quantum computing","quantum error correction","stabilizer codes","simulation","QEC"],"install":[{"cmd":"pip install stim","lang":"bash","label":"Install Stim"}],"dependencies":[{"reason":"Commonly used for decoding Detector Error Models generated by Stim.","package":"pymatching","optional":true}],"imports":[{"symbol":"Circuit","correct":"from stim import Circuit"},{"symbol":"TableauSimulator","correct":"from stim import TableauSimulator"},{"symbol":"PauliString","correct":"from stim import PauliString"},{"symbol":"DetectorErrorModel","correct":"from stim import DetectorErrorModel"}],"quickstart":{"code":"import stim\n\n# Create a quantum circuit\ncircuit = stim.Circuit()\ncircuit.append(\"H\", [0])\ncircuit.append(\"CNOT\", [0, 1])\ncircuit.append(\"M\", [0, 1])\n\n# Compile a sampler for the circuit\nsampler = circuit.compile_sampler()\n\n# Sample measurement shots\nshots = sampler.sample(shots=10)\n\nprint(\"Circuit:\\n\", circuit)\nprint(\"Sampled shots (first 5):\\n\", shots[:5])\n\n# Example of adding noise and extracting a detector error model\nnoisy_circuit = stim.Circuit()\nnoisy_circuit.append(\"H\", [0])\nnoisy_circuit.append(\"DEPOLARIZE1(0.001)\", [0])\nnoisy_circuit.append(\"CNOT\", [0, 1])\nnoisy_circuit.append(\"DEPOLARIZE2(0.002)\", [0, 1])\nnoisy_circuit.append(\"M\", [0, 1])\nnoisy_circuit.append(\"DETECTOR\", [0]) # Add a simple detector at qubit 0\n\ndem = noisy_circuit.detector_error_model()\nprint(\"\\nDetector Error Model (first few lines):\\n\", str(dem).splitlines()[0:5])","lang":"python","description":"This quickstart demonstrates how to create a basic quantum circuit, add gates, compile a sampler for efficient measurement shot generation, and extract a detector error model from a noisy circuit. The example includes fundamental operations and a simple noise model."},"warnings":[{"fix":"Explicitly set `ignore_ungraphlike_errors=False` if you require the old behavior, or review your logic to account for the new default.","message":"The default value for `ignore_ungraphlike_errors` in `stim.DetectorErrorModel.shortest_graphlike_error` changed from `False` to `True` in v1.11.0. This means the method will now ignore ungraphlike errors by default, which may change behavior for existing code.","severity":"breaking","affected_versions":">=1.11.0"},{"fix":"Ensure all operations involving `\"ptb64\"` format data handle shot counts that are exact multiples of 64.","message":"When reading or writing data using the `\"ptb64\"` format, the shot count is strictly required to be a multiple of 64 since v1.9.0. Previously, missing shots might have been padded.","severity":"breaking","affected_versions":">=1.9.0"},{"fix":"When interacting with Stim's C++ components directly, always pin to a specific Stim version and be prepared for API changes with updates. For stability, use the Python API.","message":"Stim's C++ API makes no compatibility guarantees and may change arbitrarily and catastrophically between minor versions. Only the Python API and command-line API promise backwards compatibility within major versions.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to Stim v1.12.1 or newer to ensure correct behavior of `HERALDED_PAULI_CHANNEL_1`. If using older versions, thoroughly validate circuits involving this gate. [cite: -Github release v1.12.1]","message":"The `HERALDED_PAULI_CHANNEL_1` gate had a bug prior to v1.12.1 where it targeted fixed indices instead of the given qubits. This could lead to incorrect simulation results without explicit error messages.","severity":"gotcha","affected_versions":"<1.12.1"},{"fix":"For advanced noise or feedback scenarios, use `stim.TableauSimulator` and implement custom logic for state evolution.","message":"Stim's `Circuit` class primarily supports Pauli noise channels and single-control Pauli feedback. For more complex noise models (e.g., amplitude decay) or multi-control feedback, you must manually drive a `stim.TableauSimulator`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'activ':72 'analysi':17 'block':39 'build':38 'cadenc':62 'carlo':54 'circuit':4,21,42 'code':82 'comput':77 'correct':28,80 'develop':73 'enabl':51 'ensur':71 'error':27,79 'everi':68 'fast':8,37 'focus':31 'high':13 'high-perform':12 'improv':75 'level':36 'librari':10,57 'low':35 'low-level':34 'maintain':58 'million':48 'minor':64 'mont':53 'month':70 'oper':50 'particular':22 'perform':14 'provid':33 'python':9 'qec':29,84 'quantum':2,19,26,76,78 'qubit':46 'rapid':52 'regular':60 'releas':61,67 'sampl':55 'simul':15,41,83 'stabil':3,20,81 'stim':1,5 'thousand':44 'typic':66 'use':24 'version':65","created_at":"2026-04-16T14:12:07.565504+00:00","updated_at":"2026-04-16T14:12:07.565504+00:00","problems":[{"fix":"Install Stim using pip: `pip install stim`","cause":"The Stim library is not installed in the current Python environment, or the environment is not active.","error":"ModuleNotFoundError: No module named 'stim'"},{"fix":"Adjust the `shots` parameter to be a multiple of 64. For example, `sampler.sample(shots=128, format='ptb64')`.","cause":"When reading or writing measurement results using the 'ptb64' format (e.g., with `Circuit.compile_sampler().sample(..., format='ptb64')`), the number of shots provided is not a multiple of 64.","error":"ValueError: shot_count must be a multiple of 64 for 'ptb64' format."},{"fix":"Consult the Stim documentation for the specific gate's target format. For single-qubit gates, pass qubits individually (e.g., `circuit.append(\"H\", [0]); circuit.append(\"H\", [1])`) or as separate entries. For multi-qubit gates, ensure the list format matches (e.g., `circuit.append(\"CNOT\", [0, 1])`).","cause":"An incorrect number or type of targets was provided for a gate. For example, applying a single-qubit gate like 'H' to multiple qubits in a single instruction when it expects a list of individual qubit targets.","error":"TypeError: Cannot apply H to qubit 0 1: expected a single qubit target or a list of single qubit targets, not a list of 2 targets"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.16.0","cli_name":"stim","cli_version":"Aborted (core dumped)","type":"library","homepage":null,"github":"https://github.com/quantumlib/stim","docs":null,"changelog":null,"pypi":"https://pypi.org/project/stim/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}