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
7 changes: 6 additions & 1 deletion src/stim/simulators/error_matcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,12 @@ void ErrorMatcher::err_heralded_pauli_channel_1(const CircuitInstruction &op) {
cur_loc.flipped_measurement.measurement_record_index = UINT64_MAX;

assert(error_analyzer.error_class_probabilities.empty());
error_analyzer.tracker.undo_gate(op);
error_analyzer.tracker.undo_gate(CircuitInstruction{
op.gate_type,
op.args,
op.targets.sub(k, k + 1),
op.tag,
});
error_analyzer.mono_buf.clear();
error_analyzer.error_class_probabilities.clear();
error_analyzer.flushed_reversed_model.clear();
Expand Down
60 changes: 60 additions & 0 deletions src/stim/simulators/error_matcher.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -549,3 +549,63 @@ ExplainedError {
}
)RESULT");
}

TEST(ErrorMatcher, heralded_error) {
Circuit circuit(R"CIRCUIT(
HERALDED_ERASE(0.01) 0
DETECTOR rec[-1]
HERALDED_ERASE(0.01) 1 2
)CIRCUIT");
DetectorErrorModel filter(R"MODEL(
error(1) D0
)MODEL");

auto actual = ErrorMatcher::explain_errors_from_circuit(
circuit,
&filter,
false);
std::stringstream ss;
for (const auto &match : actual) {
ss << "\n" << match << "\n";
}
ASSERT_EQ(ss.str(), R"RESULT(
ExplainedError {
dem_error_terms: D0
CircuitErrorLocation {
flipped_measurement.measurement_record_index: 0
Circuit location stack trace:
(after 0 TICKs)
at instruction #1 (HERALDED_ERASE) in the circuit
at target #1 of the instruction
resolving to HERALDED_ERASE(0.01) 0
}
CircuitErrorLocation {
flipped_pauli_product: X0
flipped_measurement.measurement_record_index: 0
Circuit location stack trace:
(after 0 TICKs)
at instruction #1 (HERALDED_ERASE) in the circuit
at target #1 of the instruction
resolving to HERALDED_ERASE(0.01) 0
}
CircuitErrorLocation {
flipped_pauli_product: Y0
flipped_measurement.measurement_record_index: 0
Circuit location stack trace:
(after 0 TICKs)
at instruction #1 (HERALDED_ERASE) in the circuit
at target #1 of the instruction
resolving to HERALDED_ERASE(0.01) 0
}
CircuitErrorLocation {
flipped_pauli_product: Z0
flipped_measurement.measurement_record_index: 0
Circuit location stack trace:
(after 0 TICKs)
at instruction #1 (HERALDED_ERASE) in the circuit
at target #1 of the instruction
resolving to HERALDED_ERASE(0.01) 0
}
}
)RESULT");
}
Loading