Closed IlanIwumbwe closed 2 months ago
Is the above the full code to reproduce? Running it works for me without error.
No, here is the updated code snippet:
main_circ = Circuit(2, 2, "main_circ")
a = Symbol("a")
s_map = {a : -0.5}
# Adding creg resources
creg_0 = main_circ.add_c_register("creg_0",2)
main_circ.Rz(1,0, condition = reg_eq(creg_0, 3))
main_circ.symbol_substitution(s_map)
main_circ.measure_all()
backend = AerBackend()
no_pass_circ = backend.get_compiled_circuit(main_circ, optimisation_level=0)
counts = backend.run_circuit(no_pass_circ).get_counts()
I think the bug here is that symbol_substitution()
is implemented thus for all ClassicalOp
types. But there is a whole hierarchy of types inheriting from ClassicalOp
, including RangePredicateOp
. So when we apply symbol_substitution
to those we just get a ClassicalOp
.
Ah, that makes sense. Thank you for the quick response.
Ah, that makes sense. Thank you for the quick response.
Thank you for raising the issue. Will work on a fix.
Benny and I found this by running a randomly generated circuit through the compiler.
Recreate with:
Results in:
When we remove the symbol substitution, the code runs. After closer inspection, we found that symbol substitution changes
Optype.RangePredicate
ops intoOptype.ClassicalOp
even though optype is still stated asOptype.RangePredicate
here