-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
What should we add?
ConsolidateBlocks
has some logic for choosing whether to collapse some blocks into a UnitaryGate. But this is pretty outdated by now. It basically checks whether number of gates in the decomposition improves. First, number of gates is not necessarily important, but rather the error is. Second, it does not currently deal with multiple (heterogeneous) possible decompositions.
But all of this is implemented correctly in UnitarySynthesis (at least for 2q blocks). So ConsolidateBlocks should just defer to UnitarySynthesis for when and how to resynthesize a sequence of 2q gates. All of its decomposition considerations should come from UnitarySynthesis.
I think it is better to write a new pass PeepholeUnitaryResynthesis
, which does all 3 of these actions: Collect2QBlocks
, ConsolidateBlocks
, UnitarySynthesis
. The logic must be consistent, so there's no point splitting these 3 stages.
I believe this can replace the UnitarySynthesis
pass because any Unitary can be considered a simple peephole unitary.
(** note: currently if the user knows that there's a good chance that UnitarySynthesis improves the circuit, they can force it to occur by adding [Collect2QBlocks(target=target), ConsolidateBlocks(force_consolidate=True), UnitarySynthesis(target=target)]
to the passmanager, so it is possible to customize this by a user who knows how to use the passmanager)