Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/pymatching/sparse_blossom/driver/user_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,12 @@ void iter_dem_instructions_include_correlations(
"Encountered a decomposed error instruction with an undetectable component (0 detectors). "
"This is not supported.");
} else if (num_component_detectors > 0) {
// If the previous error in the decomposition had 1 or 2 detectors, we handle it
handle_dem_error(p, {component->node1, component->node2}, component->observable_indices);
// If the previous error in the decomposition had 1 or 2 detectors, we handle it.
if (component->node2 == SIZE_MAX) {
handle_dem_error(p, {component->node1}, component->observable_indices);
} else {
handle_dem_error(p, {component->node1, component->node2}, component->observable_indices);
}
decomposed_err.components.push_back({});
component = &decomposed_err.components.back();
component->node1 = SIZE_MAX;
Expand Down
20 changes: 20 additions & 0 deletions tests/matching/decode_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,26 @@ def test_decode_to_edges_with_correlations():
assert np.array_equal(edges, expected_edges)


def test_correlated_matching_handles_single_detector_components():
stim = pytest.importorskip("stim")
p = 0.1
circuit = stim.Circuit.generated(
code_task="surface_code:rotated_memory_x",
distance=5,
rounds=5,
before_round_data_depolarization=p,
)
circ_str = str(circuit).replace(
f"DEPOLARIZE1({p})", f"PAULI_CHANNEL_1(0, {p}, 0)"
)
noisy_circuit = stim.Circuit(circ_str)
dem = noisy_circuit.detector_error_model(
decompose_errors=True, approximate_disjoint_errors=True
)
m = Matching.from_detector_error_model(dem, enable_correlations=True)
assert m.num_detectors > 0


def test_load_from_circuit_with_correlations():
stim = pytest.importorskip("stim")
circuit = stim.Circuit.generated(
Expand Down