qiskit-algorithms icon indicating copy to clipboard operation
qiskit-algorithms copied to clipboard

Attribute Error in Reverse QGT

Open Gopal-Dahale opened this issue 4 months ago • 0 comments

Environment

  • Qiskit Algorithms version: 0.3.0
  • Python version: 3.10.0
  • Operating system: Ubuntu 22.04.5 LTS

What is happening?

When using ReverseQGT, we get the following error:

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

How can we reproduce the issue?

from qiskit.circuit.library import TwoLocal
from qiskit_algorithms.gradients import ReverseQGT
import numpy as np

n_qubits = 1
qc = TwoLocal(
    n_qubits,
    ["rx"],
    ["cx"],
    "linear",
    reps=1,
    skip_final_rotation_layer=True,
    flatten=True,
)
params = np.random.rand(qc.num_parameters)
grad = ReverseQGT()
grad.run([qc], [params]).result()

What should happen?

It should not throw this error.

Any suggestions?

We need to update the ReverseQGT with the supported attributes of QuantumCircuit for the latest qiskit version.

Gopal-Dahale avatar Oct 09 '24 09:10 Gopal-Dahale