Closed woodsp-ibm closed 8 months ago
It's almost certainly related - I'll have to do a little digging and see what's going on, but I feel like I saw something similar while initially making the change, which I started before algorithms was removed. I assumed I'd fixed all of those issues, but I can look into it.
Ok, one bug is in QuantumCircuit.remove_final_measurements
, which I could have sworn I fixed, but maybe got lost in a rebase. That's fixed in #11455.
The other is in BlueprintCircuit.copy
, or perhaps more completely, it's because the data model and principle of BlueprintCircuit
is at best flawed, and at worst just invalid. It's totally unreliable to append to, or generally otherwise mutate a BlueprintCircuit
(which the algorithms tests do), but that's something that people try all the time, because there's no indication that you can't. Any time something does something that BlueprintCircuit
considers a "modification", it invalidates itself, which involves scrubbing (some of) its state. In this case, the part of QuantumCircuit.copy_empty_like
that refreshes the qregs
list is counted as a modification, so BlueprintCircuit
scrubs itself, including zeroing out the global phase, but copy_empty_like
doesn't know that it's done that (nor should it need to know), so it doesn't restore it. This will have been zeroing the global phase out before #11428, but that PR caused it to get noticed. I've put in an override of QuantumCircuit.copy_empty_like
in #11456, but this won't be the last time we find some weirdness where BlueprintCircuit
is invalidating itself and throwing away data.
Which BlueprintCircuit
classes are most commonly used in the algorithms? For instance, in #11463 I am adding QftGate
class that should in principle replace the QFT
bluecircuit class.
Sasha: in my informal survey, it's like 90% NLocal
and subclasses like RealAmplitudes
. Those could have probably been factory functions for regular QuantumCircuit
instances, or potentially very simple subclasses adding an extra attribute, but I think the ship has sailed on that for Qiskit 1.0.
Qiskit Algorithms runs a couple of CI jobs against the main branch here to keep an eye on ongoing changes here. Last nights CI nightly run failed https://github.com/qiskit-community/qiskit-algorithms/actions/runs/7282997053/job/19846228142 Could this be related to #11428 ? @jakelishman