Skip to content

Cannot get detector error model from tsim circuit #168

@jon-wurtz

Description

@jon-wurtz
from bloqade.lanes import GeminiLogicalSimulator

# Dialect groups
from bloqade.gemini import logical
from bloqade import qubit, squin

@logical.kernel(aggressive_unroll=True, verify=True)
def main():
    reg = qubit.qalloc(3)
    squin.h(reg[0])
    squin.cx(reg[0], reg[1])
    return logical.default_post_processing(reg)
task = GeminiLogicalSimulator().task(main)
print(task.tsim_circuit.detector_error_model())

raises (in vscode jupyter notebook, python file.py and an ide)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[8], [line 18](vscode-notebook-cell:?execution_count=8&line=18)
     14 
     15 
     16 task = GeminiLogicalSimulator().task(main)
     17 
---> [18](vscode-notebook-cell:?execution_count=8&line=18) print(task.tsim_circuit.detector_error_model())

File ~/PATH/TO/.venv/lib/python3.13/site-packages/tsim/circuit.py:535, in Circuit.detector_error_model(self, decompose_errors, flatten_loops, allow_gauge_detectors, approximate_disjoint_errors, ignore_decomposition_failures, block_decomposition_from_introducing_remnant_edges)
    466 def detector_error_model(
    467     self,
    468     *,
   (...)    474     block_decomposition_from_introducing_remnant_edges: bool = False,
    475 ) -> stim.DetectorErrorModel:
    476     """Return a stim.DetectorErrorModel describing the error processes in the circuit.
    477 
    478     Unlike the stim.Circuit.detector_error_model() method, this method allows for non-deterministic observables
   (...)    533 
    534     """
--> [535](https://file+.vscode-resource.vscode-cdn.net/PATH/TO/.venv/lib/python3.13/site-packages/tsim/circuit.py:535)     return get_detector_error_model(
    536         self._stim_circ,
    537         allow_non_deterministic_observables=True,
    538         decompose_errors=decompose_errors,
    539         flatten_loops=flatten_loops,
    540         allow_gauge_detectors=allow_gauge_detectors,
    541         approximate_disjoint_errors=approximate_disjoint_errors,
    542         ignore_decomposition_failures=ignore_decomposition_failures,
    543         block_decomposition_from_introducing_remnant_edges=block_decomposition_from_introducing_remnant_edges,
    544     )

File ~/PATH/TO/.venv/lib/python3.13/site-packages/tsim/noise/dem.py:149, in get_detector_error_model(stim_circuit, allow_non_deterministic_observables, decompose_errors, flatten_loops, allow_gauge_detectors, approximate_disjoint_errors, ignore_decomposition_failures, block_decomposition_from_introducing_remnant_edges)
    146     mapping[num_detectors] = idx
    147     num_detectors += 1
--> [149](https://file+.vscode-resource.vscode-cdn.net/PATH/TO/.venv/lib/python3.13/site-packages/tsim/noise/dem.py:149) dem = new_circuit.detector_error_model(
    150     allow_gauge_detectors=True,
    151     decompose_errors=decompose_errors,
    152     flatten_loops=flatten_loops,
    153     approximate_disjoint_errors=approximate_disjoint_errors,
    154     ignore_decomposition_failures=ignore_decomposition_failures,
    155     block_decomposition_from_introducing_remnant_edges=block_decomposition_from_introducing_remnant_edges,
    156 )
    158 new_dem = stim.DetectorErrorModel()
    160 for instruction in dem:

ValueError: Encountered the operation PAULI_CHANNEL_2 during error analysis, but this operation requires the `approximate_disjoint_errors` option to be enabled.
If you're calling from python, using stim.Circuit.detector_error_model, you need to add the argument approximate_disjoint_errors=True.

If you're calling from the command line, you need to specify --approximate_disjoint_errors.

Circuit stack trace:
    at instruction #142 [which is PAULI_CHANNEL_2(0.00022747, 0.00022747, 0.00151278, 0.00022747, 0.00014286, 0.00014286, 0.00014308, 0.00022747, 0.00014286, 0.00014286, 0.00014308, 0.00151278, 0.00014308, 0.00014308, 0.00142814) 0 7 1 8 2 9 3 10 4 11 5 12 6 13]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions