Skip to content

Commit 702d133

Browse files
committed
Temporarily mark time-reversing feedback as not supported
Mitigates #764
1 parent fcf0949 commit 702d133

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

src/stim/util_top/circuit_inverse_qec.cc

+16-5
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ void CircuitFlowReverser::do_measuring_instruction(const CircuitInstruction &ins
124124
rev.undo_gate(inst);
125125
}
126126

127+
void CircuitFlowReverser::do_feedback_capable_instruction(const CircuitInstruction &inst) {
128+
for (GateTarget t : inst.targets) {
129+
if (t.is_measurement_record_target()) {
130+
throw std::invalid_argument("Time-reversing feedback isn't supported yet. Found feedback in: " + inst.str());
131+
}
132+
}
133+
rev.undo_gate(inst);
134+
}
135+
127136
void CircuitFlowReverser::do_simple_instruction(const CircuitInstruction &inst) {
128137
Gate g = GATE_DATA[inst.gate_type];
129138
rev.undo_gate(inst);
@@ -207,13 +216,8 @@ void CircuitFlowReverser::do_instruction(const CircuitInstruction &inst) {
207216
case GateType::ISWAP_DAG:
208217
case GateType::XCX:
209218
case GateType::XCY:
210-
case GateType::XCZ:
211219
case GateType::YCX:
212220
case GateType::YCY:
213-
case GateType::YCZ:
214-
case GateType::CX:
215-
case GateType::CY:
216-
case GateType::CZ:
217221
case GateType::H:
218222
case GateType::H_XY:
219223
case GateType::H_YZ:
@@ -229,6 +233,13 @@ void CircuitFlowReverser::do_instruction(const CircuitInstruction &inst) {
229233
case GateType::HERALDED_PAULI_CHANNEL_1:
230234
do_simple_instruction(inst);
231235
return;
236+
case GateType::XCZ:
237+
case GateType::YCZ:
238+
case GateType::CX:
239+
case GateType::CY:
240+
case GateType::CZ:
241+
do_feedback_capable_instruction(inst);
242+
break;
232243
case GateType::MRX:
233244
case GateType::MRY:
234245
case GateType::MR:

src/stim/util_top/circuit_inverse_qec_test.py

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
import stim
23

34

@@ -151,3 +152,14 @@ def test_measurement_ordering_3():
151152
assert circuit.has_all_flows(flows, unsigned=True)
152153
new_circuit, new_flows = circuit.time_reversed_for_flows(flows)
153154
assert new_circuit.has_all_flows(new_flows, unsigned=True)
155+
156+
157+
def test_feedback():
158+
c = stim.Circuit("""
159+
R 1
160+
M 1
161+
CX rec[-1] 0
162+
""")
163+
with pytest.raises(ValueError):
164+
c.time_reversed_for_flows([stim.Flow("Z0 -> Z0")])
165+
# TODO: once feedback is supported verify the inv flow is correct

0 commit comments

Comments
 (0)