You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The call to DynamicsBackend.from_backend throws a ValueError if given the parameter rwa_cutoff_freq=5e9.
The docstring states, that a float parameter can be given.
Error Message:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
File [~/Workspace/git/quantum-optimal-control-algorithms/.venv/lib/python3.11/site-packages/qiskit_dynamics/array/array.py:212](https://file+.vscode-resource.vscode-cdn.net/home/luja_sa/Workspace/git/quantum-optimal-control-algorithms/src/notebooks/~/Workspace/git/quantum-optimal-control-algorithms/.venv/lib/python3.11/site-packages/qiskit_dynamics/array/array.py:212), in Array.__float__(self)
[211](https://file+.vscode-resource.vscode-cdn.net/home/luja_sa/Workspace/git/quantum-optimal-control-algorithms/src/notebooks/~/Workspace/git/quantum-optimal-control-algorithms/.venv/lib/python3.11/site-packages/qiskit_dynamics/array/array.py:211) raise TypeError("only size-1 Arrays can be converted to Python scalars.")
--> [212](https://file+.vscode-resource.vscode-cdn.net/home/luja_sa/Workspace/git/quantum-optimal-control-algorithms/src/notebooks/~/Workspace/git/quantum-optimal-control-algorithms/.venv/lib/python3.11/site-packages/qiskit_dynamics/array/array.py:212) return float(self._data)
TypeError: float() argument must be a string or a real number, not 'complex'
The above exception was the direct cause of the following exception:
ValueError Traceback (most recent call last)
Cell In[4], [line 5](vscode-notebook-cell:?execution_count=4&line=5)
[2](vscode-notebook-cell:?execution_count=4&line=2) from qiskit_dynamics.backend import DynamicsBackend
[4](vscode-notebook-cell:?execution_count=4&line=4) fake_backend = FakeNairobi()
----> [5](vscode-notebook-cell:?execution_count=4&line=5) sim_backend = DynamicsBackend.from_backend(fake_backend, subsystem_list=[0,1], rwa_cutoff_freq=5e9)
File [~/Workspace/git/quantum-optimal-control-algorithms/.venv/lib/python3.11/site-packages/qiskit_dynamics/backend/dynamics_backend.py:723](https://file+.vscode-resource.vscode-cdn.net/home/luja_sa/Workspace/git/quantum-optimal-control-algorithms/src/notebooks/~/Workspace/git/quantum-optimal-control-algorithms/.venv/lib/python3.11/site-packages/qiskit_dynamics/backend/dynamics_backend.py:723), in DynamicsBackend.from_backend(cls, backend, subsystem_list, rotating_frame, evaluation_mode, rwa_cutoff_freq, **options)
[719](https://file+.vscode-resource.vscode-cdn.net/home/luja_sa/Workspace/git/quantum-optimal-control-algorithms/src/notebooks/~/Workspace/git/quantum-optimal-control-algorithms/.venv/lib/python3.11/site-packages/qiskit_dynamics/backend/dynamics_backend.py:719) else:
[720](https://file+.vscode-resource.vscode-cdn.net/home/luja_sa/Workspace/git/quantum-optimal-control-algorithms/src/notebooks/~/Workspace/git/quantum-optimal-control-algorithms/.venv/lib/python3.11/site-packages/qiskit_dynamics/backend/dynamics_backend.py:720) # config is guaranteed to have a dt
[721](https://file+.vscode-resource.vscode-cdn.net/home/luja_sa/Workspace/git/quantum-optimal-control-algorithms/src/notebooks/~/Workspace/git/quantum-optimal-control-algorithms/.venv/lib/python3.11/site-packages/qiskit_dynamics/backend/dynamics_backend.py:721) dt = backend_config.dt
--> [723](https://file+.vscode-resource.vscode-cdn.net/home/luja_sa/Workspace/git/quantum-optimal-control-algorithms/src/notebooks/~/Workspace/git/quantum-optimal-control-algorithms/.venv/lib/python3.11/site-packages/qiskit_dynamics/backend/dynamics_backend.py:723) solver = Solver(
[724](https://file+.vscode-resource.vscode-cdn.net/home/luja_sa/Workspace/git/quantum-optimal-control-algorithms/src/notebooks/~/Workspace/git/quantum-optimal-control-algorithms/.venv/lib/python3.11/site-packages/qiskit_dynamics/backend/dynamics_backend.py:724) static_hamiltonian=static_hamiltonian,
[725](https://file+.vscode-resource.vscode-cdn.net/home/luja_sa/Workspace/git/quantum-optimal-control-algorithms/src/notebooks/~/Workspace/git/quantum-optimal-control-algorithms/.venv/lib/python3.11/site-packages/qiskit_dynamics/backend/dynamics_backend.py:725) hamiltonian_operators=hamiltonian_operators,
[726](https://file+.vscode-resource.vscode-cdn.net/home/luja_sa/Workspace/git/quantum-optimal-control-algorithms/src/notebooks/~/Workspace/git/quantum-optimal-control-algorithms/.venv/lib/python3.11/site-packages/qiskit_dynamics/backend/dynamics_backend.py:726) hamiltonian_channels=hamiltonian_channels,
[727](https://file+.vscode-resource.vscode-cdn.net/home/luja_sa/Workspace/git/quantum-optimal-control-algorithms/src/notebooks/~/Workspace/git/quantum-optimal-control-algorithms/.venv/lib/python3.11/site-packages/qiskit_dynamics/backend/dynamics_backend.py:727) channel_carrier_freqs=channel_freqs,
...
--> [269](https://file+.vscode-resource.vscode-cdn.net/home/luja_sa/Workspace/git/quantum-optimal-control-algorithms/src/notebooks/~/Workspace/git/quantum-optimal-control-algorithms/.venv/lib/python3.11/site-packages/qiskit_dynamics/models/rotating_wave_approximation.py:269) carrier_freqs[i] = sig.carrier_freq
[271](https://file+.vscode-resource.vscode-cdn.net/home/luja_sa/Workspace/git/quantum-optimal-control-algorithms/src/notebooks/~/Workspace/git/quantum-optimal-control-algorithms/.venv/lib/python3.11/site-packages/qiskit_dynamics/models/rotating_wave_approximation.py:271) num_components = len(carrier_freqs)
[272](https://file+.vscode-resource.vscode-cdn.net/home/luja_sa/Workspace/git/quantum-optimal-control-algorithms/src/notebooks/~/Workspace/git/quantum-optimal-control-algorithms/.venv/lib/python3.11/site-packages/qiskit_dynamics/models/rotating_wave_approximation.py:272) n = current_ops[0].shape[-1]
ValueError: setting an array element with a sequence.
The problem originates from the line 269 in rotating_wave_approximation.py:
carrier_freqs[i] =sig.carrier_freq
which throws as it expects a float assignment but actually receives a complex. All carrier frequency values corresponding the control channels U* are of type complex while the ones for the drive channels D* are float.
The values for sig.carrier_freq are extracted from the backend_config in DynamicsBackend.from_backend in line 677 of dynamics_backend.py by calling _get_backend_channel_freqs(...).
For control channels the values are calculated in line 1059.
Informations
0.4.2
3.11.7
Ubuntu 22.04.3 LTS
What is the current behavior?
The call to
DynamicsBackend.from_backend
throws aValueError
if given the parameterrwa_cutoff_freq=5e9
.The docstring states, that a
float
parameter can be given.Error Message:
Steps to reproduce the problem
What is the expected behavior?
No exception is thrown and the
rwa_cutoff_freq
is used by theSolver
instance.Suggested solutions
None, I have not checked the cause of the error.
The text was updated successfully, but these errors were encountered: