Skip to content
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

ParameterExpression not cast to float in rzx_builder.py #8963

Closed
nbronn opened this issue Oct 19, 2022 · 1 comment
Closed

ParameterExpression not cast to float in rzx_builder.py #8963

nbronn opened this issue Oct 19, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@nbronn
Copy link
Contributor

nbronn commented Oct 19, 2022

Environment

  • Qiskit Terra version: 0.22.0
  • Python version: 3.9.12
  • Operating system: Darwin

What is happening?

See below.

How can we reproduce the issue?

from qiskit.circuit import Parameter, QuantumCircuit
from qiskit.providers.fake_provider import FakeLagos
from qiskit.transpiler import PassManager
from qiskit.transpiler.passes.calibration import RZXCalibrationBuilder

backend = FakeLagos()
inst_sched_map = backend.defaults().instruction_schedule_map
coupling_map = backend.configuration().coupling_map

theta = Parameter('θ')
qc = QuantumCircuit(2)
qc.rzx(theta, 0, 1)
qc.draw()

yields

     ┌─────────┐
q_0: ┤0        ├
     │  Rzx(θ) │
q_1: ┤1        ├
     └─────────┘

Then,

pm = PassManager(RZXCalibrationBuilder(inst_sched_map, coupling_map))
qc_t = pm.run(qc.bind_parameters({theta: 0.3}))

results in an error:

File ~/opt/anaconda3/envs/qiskit-stable/lib/python3.9/site-packages/numpy/core/numeric.py:2287, in isclose(a, b, rtol, atol, equal_nan)
   2284 dt = multiarray.result_type(y, 1.)
   2285 y = array(y, dtype=dt, copy=False, subok=True)
-> 2287 xfin = isfinite(x)
   2288 yfin = isfinite(y)
   2289 if all(xfin) and all(yfin):

TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

What should happen?

This works fine if the theta rotation is replaced by a float, i.e. 0.3.

Any suggestions?

The ParameterExpression should be cast to float.

@jakelishman
Copy link
Member

Fixed by #8965.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants