Open braised-babbage opened 3 years ago
This is a good point; I agree there's no reason to rush to fix. (However, it's nice when you can depend on certain invariants being true; if I was a new programmer on the QUILC project and I had to hack on the logical scheduler, I'd perhaps assume that such extra links wouldn't exist, which means I might inadvertently write subtly buggy code.)
Consider the following program
Naively, one would expect that the dependency graph of these instructions looks like this:
but, if we construct a logical schedule with these instructions, we see something like
Concretely, what I am showing comes from the following
with the links representing the
earlier
relation.The extra link is superfluous (since the dependency between
CNOT 1 2
andCNOT 0 1
is already mediated byX 1
), and makes the lscheduler behavior just a bit more confusing than need be. The reason it comes about is evident in the source for append-instruction-to-logical-schedule, since at the point at whichCNOT 1 2
is appended, bothX 1
andCNOT 0 1
are considered to the bottom. A fix would involve tracking how the bottom instructions partition the set of resources, so that e.g. qubit 1 is considered "owned" byX 1
rather than bothX 1
andCNOT 0 1
.IMO, this is not a "real" problem, and probably not worth changing right now as a standalone fix, since the logical scheduling stuff works fine as a whole. It should be kept in mind if we ever do a more serious refactor of the logical scheduling code.