Closed pdhoolia closed 7 hours ago
To address the issue of efficiently synthesizing the special pattern exp(-it (IZZ + ZZI + ZZZ))
in Qiskit, we can create a custom synthesis method for the PauliEvolutionGate
. This method will specifically handle the given pattern and optimize the circuit to use fewer two-qubit gates, as proposed in the reference. Here's a step-by-step plan to implement this:
Extend PauliEvolutionGate
to Support Custom Synthesis:
IZZ
, ZZI
, and ZZZ
and applies the optimized circuit structure.Add Custom Synthesis Strategy:
SpecialPatternSynthesis
) that implements the optimized circuit for this special pattern.Integrate the Custom Synthesis into PauliEvolutionGate
:
PauliEvolutionGate
to use this custom synthesis strategy when the operator matches the specific pattern.PauliEvolutionGate
in pauli_evolution.py
Add a method to detect the special pattern and apply the optimized synthesis.
class PauliEvolutionGate(Gate):
# Existing code...
def _define(self):
"""Unroll, where the default synthesis is matrix based."""
if self._is_special_pattern():
self.definition = self._special_pattern_synthesis()
else:
self.definition = self.synthesis.synthesize(self)
def _is_special_pattern(self):
"""Check if the operator matches the special pattern IZZ, ZZI, ZZZ."""
if isinstance(self.operator, SparsePauliOp):
labels = self.operator.paulis.to_labels()
return set(labels) == {"IZZ", "ZZI", "ZZZ"}
return False
def _special_pattern_synthesis(self):
"""Synthesize the special pattern using the optimized circuit."""
from qiskit.circuit import QuantumCircuit
qc = QuantumCircuit(self.num_qubits)
x = self.time
# Optimized pattern synthesis
qc.cx(0, 1)
qc.rz(2.0 * x, 1)
qc.cx(1, 2)
qc.rz(6.0 * x, 2)
qc.cx(0, 1)
qc.rz(4.0 * x, 2)
qc.cx(1, 2)
return qc
If you want to make this more modular and reusable, you could define a separate class for the synthesis strategy. However, for simplicity, the above inline method in PauliEvolutionGate
suffices for now.
PauliEvolutionGate
correctly identifies the special pattern and applies the optimized circuit.By implementing the above changes, Qiskit will be able to handle the special pattern exp(-it (IZZ + ZZI + ZZZ))
efficiently, reducing the number of two-qubit gates as proposed in the referenced paper.
What should we add?
[1] proposed an efficient way to synthesize the following special pattern of two-body terms (
IZZ
andZZI
) and three-body term (ZZZ
) (Fig. 2 [1]). It can halve the number of two-qubit gates (8 to 4). This pattern is useful to handle QAOA with cubic terms as [1] did.It would be nice if Qiskit can handle this special pattern of synthesis.
Target (
coeffs
can be arbitrary)Qiskit optimization_level=3
Proposed circuit by [1]
Reference [1] Pelofske, E., Bärtschi, A., & Eidenbenz, S. (2024). Short-depth QAOA circuits and quantum annealing on higher-order ising models. Npj Quantum Information, 10(1), 30. https://doi.org/10.1038/s41534-024-00825-w
Script to reproduce