CQCL / pytket-quantinuum

pytket-quantinuum, extensions for pytket quantum SDK
Apache License 2.0
25 stars 13 forks source link

Don't remove unused qubits in default compilation pass #116

Open cqc-alec opened 1 year ago

cqc-alec commented 1 year ago

This causes sometimes-surprising differences with other backends. To get around the problem of QASM insisting on contiguous zero-indexed registers, can we omit this step and relabel the qubits including the blank ones?

sjdilkes commented 1 year ago

This solution would mean we're rejecting valid Circuits that only need to call remove_blank_wires. The inconsistency Dan found is due to the stored Architecture referring to Node as "fcNode", while the current Quantinuum compilation both relabels them to "q", and doesn't update the Compilation maps to reflect this. Updating the connectivity graph generating Architecture classes to allow custom Node labelling https://github.com/CQCL/tket/pull/796 and moving the relabelling pass into the c++ to allow the maps to be updated https://github.com/CQCL/tket/pull/799 was my planned solution.

*The analogy I've been working with for removing wires is as with Routing for other algorithms, where we remove empty wires and add ancillas to find a good solution.

I think this works around Dan's problems sufficiently - but can update it to just not remove empty wires if that is preferred* though I don't think this is a better solution.

cqc-alec commented 1 year ago

I thought the issue was that Dan wants to run the default compilation pass on circuits that contain blank wires and for the result to still contain blank wires. However I'm not sure that's a reasonable request. Maybe having remove_blank_wires as an option defaulting to True would also work.

daniel-mills-cqc commented 1 year ago

Just to give my view as a user, there are a couple of themes which guide my requests:

I think maybe these both apply here? Many thanks for looking into this!