Repository navigation
Unable to create the decoder for Y noise modelled using PAULI_CHANNEL_1(0, p, 0) #175
Copy link
Copy link
Closed
Description
When I use the following script, adapted from the README to only add data qubit Y error modelled using the PAULI_CHANNEL_1 instruction from stim, the script seg-faults occasionally when creating the decoder object with correlations enabled.
- If correlations are turned off, there are no segmentation faults.
- When correlations are turned on, if
p_xis set very small like1e-15, the decoder creation doesn't seg-fault - Same behavior repeated across Mac and Ubuntu mcahines
- Also happens if I set
approximate_disjoint_errors=False
Is this expected behavior for correlated matching? If yes, then it would be nice to throw an error that this is cannot be supported.
Script
import numpy as np
import stim
import pymatching
distance = 5
p = 0.1
circuit = stim.Circuit.generated(
"surface_code:rotated_memory_x",
distance=7,
rounds=7,
before_round_data_depolarization=p
)
circ_str = circuit.__str__()
circ_str = circ_str.replace(f"DEPOLARIZE1({p})", f"PAULI_CHANNEL_1(0, {p}, 0)")
stim_direct = stim.Circuit(circ_str)
model = stim_direct.detector_error_model(decompose_errors=True, approximate_disjoint_errors=True)
print("created DEM succesfully")
matching = pymatching.Matching.from_detector_error_model(model, enable_correlations=True)
print("created matching")
sampler = stim_direct.compile_detector_sampler()
syndrome, actual_observables = sampler.sample(shots=1000, separate_observables=True)
predicted_observables_corr = matching.decode_batch(syndrome, enable_correlations=True)
num_errors = np.sum(np.any(predicted_observables_corr != actual_observables, axis=1))
print(num_errors) Traceback with 4 consecutive runs
external/test-env via 🐍 v3.13.4 (.venv) on ☁️ varun took 37s
❯ python matching.py
created DEM succesfully
created matching
339
external/test-env via 🐍 v3.13.4 (.venv) on ☁️ varun
❯ python matching.py
created DEM succesfully
created matching
329
external/test-env via 🐍 v3.13.4 (.venv) on ☁️ varun
❯ python matching.py
created DEM succesfully
[1] 49910 segmentation fault python matching.py
external/test-env via 🐍 v3.13.4 (.venv) on ☁️ varun
❯ python matching.py
created DEM succesfully
Traceback (most recent call last):
File "/Users/varunseshadri/repos/external/test-env/matching.py", line 22, in <module>
matching = pymatching.Matching.from_detector_error_model(model, enable_correlations=True)
File "/Users/varunseshadri/repos/external/test-env/.venv/lib/python3.13/site-packages/pymatching/matching.py", line 1295, in from_detector_error_model
m._load_from_detector_error_model(model, enable_correlations=enable_correlations)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/varunseshadri/repos/external/test-env/.venv/lib/python3.13/site-packages/pymatching/matching.py", line 1407, in _load_from_detector_error_model
self._matching_graph = _cpp_pm.detector_error_model_to_matching_graph(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
str(model), enable_correlations=enable_correlations
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
ValueError: vector
Doing this removed the seg-faults,
-circ_str = circ_str.replace(f"DEPOLARIZE1({p})", f"PAULI_CHANNEL_1(0, {p}, 0)")
+circ_str = circ_str.replace(f"DEPOLARIZE1({p})", f"PAULI_CHANNEL_1(1e-15, {p}, 0)")Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
Handle boundary edge components and refactor `iter_dem_instructions_i…
oscarhiggott commentedon Sep 25, 2025
This issue has now been fixed in PR #171 and this fix is included in the newly release pymatching v2.3.1. I checked that this does remove the issue in the code snippet you shared, but let me know if you still encounter any issues with the new release!
isolatedinformation commentedon Sep 26, 2025
Thanks, it works now :)