File tree 2 files changed +28
-5
lines changed
2 files changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,15 @@ void CircuitFlowReverser::do_measuring_instruction(const CircuitInstruction &ins
124
124
rev.undo_gate (inst);
125
125
}
126
126
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
+
127
136
void CircuitFlowReverser::do_simple_instruction (const CircuitInstruction &inst) {
128
137
Gate g = GATE_DATA[inst.gate_type ];
129
138
rev.undo_gate (inst);
@@ -207,13 +216,8 @@ void CircuitFlowReverser::do_instruction(const CircuitInstruction &inst) {
207
216
case GateType::ISWAP_DAG:
208
217
case GateType::XCX:
209
218
case GateType::XCY:
210
- case GateType::XCZ:
211
219
case GateType::YCX:
212
220
case GateType::YCY:
213
- case GateType::YCZ:
214
- case GateType::CX:
215
- case GateType::CY:
216
- case GateType::CZ:
217
221
case GateType::H:
218
222
case GateType::H_XY:
219
223
case GateType::H_YZ:
@@ -229,6 +233,13 @@ void CircuitFlowReverser::do_instruction(const CircuitInstruction &inst) {
229
233
case GateType::HERALDED_PAULI_CHANNEL_1:
230
234
do_simple_instruction (inst);
231
235
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 ;
232
243
case GateType::MRX:
233
244
case GateType::MRY:
234
245
case GateType::MR:
Original file line number Diff line number Diff line change
1
+ import pytest
1
2
import stim
2
3
3
4
@@ -151,3 +152,14 @@ def test_measurement_ordering_3():
151
152
assert circuit .has_all_flows (flows , unsigned = True )
152
153
new_circuit , new_flows = circuit .time_reversed_for_flows (flows )
153
154
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
You can’t perform that action at this time.
0 commit comments