Qiskit / qiskit-serverless

A programming model for leveraging quantum and classical resources
https://qiskit.github.io/qiskit-serverless/
Apache License 2.0
62 stars 27 forks source link

docs/guides/03_runtime_primitives_with_quantum_serverless.ipynb fails #488

Closed akihikokuroda closed 1 year ago

akihikokuroda commented 1 year ago

Steps to reproduce the problem

Run docker compose Run Jupyter notebook Run docs/guides/03_runtime_primitives_with_quantum_serverless.ipynb

What is the current behavior?

It fails with the following error.

RayTaskError(AccountNotFoundError)        Traceback (most recent call last)
Cell In [1], line 36
     32 function_references = [my_function(circ, obs_ref) for circ in circuits]
     34 # 5. to get results back from reference
     35 # we need to call `get` on function reference
---> 36 print("Single execution:", get(function_reference))
     37 print("N parallel executions:", get(function_references))

File /opt/conda/lib/python3.9/site-packages/ray/_private/client_mode_hook.py:105, in client_mode_hook.<locals>.wrapper(*args, **kwargs)
    103     if func.__name__ != "init" or is_client_mode_enabled_by_default:
    104         return getattr(ray, func.__name__)(*args, **kwargs)
--> 105 return func(*args, **kwargs)

File /opt/conda/lib/python3.9/site-packages/ray/_private/worker.py:2521, in get(object_refs, timeout)
   2519     worker.core_worker.dump_object_store_memory_usage()
   2520 if isinstance(value, RayTaskError):
-> 2521     raise value.as_instanceof_cause()
   2522 else:
   2523     raise value

RayTaskError(AccountNotFoundError): ray::my_function() (pid=7113, ip=10.4.1.79)
  File "/opt/conda/lib/python3.9/site-packages/quantum_serverless/core/decorators.py", line 202, in wraps
    return func(*args, **kwargs)
  File "/tmp/ipykernel_6556/2197171511.py", line 13, in my_function
  File "/opt/conda/lib/python3.9/site-packages/qiskit_ibm_runtime/estimator.py", line 205, in __init__
    self._session = get_default_session(service, backend)
  File "/opt/conda/lib/python3.9/site-packages/qiskit_ibm_runtime/session.py", line 285, in get_default_session
    else QiskitRuntimeService()
  File "/opt/conda/lib/python3.9/site-packages/qiskit_ibm_runtime/qiskit_runtime_service.py", line 190, in __init__
    self._account = self._discover_account(
  File "/opt/conda/lib/python3.9/site-packages/qiskit_ibm_runtime/qiskit_runtime_service.py", line 312, in _discover_account
    account = AccountManager.get(filename=filename)
  File "/opt/conda/lib/python3.9/site-packages/qiskit_ibm_runtime/accounts/management.py", line 184, in get
    raise AccountNotFoundError("Unable to find account.")
qiskit_ibm_runtime.accounts.exceptions.AccountNotFoundError: 'Unable to find account.'

What is the expected behavior?

Run without error.

akihikokuroda commented 1 year ago

I wonder if this should run. Do we need embed an account?

IceKhan13 commented 1 year ago

I will cover this under #479

Now we can pass runtime service object as argument. We will use that to handle account details

IceKhan13 commented 1 year ago

Gone in https://github.com/Qiskit-Extensions/quantum-serverless/pull/481