We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Controlled parameterized gates (like CRYGate) seem to be ignored when running the Sampler (V1 or V2).
CRYGate
from qiskit.circuit import QuantumCircuit, Parameter import numpy as np from qiskit_aer.primitives import Sampler from qiskit_aer.primitives import SamplerV2 sampler = Sampler() sampler_v2 = SamplerV2() a = Parameter("a") qc = QuantumCircuit(2) qc.x(0) qc.cry(a, 0, 1) qc.x(0) # Parameter list params = [np.pi / 4] qc_measured = qc.measure_all(inplace=False) dist = sampler.run(qc_measured, params).result().quasi_dists print("Dist V1", dist) dist_v2 = sampler_v2.run([(qc_measured, params)]).result()[0].data.meas.get_counts() print("Dist V2", dist_v2) qc_bound = qc_measured.assign_parameters(params) dist = sampler.run(qc_bound).result().quasi_dists print("Dist V1", dist) dist_v2 = sampler_v2.run([(qc_bound)]).result()[0].data.meas.get_counts() print("Dist V2", dist_v2)
Result:
Dist V1 [{0: 1.0}] Dist V2 {'00': 1024} Dist V1 [{2: 0.14453125, 0: 0.85546875}] Dist V2 {'00': 886, '10': 138}
Both circuits, the one with assigned parameters and the one without assigned parameters, should return similar values.
As shown in the example, this can be circumvented by assigning parameters before running the Sampler.
The text was updated successfully, but these errors were encountered:
It looks like the cause is on
qiskit-aer/qiskit_aer/backends/aerbackend.py
Line 125 in 37718fa
instruction.operation.is_parameterized() returns false for controlled rotations (see also Qiskit/qiskit#12624 (comment)).
instruction.operation.is_parameterized()
Sorry, something went wrong.
No branches or pull requests
Informations
What is the current behavior?
Controlled parameterized gates (like
CRYGate
) seem to be ignored when running the Sampler (V1 or V2).Steps to reproduce the problem
Result:
What is the expected behavior?
Both circuits, the one with assigned parameters and the one without assigned parameters, should return similar values.
Suggested solutions
As shown in the example, this can be circumvented by assigning parameters before running the Sampler.
The text was updated successfully, but these errors were encountered: