Closed Cryoris closed 4 months ago
With slightly modified code to account for changes in Qiskit since this issue:
from qiskit.circuit import QuantumCircuit, Parameter
from qiskit.circuit.library import PauliEvolutionGate
from qiskit.synthesis import SuzukiTrotter, MatrixExponential
from qiskit.quantum_info import Operator, SparsePauliOp
# evolution time and operator we evolve
time = Parameter("t")
op = SparsePauliOp.from_list([("IXY", 1), ("IYX", 1), ("ZZI", -1)])
# evolution gate
synth = MatrixExponential()
evo = PauliEvolutionGate(op, time=time, synthesis=synth)
# plug into circuit
circuit = QuantumCircuit(op.num_qubits)
circuit.append(evo, range(op.num_qubits))
print(circuit.draw())
# bind time to some value and obtain matrix
value = 0.23
bound = circuit.assign_parameters([value]) # or {time: value}
print(bound.decompose())
this no longer seems to be reproducible with Qiskit 1.0, so I'll close the issue.
Environment
What is happening?
Using the
PauliEvolutionGate
with a parameterized time and theMatrixExponential
as synthesis method breaks. The reason is that the evolution time, after being bound, is not cast to a float but remains aParameterExpression
with 0 free parameters. That type is incompatible with SciPy which is used to compute the matrix exponential.How can we reproduce the issue?
produces
What should happen?
Properly evolve.
Any suggestions?
See #7508