# Applying Suzuki-Trotter approximation to a Quantum Circuit in Qiskit

I am trying to apply the Suzuki-Trotter approximation to a quantum circuit in Qiskit. However, when I attempt to use the st.synthesize() method on my quantum circuit, I encounter the following error:

AttributeError: 'QuantumCircuit' object has no attribute 'operator'


Here is the relevant code part:

for j in range(0, N_qubit, 2):
H = (U * Z^Z) - (J * X^X) - (J * Y^Y)
pauli_ev_gate = PauliEvolutionGate(H, time=t)
if j != N_qubit - 1:
qc.append(pauli_ev_gate, [j, j+1])

for j in range(1, N_qubit, 2):
H = (U * Z^Z) - (J * X^X) - (J * Y^Y)
pauli_ev_gate = PauliEvolutionGate(H, time=t)
if j != N_qubit - 1:
qc.append(pauli_ev_gate, [j, j+1])

for j in range(N_qubit):
pauli_ev_gate = PauliEvolutionGate(h[j]*Z, time=t)
qc.append(pauli_ev_gate, [j])

st = SuzukiTrotter(order=2, reps=6)
qc = st.synthesize(qc)


I want to apply the Suzuki-Trotter approximation to my quantum circuit after adding the gates. How can I resolve the AttributeError and successfully apply the Suzuki-Trotter transformation to my circuit?

Also if someone can explain does it matter to apply SuzukiTrotter transformation on each gate individually or on the whole circuit, it'd be quite helpful.

Any insights or suggestions would be greatly appreciated! Thank you.

The method SuzukiTrotter.synthesize() takes an instance of PauliEvolutionGate as a parameter. The issue in your code is that you are passing a QuantumCircuit.

The right way to use SuzukiTrotter.synthesize():

• Define your Hamiltonian as one of the operator classes supported by PauliEvolutionGate . e.g., SparsePauliOp
• Create a PauliEvolutionGate. Set its operator parameter to be that Hamiltonian.
• Pass the gate to SuzukiTrotter.synthesize()

As an example, assume that we have the Hamiltonian: $$H = -J \sum_{i=1}^{N-1} Z_i Z_{i+1} + h\sum_{i=1}^{N} X_i$$ We can define it using the following code snippet:

from qiskit.circuit import Parameter
from qiskit.quantum_info import Pauli, SparsePauliOp
import numpy as np

J = Parameter("J")
h = Parameter("h")

N = 4
pauli_list = []
coeffs = []
for i in range(N - 1):
x_p = np.zeros(N, dtype=bool)
z_p = np.zeros(N, dtype=bool)
z_p[i] = True
z_p[i + 1] = True
pauli_list.append(Pauli((z_p, x_p)))
coeffs.append(-J)

for i in range(N):
x_p = np.zeros(N, dtype=bool)
z_p = np.zeros(N, dtype=bool)
x_p[i] = True
pauli_list.append(Pauli((z_p, x_p)))
coeffs.append(h)

H = SparsePauliOp(pauli_list, coeffs=coeffs)

# assign J & h values:
H = H.assign_parameters({ J: 1, h: 1 })


Now we create the evolution gate:

from qiskit.circuit.library import PauliEvolutionGate

gate = PauliEvolutionGate(H)


Finally, we synthesize it:

from qiskit.synthesis import SuzukiTrotter

st = SuzukiTrotter(order=2, reps=6)
circ = st.synthesize(gate)

• Thanks a lot, it really helped. Commented Jul 22, 2023 at 13:27
• Can you also say how to choose SuzukitTrotter order is bigger order always more precise? Commented Jul 22, 2023 at 15:15
• Qiskit documentation for SuzukiTrotter is a good starting point. And it contains references for more details. Commented Jul 22, 2023 at 15:46

The docs here https://qiskit.org/documentation/stubs/qiskit.synthesis.SuzukiTrotter.synthesize.html state that the synthesize method takes a PauliEvolutionGate and returns a QuantumCircuit implementing the evolution

• Yes I know that I was wondering how can I apply this transform to overal circuit instead of individual gates. And does it matter? Does applying SuzikiTrotter to overal circuit differes from applying it to individual terms? -Since it's not linear transform I am unsure(When operators do not commute- Commented Jul 19, 2023 at 15:57