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

01_vqe.ipy and 01_qaoq.ipy execution fail #1095

Closed
akihikokuroda opened this issue Nov 15, 2023 · 9 comments
Closed

01_vqe.ipy and 01_qaoq.ipy execution fail #1095

akihikokuroda opened this issue Nov 15, 2023 · 9 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@akihikokuroda
Copy link
Collaborator

Steps to reproduce the problem

Execute 01_vqe.ipy and 01_qaoq.ipy in the Jupyter notebook

What is the current behavior?

The execution fails and there is no result

What is the expected behavior?

Execution completes successfully and generates results.

Logs output of 01_vqe

'/tmp/ray/session_2023-11-14_12-26-15_736092_8/runtime_resources/working_dir_files/_ray_pkg_e2b79fcf1b9147e1/vqe.py:13: DeprecationWarning: The ``qiskit.opflow`` module is deprecated as of qiskit-terra 0.24.0. It will be removed no earlier than 3 months after the release date. For code migration guidelines, visit [https://qisk.it/opflow_migration.\n](https://qisk.it/opflow_migration./n)  from qiskit.opflow import PauliSumOp\ncapi_return is NULL\nCall-back cb_calcfc_in__cobyla__user__routines failed.\nTraceback (most recent call last):\n  File "/tmp/ray/session_2023-11-14_12-26-15_736092_8/runtime_resources/working_dir_files/_ray_pkg_e2b79fcf1b9147e1/vqe.py", line 154, in <module>\n    vqe_result, callback_dict = run_vqe(\n  File "/tmp/ray/session_2023-11-14_12-26-15_736092_8/runtime_resources/working_dir_files/_ray_pkg_e2b79fcf1b9147e1/vqe.py", line 119, in run_vqe\n    result = minimize(\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/scipy/optimize/_minimize.py", line 702, in minimize\n    res = _minimize_cobyla(fun, x0, args, constraints, callback=callback,\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/scipy/optimize/_cobyla_py.py", line 34, in wrapper\n    return func(*args, **kwargs)\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/scipy/optimize/_cobyla_py.py", line 270, in _minimize_cobyla\n    xopt, info = cobyla.minimize(calcfc, m=m, x=np.copy(x0), rhobeg=rhobeg,\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/scipy/optimize/_cobyla_py.py", line 258, in calcfc\n    f = fun(np.copy(x), *args)\n  File "/tmp/ray/session_2023-11-14_12-26-15_736092_8/runtime_resources/working_dir_files/_ray_pkg_e2b79fcf1b9147e1/vqe.py", line 105, in cost_func\n    estimator.run(ansatz, hamiltonian, parameter_values=params).result().values[0]\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit/primitives/primitive_job.py", line 55, in result\n    return self._future.result()\n  File "/home/ray/anaconda3/lib/python3.9/concurrent/futures/_base.py", line 439, in result\n    return self.__get_result()\n  File "/home/ray/anaconda3/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result\n    raise self._exception\n  File "/home/ray/anaconda3/lib/python3.9/concurrent/futures/thread.py", line 58, in run\n    result = self.fn(*self.args, **self.kwargs)\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit/primitives/estimator.py", line 109, in _call\n    final_state = Statevector(bound_circuit_to_instruction(circ))\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit/quantum_info/states/statevector.py", line 91, in __init__\n    self._data = Statevector.from_instruction(data).data\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit/quantum_info/states/statevector.py", line 768, in from_instruction\n    return Statevector._evolve_instruction(vec, instruction)\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit/quantum_info/states/statevector.py", line 960, in _evolve_instruction\n    Statevector._evolve_instruction(statevec, instruction.operation, qargs=new_qargs)\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit/quantum_info/states/statevector.py", line 960, in _evolve_instruction\n    Statevector._evolve_instruction(statevec, instruction.operation, qargs=new_qargs)\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit/quantum_info/states/statevector.py", line 896, in _evolve_instruction\n    mat = Operator._instruction_to_matrix(obj)\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit/quantum_info/operators/operator.py", line 718, in _instruction_to_matrix\n    mat = obj.to_matrix()\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit/circuit/gate.py", line 61, in to_matrix\n    return self.__array__(dtype=complex)\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit/circuit/library/standard_gates/ry.py", line 106, in __array__\n    cos = math.cos(self.params[0] / 2)\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit/circuit/parameterexpression.py", line 493, in __float__\n    raise TypeError(\nTypeError: ParameterExpression with unbound parameters (dict_keys([ParameterVectorElement(θ[0])])) cannot be cast to a float.\n'

logs output of 02_qaoa

'/tmp/ray/session_2023-11-15_07-08-55_675046_8/runtime_resources/working_dir_files/_ray_pkg_817bb4a74aedd14d/qaoa.py:9: DeprecationWarning: The ``qiskit.opflow`` module is deprecated as of qiskit-terra 0.24.0. It will be removed no earlier than 3 months after the release date. For code migration guidelines, visit [https://qisk.it/opflow_migration.\n](https://qisk.it/opflow_migration./n)  from qiskit.opflow import PauliSumOp\nTraceback (most recent call last):\n  File "/tmp/ray/session_2023-11-15_07-08-55_675046_8/runtime_resources/working_dir_files/_ray_pkg_817bb4a74aedd14d/qaoa.py", line 53, in <module>\n    arguments = get_arguments()\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/quantum_serverless/serializers/program_serializers.py", line 84, in get_arguments\n    return json.loads(os.environ.get(ENV_JOB_ARGUMENTS, "{}"), cls=QiskitObjectsDecoder)\n  File "/home/ray/anaconda3/lib/python3.9/json/__init__.py", line 359, in loads\n    return cls(**kw).decode(s)\n  File "/home/ray/anaconda3/lib/python3.9/json/decoder.py", line 337, in decode\n    obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n  File "/home/ray/anaconda3/lib/python3.9/json/decoder.py", line 353, in raw_decode\n    obj, end = self.scan_once(s, idx)\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/quantum_serverless/serializers/program_serializers.py", line 74, in object_hook\n    return super().object_hook(obj)\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit_ibm_runtime/utils/json.py", line 302, in object_hook\n    return _decode_and_deserialize(obj_val, load)[0]\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit_ibm_runtime/utils/json.py", line 129, in _decode_and_deserialize\n    return deserializer(buff)\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit_ibm_provider/qpy/interface.py", line 273, in load\n    loader(  # type: ignore[no-untyped-call]\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit_ibm_provider/qpy/binary_io/circuits.py", line 1206, in read_circuit\n    _read_instruction(\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit_ibm_provider/qpy/binary_io/circuits.py", line 350, in _read_instruction\n    circuit._append(CircuitInstruction(gate, qargs, cargs))\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit/circuit/quantumcircuit.py", line 1357, in _append\n    self._update_parameter_table(instruction)\n  File "/home/ray/anaconda3/lib/python3.9/site-packages/qiskit/circuit/quantumcircuit.py", line 1377, in _update_parameter_table\n    raise CircuitError(f"Name conflict on adding parameter: {parameter.name}")\nqiskit.circuit.exceptions.CircuitError: \'Name conflict on adding parameter: γ[0]\'\n'
@akihikokuroda akihikokuroda added the bug Something isn't working label Nov 15, 2023
@akihikokuroda
Copy link
Collaborator Author

Both logs have

DeprecationWarning: The qiskit.opflow module is deprecated as of qiskit-terra 0.24.0.

Is it better replacing these with something else?

@psschwei
Copy link
Collaborator

also fails for me, with same errors.

I wonder if this is another case of a new version of a library causing a break... if so, maybe we should reopen #806 as a short-term solution until we have a better dependency management solution in place?

@psschwei
Copy link
Collaborator

Based on our discussion in the other issue, I'd vote for dropping these notebooks or moving them to one of the applications repos.

@IceKhan13
Copy link
Member

VQE and QAOA are not applications, they are just examples of algorithms. We should have at least VQE in our docs for sure as it is the most popular quantum algorithm

@akihikokuroda
Copy link
Collaborator Author

OK. I can work to fix them.

@psschwei
Copy link
Collaborator

psschwei commented Nov 29, 2023

Both logs have

DeprecationWarning: The qiskit.opflow module is deprecated as of qiskit-terra 0.24.0.

Is it better replacing these with something else?

Luciano linked to a migration guide in the above issue: https://qisk.it/opflow_migration

@akihikokuroda
Copy link
Collaborator Author

I've looked at this issue for a week. I finally found that this is caused by a qiskit/ParameterVector serialization issue. The issue will be fixed in Qiskit/qiskit-ibm-provider#736 which is still open though.

@akihikokuroda
Copy link
Collaborator Author

I verified that picking up changes between line 217-240 in qiskit_ibm_provider/qpy/binary_io/value.py fix this issue.

@IceKhan13 IceKhan13 added this to the Q1'24 milestone Dec 12, 2023
@IceKhan13 IceKhan13 modified the milestones: Q1'24, Q3'24, Tech debt Jan 17, 2024
@psschwei
Copy link
Collaborator

psschwei commented Feb 1, 2024

These both run successfully for me now against main ... should we close this?

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

3 participants