-
Notifications
You must be signed in to change notification settings - Fork 58
Description
Is your feature request related to a problem? Please describe.
When running subcircuit MCFE, it is possible that a circuit with the same operations, on the same qubits, is sampled multiple times. In these cases, we would like to avoid running more circuits than we need to by deduplicating any circuit that is sampled multiple times. This logic is currently implemented for MCFE experiment designs by using the pyGSTi circuit as a key in a dictionary, and therefore the deduplication is based on checking whether two circuits are equal based on their hashes. However, consider the following two circuits circ_1 and circ_2 given by:
circ_1 = pygsti.circuits.Circuit([[("Gxpi2", "Q0"), ("Gypi2", "Q1")]])
circ_2 = pygsti.circuits.Circuit([[("Gypi2", "Q1"), ("Gxpi2", "Q0")]])
These two circuits are logically equivalent. Each has a Gxpi2 gate on Q0 and a Gypi2 gate on Q1. Thus, for the deduplication use case, we want to consider these circuits as equivalent. However, their hashes are different, and so we fail to deduplicate. In this particular case, circ_1.__hash__() = 2869224465175841073 and circ_2.__hash__() = -9005778824968725551. The issue is that since the order of the gates within the layer is different, the hash is different, even though this has no effect on the logical behavior of the quantum circuit.
Describe the solution you'd like
I would like a second kind of circuit equality check that checks for logical equivalence between circuits, and is thereby independent of the insertion order of gates within a layer.
Describe alternatives you've considered
One could instead sort the layer labels upon construction of the circuit (or once the circuit is made static), such that the logical equivalence check that I am describing and the current equality check would coincide.