Closed cqc-alec closed 3 weeks ago
I've only left a couple of comments - looks nice and clean. Could it be worth adding tests covering some of the strange behaviour from
ClassicalExpBox
, such as having classical expressions inCircBox
that are copied, or python circuits that have classical expressions added, the units relabelled and then converted to qasm to confirm that the expressions are as desired?
Good idea, I'll add some such tests.
Exciting, LGTM! So I could submit jobs to
QuantinuumBackend
withqasm
conversion andClExpr
now and it should work?
Yes I believe that should work. Note that there is not yet a version of DecomposeClassicalExp
that works with ClExpr
, but that should not be needed in many cases.
This is the first stage of
ClassicalExpBox
refactoring: defining a new operation type (ClExprOp
) to replace it. This is defined in C++ with Python bindings, and is independent of bit and register names (information about which variable corresponds to which input etc. is encoded in theOp
).This PR also implements QASM conversion to and from the new op, but for QASM-to-circuit conversion this is not the default: a new boolean argument for
circuit_from_qasm
and friends is added to control this. This is so as not to break current workflows that rely on pytket-to-X conversions that don't currently handle theClExprOp
. After this is in a release we will update pytket-qir, pytket-phir and any other relevant extensions to handle the new type; after that we can update tket to use it everywhere by default, write a new decomposer pass for it, and deprecateClassicalExpBox
.PS The Nix build failure is expected because it is using an older mypy version.