-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parameter binds does not work when unrolling parameterized gates #1346
Labels
bug
Something isn't working
stable-backport-potential
The issue or PR might be minimal and/or import enough to backport to stable
Comments
@mtreinish It looks to be something to do with transpiling to different basis gates, though I'm not sure why this would cause an issue. Here is a more minimal example that avoids the import numpy as np
from qiskit import QuantumCircuit, transpile
from qiskit.circuit import Parameter
from qiskit.providers.aer import AerSimulator
a = Parameter('a')
qc = QuantumCircuit(1, 1)
qc.rx(a,0)
qc.measure(0,0)
# Transpile rx -> u3
tqc = transpile(qc, basis_gates=['u3'])
binds = [{a: np.array([np.pi])}]
result = AerSimulator().run(tqc, parameter_binds=binds).result()
|
chriseclectic
changed the title
Noisy Simulations require manual parameter binding; multiple errors encountered.
Parameter binds does not work when unrolling parameterized gates
Sep 23, 2021
mtreinish
added
the
stable-backport-potential
The issue or PR might be minimal and/or import enough to backport to stable
label
Sep 23, 2021
mtreinish
added a commit
to mtreinish/qiskit-aer
that referenced
this issue
Sep 23, 2021
This commit fixes an oversight in the handling of the parameter binds kwarg on backend.run(). To build the parameterizations representation that aer's c++ code expects we need to iterate over all the instructions to find any that are parameterized. In this check we were incorrectly finding gates with ParameterExpressions that were already bound to a value (and had no unbound parameters). This would often come up from the transpiler when the basis translator uses a parameter expression to adjust rotation angles when translating between 1q gates. This commit fixes this by adding a check for fully bound parameter expressions and not including them in the set of parameterizations we pass to the inner simulator code. Fixes Qiskit#1346
chriseclectic
pushed a commit
that referenced
this issue
Sep 23, 2021
This commit fixes an oversight in the handling of the parameter binds kwarg on backend.run(). To build the parameterizations representation that aer's c++ code expects we need to iterate over all the instructions to find any that are parameterized. In this check we were incorrectly finding gates with ParameterExpressions that were already bound to a value (and had no unbound parameters). This would often come up from the transpiler when the basis translator uses a parameter expression to adjust rotation angles when translating between 1q gates. This commit fixes this by adding a check for fully bound parameter expressions and not including them in the set of parameterizations we pass to the inner simulator code. Fixes #1346
chriseclectic
pushed a commit
to chriseclectic/qiskit-aer
that referenced
this issue
Oct 5, 2021
This commit fixes an oversight in the handling of the parameter binds kwarg on backend.run(). To build the parameterizations representation that aer's c++ code expects we need to iterate over all the instructions to find any that are parameterized. In this check we were incorrectly finding gates with ParameterExpressions that were already bound to a value (and had no unbound parameters). This would often come up from the transpiler when the basis translator uses a parameter expression to adjust rotation angles when translating between 1q gates. This commit fixes this by adding a check for fully bound parameter expressions and not including them in the set of parameterizations we pass to the inner simulator code. Fixes Qiskit#1346
chriseclectic
pushed a commit
to chriseclectic/qiskit-aer
that referenced
this issue
Oct 8, 2021
This commit fixes an oversight in the handling of the parameter binds kwarg on backend.run(). To build the parameterizations representation that aer's c++ code expects we need to iterate over all the instructions to find any that are parameterized. In this check we were incorrectly finding gates with ParameterExpressions that were already bound to a value (and had no unbound parameters). This would often come up from the transpiler when the basis translator uses a parameter expression to adjust rotation angles when translating between 1q gates. This commit fixes this by adding a check for fully bound parameter expressions and not including them in the set of parameterizations we pass to the inner simulator code. Fixes Qiskit#1346
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
stable-backport-potential
The issue or PR might be minimal and/or import enough to backport to stable
Informations
What is the current behavior?
parameters must be manually bound beforehand or else noisy simulations cannot be executed.
One of three errors arises, which will be different depending on what you pass as a parameter bind. If binds are List of Dict(Parameter, number), the following error occurs:
Whereas, if one attempts to rectify this with binds as List of Dict(Parameter,array), one gets either
if using np.asarray([number]). if using np.array(number), one instead gets:
Steps to reproduce the problem
What is the expected behavior?
Parameter binds of List of Dict(Parameter,number) should be acceptable as a pass-down.
Suggested solutions
No clue. The fix to one problem keeps creating a new one. This is potentially related to the fix to #1249.
The text was updated successfully, but these errors were encountered: