Code Monkey home page Code Monkey logo

qiskit-ibm-runtime's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qiskit-ibm-runtime's Issues

Replace **kwargs with proxies and verify in IBMRuntimeService constructor

What is the expected feature or enhancement?

IBMRuntimeService constructor has a **kwargs which is documented as

            **kwargs: Additional settings for the connection:
                * proxies (dict): proxy configuration.
                * verify (bool): verify the server's TLS certificate.

If proxies and verify are the only ones allowed, why not spell them out?

Runtime VQEProgram error

Describe the bug
I got the error when I executed Nature runtime tutorial: https://qiskit.org/documentation/nature/tutorials/07_leveraging_qiskit_runtime.html on 'ibmq_qasm_simulator'.

Steps to reproduce
I selected the simulator as the backend:

from qiskit import IBMQ

IBMQ.load_account()
provider = IBMQ.get_provider(hub='ibm-q', group='open', project='main')
backend = provider.get_backend('ibmq_qasm_simulator')

and set the same VQEProgram as the tutorial, and executed below;

runtime_vqe_groundstate_solver = GroundStateEigensolver(qubit_converter, runtime_vqe)
runtime_vqe_result = runtime_vqe_groundstate_solver.solve(problem)

then I got;

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-11-b7ecbb463844> in <module>
      1 runtime_vqe_groundstate_solver = GroundStateEigensolver(qubit_converter, runtime_vqe)
----> 2 runtime_vqe_result = runtime_vqe_groundstate_solver.solve(problem)

~/opt/anaconda3/envs/qiskit0331_3/lib/python3.8/site-packages/qiskit_nature/algorithms/ground_state_solvers/ground_state_eigensolver.py in solve(self, problem, aux_operators)
    111         raw_mes_result = self._solver.compute_minimum_eigenvalue(main_operator, aux_ops)
    112 
--> 113         result = problem.interpret(raw_mes_result)
    114         return result
    115 

~/opt/anaconda3/envs/qiskit0331_3/lib/python3.8/site-packages/qiskit_nature/problems/second_quantization/electronic/electronic_structure_problem.py in interpret(self, raw_result)
    164         result = ElectronicStructureResult()
    165         result.combine(eigenstate_result)
--> 166         self._grouped_property_transformed.interpret(result)
    167         result.computed_energies = np.asarray([e.real for e in eigenstate_result.eigenenergies])
    168         return result

~/opt/anaconda3/envs/qiskit0331_3/lib/python3.8/site-packages/qiskit_nature/properties/grouped_property.py in interpret(self, result)
    104         """
    105         for prop in self._properties.values():
--> 106             prop.interpret(result)

~/opt/anaconda3/envs/qiskit0331_3/lib/python3.8/site-packages/qiskit_nature/properties/second_quantization/electronic/particle_number.py in interpret(self, result)
    187 
    188             if aux_op_eigenvalues[0] is not None:
--> 189                 n_particles = aux_op_eigenvalues[0][0].real  # type: ignore
    190                 result.num_particles.append(n_particles)
    191 

TypeError: 'float' object is not subscriptable

Expected behavior
Same as the tutorial, no message is expected.

Suggested solutions

Additional Information

  • Qiskit IBM Runtime version:

qiskit-terra | 0.19.1
qiskit-aer | 0.9.1
qiskit-ignis | 0.7.0
qiskit-ibmq-provider | 0.18.2
qiskit | 0.33.1
qiskit-nature | 0.2.2
qiskit-finance | 0.2.1
qiskit-optimization | 0.2.3
qiskit-machine-learning | 0.2.1

  • Python version:

Python version | 3.8.5

  • Operating system:

OS | Darwin

Exiting Python session generates TypeError

Describe the bug

After using IBMRuntimeService in a Python CLI session, when exiting it generated a bunch of TypeError:

Exception ignored in: <function RetrySession.__del__ at 0x13fd5cd30>
Traceback (most recent call last):
  File "/Users/jessieyu/Documents/Q/Github/qiskit-ibm-runtime/qiskit_ibm_runtime/api/session.py", line 173, in __del__
  File "/Users/jessieyu/.pyenv/versions/qiskit-ibm-runtime/lib/python3.8/site-packages/requests/sessions.py", line 747, in close
  File "/Users/jessieyu/.pyenv/versions/qiskit-ibm-runtime/lib/python3.8/site-packages/requests/adapters.py", line 325, in close
  File "/Users/jessieyu/.pyenv/versions/qiskit-ibm-runtime/lib/python3.8/site-packages/urllib3/poolmanager.py", line 222, in clear
  File "/Users/jessieyu/.pyenv/versions/qiskit-ibm-runtime/lib/python3.8/site-packages/urllib3/_collections.py", line 100, in clear
  File "/Users/jessieyu/.pyenv/versions/qiskit-ibm-runtime/lib/python3.8/site-packages/urllib3/poolmanager.py", line 173, in <lambda>
  File "/Users/jessieyu/.pyenv/versions/qiskit-ibm-runtime/lib/python3.8/site-packages/urllib3/connectionpool.py", line 494, in close
TypeError: catching classes that do not inherit from BaseException is not allowed
Exception ignored in: <function RetrySession.__del__ at 0x13fd5cd30>
Traceback (most recent call last):

Steps to reproduce

>>> from qiskit_ibm_runtime import IBMRuntimeService
>>> service = IBMRuntimeService()
>>> backend = service.least_busy()
<ctrl-D>

Expected behavior

Suggested solutions

Additional Information

  • Qiskit IBM Runtime version:
  • Python version: 3.8.1
  • Operating system:

Tests started failing without code change in qiskit-ibm-runtime

Describe the bug
6 test cases started failing without code changes in qiskit-ibm-runtime.
image

Steps to reproduce
Run PR tests

Preliminary analysis
Inspected the objects where self.assertEqual now fails with the aid of the debugger. In the failing cases op.coeff != decoded.coeff.
image

Runtime 0.1 - Programs

A user should basically be able to create, view, view all, update and delete program data and metadata. This epic can be used to track other enhancements made to programs for runtime 0.1 release.

  • pprint_programs
  • programs
  • program
  • upload_program
  • update_program
  • delete_program
  • set_program_visibility

Runtime 0.2 - Session

A user should be able to create a session with a running program and execute it multiple times by passing slightly different parameters to the program each time.

QAOA Runtime fails when setting mitigation and pulse efficient inputs

Describe the bug
When running the code from this tutorial : https://qiskit.org/documentation/optimization/tutorials/12_qaoa_runtime.html, when setting the backend to a real one, I have a QiskitError : TensoredMeasFitter doesn't support subset_fitter when setting measurement_error_mitigation=True, and a PulseError : "Operation 'cx' exists, but is only defined for qubits [(0, 1), (1, 0), (1, 2), (1, 3), (2, 1), (3, 1), (3, 4), (4, 3)]." when use_pulse_efficient=True

Steps to reproduce

from qiskit import IBMQ
provider = IBMQ.load_account()
import numpy as np

from qiskit.opflow import PauliSumOp, Z, I
from qiskit.algorithms.optimizers import SPSA
program_id = "qaoa"

# Define the cost operator to run.
op = (
    (Z ^ Z ^ I ^ I ^ I)
    - (I ^ I ^ Z ^ Z ^ I)
    + (I ^ I ^ Z ^ I ^ Z)
    - (Z ^ I ^ Z ^ I ^ I)
    - (I ^ Z ^ Z ^ I ^ I)
    + (I ^ Z ^ I ^ Z ^ I)
    + (I ^ I ^ I ^ Z ^ Z)
)

# SPSA helps deal with noisy environments.
optimizer = SPSA(maxiter=100)

# We will run a depth two QAOA.
reps = 2

# The initial point for the optimization, chosen at random.
initial_point = np.random.random(2 * reps)

# The backend that will run the programm.
#options = {"backend_name": "ibm_perth"}
options = {"backend_name": "ibmq_belem"}


# The inputs of the program as described above.
runtime_inputs = {
    "operator": op,
    "reps": reps,
    "optimizer": optimizer,
    "initial_point": initial_point,
    "shots": 2 ** 13,
    # Set to True when running on real backends to reduce circuit
    "measurement_error_mitigation": True,
    # depth by leveraging swap strategies. If False the
    # given optimization_level (default is 1) will be used.
    "use_swap_strategies": False,
    # Set to True when optimizing sparse problems.
    "use_initial_mapping": False,
    # Set to true when using echoed-cross-resonance hardware.
    "use_pulse_efficient": False,
}
job = provider.runtime.run(
    program_id=program_id,
    options=options,
    inputs=runtime_inputs,
)
result = job.result()

  • Qiskit IBM Runtime version: {'qiskit-terra': '0.19.1', 'qiskit-aer': '0.10.1', 'qiskit-ignis': '0.7.0', 'qiskit-ibmq-provider': '0.18.3', 'qiskit-aqua': '0.9.5', 'qiskit': '0.34.0', 'qiskit-nature': '0.3.0', 'qiskit-finance': '0.3.0', 'qiskit-optimization': '0.3.0', 'qiskit-machine-learning': '0.3.0'}
  • Python version: Python 3.8.0
  • Operating system: macOS Big Sur

Fix `jupyter` and `visualization` modules within `qiskit_ibm_runtime`

Problem
@jyu00 noticed that the jupyter and visualization modules within qiskit_ibm_runtime may not work. Prior to the first release (Runtime 0.1) we need to ensure they are functional, or are not referenced in the public documentation.

Acceptance criteria

  • Option 1) Both modules are documented and working
  • Option 2) The modules are not documented in the initial release and follow-up efforts are tracked

Stop caching Qobj in the job

What is the expected enhancement?

Today we cache Qobj in the job after submission, so that it's readily available if the user wants to access it. The problem is, as the size of the machines increases, so does the size of the Qobjs. Caching Qobj in the job means Python cannot garbage collect it. This gets much worse if one submits many jobs in a single Python session, like many algorithms do.

Instead of keep a reference to the Qobj in the job, we can just retrieve it on demand. It'd be slower for users who references the Qobj multiple times, but they can easily keep a local reference rather than doing job.circuits() each time.

Setup repository secrets

What is the expected feature or enhancement?
The following repository secrets need to be setup, for which I don't know the values for. @mtreinish Could you please help setup these?
ENCRYPTED_DEPLOY_PO_BRANCH_IV
ENCRYPTED_DEPLOY_PO_BRANCH_KEY
PYPI_API_TOKEN

Runtime 0.1 - Infrastructure

Aggregate bugs and tasks related to repo setup, continuous integration and other technical tasks required for runtime 0.1 release.

Merge qiskit-runtime into this repo

What is the expected feature or enhancement?

Currently there is a set of tutorials and program source code living in https://github.com/Qiskit-Partners/qiskit-runtime. It was created because qiskit-ibmq-provider had non-runtime services. But since this repo is only about runtime, it doesn't make sense to have 2 repos.

Acceptance criteria

qiskit-runtime is merged into qiskit-ibm-runtime.

Verify test coverage

What is the expected feature or enhancement?

Since there was a lot of rewrite and reusing old test cases, we should ensure the test cases provide sufficient coverage. This can be done manually or use some kind of tool as mentioned in #22.

Acceptance criteria

Verify there is sufficient test coverage.

Refactor environment variables used by test cases

What is the expected feature or enhancement?

We currently have the following environment variables after porting code from qiskit-ibm.
QISKIT_IBM_RUNTIME_API_URL
QISKIT_IBM_RUNTIME_API_TOKEN
QISKIT_IBM_RUNTIME_HGP
QISKIT_IBM_RUNTIME_PRIVATE_HGP
QISKIT_IBM_RUNTIME_DEVICE
QISKIT_IBM_RUNTIME_USE_STAGING_CREDENTIALS
QISKIT_IBM_RUNTIME_STAGING_API_TOKEN
QISKIT_IBM_RUNTIME_STAGING_API_URL
QISKIT_IBM_RUNTIME_STAGING_DEVICE
QISKIT_IBM_RUNTIME_STAGING_PRIVATE_HGP

Once we add support for IBM Cloud authentication we should have the below environment variables.

Cloud (Production)

QISKIT_IBM_CLOUD_API_LOCATOR
QISKIT_IBM_CLOUD_API_TOKEN
QISKIT_IBM_CLOUD_DEVICE

Cloud (Staging)

QISKIT_IBM_CLOUD_USE_STAGING_CREDENTIALS
QISKIT_IBM_CLOUD_STAGING_API_LOCATOR
QISKIT_IBM_CLOUD_STAGING_API_TOKEN
QISKIT_IBM_CLOUD_STAGING_DEVICE

Legacy (Production)

QISKIT_IBM_API_TOKEN
QISKIT_IBM_API_LOCATOR
QISKIT_IBM_HGP
QISKIT_IBM_PRIVATE_HGP
QISKIT_IBM_DEVICE

Legacy (Staging)

QISKIT_IBM_USE_STAGING_CREDENTIALS
QISKIT_IBM_STAGING_API_TOKEN
QISKIT_IBM_STAGING_API_LOCATOR
QISKIT_IBM_STAGING_HGP
QISKIT_IBM_STAGING_PRIVATE_HGP
QISKIT_IBM_STAGING_DEVICE

Enable Black Code Style

Use Black Code Style instead of pycodestyle.

What is the expected feature or enhancement?
Increased development efficiency, because

  • less time is needed to discuss if personal code style preferences do not match
    • pycodestyle leaves room for that
  • code style changes are applied or fixed automatically
    • pycodestyle requires developers to fix identified style issues manually

Inspired from Qiskit/qiskit#6361.

Technical Implementation

  • install black
  • reformat existing code via black folder1 folder 2
  • subsequently fail verification if black --check folder1 folder2 returns a non-zero exit code (to force contributors to adhere to the new code style)

The ibmq_lima seems very slow

I run a circuit that contains a single x gate with 1 shot on the ibmq_lima. Here is the result. Could you please help interpret it?

1gate-1shot

What is the difference between "Running: 6.2s" and "time in system 2.1s"?

Does it seem very slow to take 2.1 seconds to run a single shot?

I assume the 2.1s is perhaps some sort of fixed cost. I also run 1000 shots. It takes 2.4s. If my assumption is correct, it would take ibmq_lima (2.4 - 2.1 = 0.3s) to complete 1000 shots. That is still 2000 times slower than a classical simulator running on my cheap laptop.

I read this paper here: https://arxiv.org/abs/2110.14108, but that paper does not have a lot of real life examples. Is it possible to apply the theories presented in that paper to my example presented above?

I hope you would provide some practical benchmarks in the future. For example, you may benchmark some well-known algorithms: Shor, QFT, QPE, ground state energy, etc., on your real quantum hardware. Benchmarking them that way may not sound rigorous, but it may be more useful to average users such as a scientist, an engineer, etc.

[qiskit 0.33.0] Error - cannot execute a circuit-runner program

Describe the bug
circuit-runner ends in JobStatus.ERROR: 'job incurred error'

RuntimeJobFailureError: 'Unable to retrieve job result. Job c6oeij749l014bc1li40 has failed:\n2021-12-08T17:20:17.898524224Z /usr/local/lib/python3.8/site-packages/qiskit/circuit/qpy_serialization.py:1044: UserWarning: The qiskit version used to generate the provided QPY file, 0.19.0, is newer than the current qiskit version 0.18.3. This may result in an error if the QPY file uses instructions not present in this current qiskit version\n2021-12-08T17:20:17.898607193Z   warnings.warn(\n2021-12-08T17:20:17.900382476Z Traceback (most recent call last):\n2021-12-08T17:20:17.900445376Z   File "/code/program_starter.py", line 61, in <module>\n2021-12-08T17:20:17.900466190Z     user_params = json.loads(params, cls=RuntimeDecoder)\n2021-12-08T17:20:17.900484234Z   File "/usr/local/lib/python3.8/json/__init__.py", line 370, in loads\n2021-12-08T17:20:17.900502446Z     return cls(**kw).decode(s)\n2021-12-08T17:20:17.900524499Z   File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode\n2021-12-08T17:20:17.900540271Z     obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n2021-12-08T17:20:17.900557031Z   File "/usr/local/lib/python3.8/json/decoder.py", line 353, in raw_decode\n2021-12-08T17:20:17.900574133Z     obj, end = self.scan_once(s, idx)\n2021-12-08T17:20:17.900591325Z   File "/usr/local/lib/python3.8/site-packages/qiskit/providers/ibmq/runtime/utils.py", line 229, in object_hook\n2021-12-08T17:20:17.900608293Z     return _decode_and_deserialize(obj_val, qpy_serialization.load)[0]\n2021-12-08T17:20:17.900624306Z   File "/usr/local/lib/python3.8/site-packages/qiskit/providers/ibmq/runtime/utils.py", line 87, in _decode_and_deserialize\n2021-12-08T17:20:17.900642771Z     orig = deserializer(buff)\n2021-12-08T17:20:17.900659013Z   File "/usr/local/lib/python3.8/site-packages/qiskit/circuit/qpy_serialization.py", line 1053, in load\n2021-12-08T17:20:17.900676157Z     circuits.append(_read_circuit(file_obj))\n2021-12-08T17:20:17.900692123Z   File "/usr/local/lib/python3.8/site-packages/qiskit/circuit/qpy_serialization.py", line 1058, in _read_circuit\n2021-12-08T17:20:17.900709416Z     header, name, metadata = _read_header(file_obj)\n2021-12-08T17:20:17.900725306Z   File "/usr/local/lib/python3.8/site-packages/qiskit/circuit/qpy_serialization.py", line 467, in _read_header\n2021-12-08T17:20:17.900741567Z     metadata = json.loads(metadata_raw)\n2021-12-08T17:20:17.900759109Z   File "/usr/local/lib/python3.8/json/__init__.py", line 343, in loads\n2021-12-08T17:20:17.900775347Z     s = s.decode(detect_encoding(s), \'surrogatepass\')\n2021-12-08T17:20:17.900792170Z   File "/usr/local/lib/python3.8/encodings/utf_32_be.py", line 11, in decode\n2021-12-08T17:20:17.900807579Z     return codecs.utf_32_be_decode(input, errors, True)\n2021-12-08T17:20:17.900823068Z UnicodeDecodeError: \'utf-32-be\' codec can\'t decode bytes in position 4-7: code point not in range(0x110000)\n'

Steps to reproduce

circ = QuantumCircuit(2)
circ.h(0)
circ.cx(0,1)
circ.measure_all()
from qiskit.providers.ibmq import RunnerResult
backend=provider.backend.ibmq_qasm_simulator

program_inputs = {
    'circuits': circ,
}
options = {'backend_name': backend.name()}

job = provider.runtime.run(program_id="circuit-runner",
                           options=options,
                           inputs=program_inputs,
                          )
result = job.result(decoder=RunnerResult)

Expected behavior
Same job runs OK in qiskit 0.32.0 & 0.32.1

Additional Information

  • Qiskit version: qiskit 0.33.0 (local and Quantum Lab)
  • Python version: 3.8.3
  • Operating system: W10

Specify logging level when running a program

Ported from Qiskit/qiskit-ibm-provider#192.

What is the expected enhancement?

Users should be able to specify the logging level of a specific runtime execution instance when running a program. logging_level query parameter is being added to POST /jobs. Possible values for logging_level: critical, error, warning, info, debug, CRITICAL, ERROR, WARNING, INFO, DEBUG. Default is warning/WARNING.

Runtime 0.1 - Jobs

A user should basically be able to run a program, run sampler, run estimator, view, view all and delete jobs. This epic can be used to track other enhancements related to jobs.

  • run
  • job
  • jobs
  • delete_job

Don't overwrite account credentials unless explicitly specified

What is the expected feature or enhancement?

The old qiskit-ibmq-provider save_account() method required you to specify overwrite=True if the account you're trying to save already exists. This is handy to avoid accidental overwrite.

Acceptance criteria

A saved account can only be overwritten if overwrite=True is specified on save_account().

Mypy does not check types in test code

What is the expected feature or enhancement?
Mypy should also check test code and fail if typing issues are found. Would have avoided #80 (review) where tests had to fail to uncover that tests have not been updated to the latest method signatures.

Login using IBM Cloud API key

What is the expected feature or enhancement?
A user should be able to login using their IBM Cloud API Key.

class IBMRuntimeService(RuntimeService):
    def __init__(self, auth=None, token=None, locator=None):
        """Initialize a new client to use the runtime service.
        
        Args:
            auth: Authentication type. `cloud` or `legacy`. If not specified, the saved default is used.
                If there is no default value, and both accounts were saved on disk, the cloud type is used.
            token: Token used for authentication. If not specified, the saved token is used.
            locator: The authentication url, if `auth=legacy`. Otherwise the CRN.
        """
        pass

When the user does

service = IBMRuntimeService(token="<apikey>", locator=<CRN>)

no API calls would be made but the passed in values should be stored in the RuntimeClient.
And then for subsequent calls made to the API like service.programs() or service.pprint_programs() the
Service-CRN: <paste-CRN-here> and Authorization: apikey <paste-apikey-here> headers should be sent with every request.

The URL for production vs staging should be automatically determined based on the cname in the CRN. staging for staging vs bluemix for prod.

Example curl to get programs:

curl --location --request GET 'https://us-east.quantum-computing.cloud.ibm.com/programs' --header 'Service-CRN: <paste-CRN-here>' --header 'Authorization: apikey <paste-API-key-here>'

Runtime 0.1 - Authentication

A user should be able to login using either IBM Cloud API key or IQX API token, save account, view saved account, view active account and also delete saved account for runtime 0.1 release.

class IBMRuntimeService(RuntimeService):
    def __init__(self, auth=None, token=None, locator=None):
        """Initialize a new client to use the runtime service.
        
        Args:
            auth: Authentication type. `cloud` or `legacy`. If not specified, the saved default is used.
                If there is no default value, and both accounts were saved on disk, the cloud type is used.
            token: Token used for authentication. If not specified, the saved token is used.
            locator: The authentication url, if `auth=legacy`. Otherwise the CRN.
        """
        pass

    @staticmethod
    def delete_account(auth=None) -> None:
       """Delete account information on disk.
       Args:
           auth: Authentication type. `cloud` or `legacy`. If auth is not passed and if there is one account saved, that is 
               deleted. If auth is not passed and if there are two accounts saved then `cloud` is deleted first.
       """
       pass

    @staticmethod
    def save_account(token, locator, as_default) -> None:
        """Save account information on disk."""
        pass

   @staticmethod
    def saved_account() -> None:
        """Get saved account information on disk."""
        pass

    def active_account() -> None:
        """Get account currently in use for the session."""
        pass

    def logout(self) -> None:
        """Clears authorization cache on the server.

        For better performance, the runtime server caches each user's
        authorization information. This method is used to force the server
        to clear its cache.

        Note:
            Invoke this method ONLY when your access level to the runtime
            service has changed - for example, the first time your account is
            given the authority to upload a program.
        """

Clarify what to use tox for

What is the expected feature or enhancement?
Some workflow actions use tox for creating virtual environments (e.g. Build Docs), others don’t (e.g. lint & mypy). Also, some of the configurations in tox.ini appear outdated or unused.

The goal of this issue is to make it clear (e.g. for new contributors) what to use tox for and use it consistently in the Github actions.

Save credentials in JSON file

What is the expected feature or enhancement?

When saving credentials to disk today we use ~/.qiskit/qiskitrc file. We can refactor and simplify a lot of the code around this functionality by saving credentials in a JSON file.

Something like in ~/.qiskit/qiskit-ibm.json.

{
    "cloud": {
        "token": "<paste_API_KEY_here>",
        "locator": "<paste_CRN_here>"
    },
    "legacy": {
        "token": "<paste_API_KEY_here>",
        "locator": "<paste_API_URL_here>",
        "verify": True,
        "default_hgp": "hub/group/project"
    },
    "cloud-staging": {
        "token": "<paste_Staging_API_KEY_here>",
        "locator": "<paste_Staging_CRN_here>"
    },
    "legacy-staging": {
        "token": "<paste_Staging_API_KEY_here>",
        "locator": "<paste_API_URL_here>",
        "verify": True,
        "default_hgp": "hub/group/project"
    }
}

We can allow users to store multiple credentials by specifying a name when saving an account. In the above example the user has saved their staging cloud and legacy accounts by passing the names cloud-staging and legacy-staging.

IBMRuntimeService.save_account(token, name="cloud-staging") # save like this
IBMRuntimeService(name="cloud-staging") # initialize like this

service.run fails with error when options is not passed in

Describe the bug
It is now optional to pass in options to service.run. (Since a backend will get selected automatically when one is not specified in options) When we do that we get the below error.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/var/folders/jt/2qwx0rx17tl94gnll6wjftjc0000gn/T/ipykernel_52337/2427600266.py in <module>
      2     "iterations": 1
      3 }
----> 4 job = service.run(program_id="hello-world-mARpjmlEe9", inputs=inputs)

~/Documents/quantum/qiskit-ibm-runtime/qiskit_ibm_runtime/ibm_runtime_service.py in run(self, program_id, inputs, options, callback, result_decoder, instance)
    813         if isinstance(options, dict):
    814             options = RuntimeOptions(**options)
--> 815         options.validate(self.auth)
    816 
    817         backend = None

AttributeError: 'NoneType' object has no attribute 'validate'

Steps to reproduce

from qiskit_ibm_runtime import IBMRuntimeService
service = IBMRuntimeService() # assuming there is a saved cloud account
inputs = {
    "iterations": 1
}
job = service.run(program_id="hello-world-mARpjmlEe9", inputs=inputs)

Expected behavior
Should not get that error.

Suggested solutions

Additional Information

  • Qiskit IBM Runtime version:
  • Python version:
  • Operating system:

VQEProgram RuntimeJobFailureError when ansatz EfficientSU2() has no parameter specified

Describe the bug
VQEProgram fails when using ansatz = EfficientSU2() that does not have any parameter.
This specific ansatz works well in classical VQE (i guess some parameter values are used by default when none is specified)

Error stack message:

Traceback (most recent call last):
  File "C:\Users\poc\Anaconda3\envs\qiskit\lib\site-packages\qiskit_nature\runtime\vqe_program.py", line 282, in compute_minimum_eigenvalue
    result = job.result()
  File "C:\Users\poc\Anaconda3\envs\qiskit\lib\site-packages\qiskit\providers\ibmq\runtime\runtime_job.py", line 151, in result
    raise RuntimeJobFailureError(f"Unable to retrieve job result. "
qiskit.providers.ibmq.runtime.exceptions.RuntimeJobFailureError: 'Unable to retrieve job result. Job c6kd626gkavn0ge25jng has failed:\n2021-12-02T14:08:52.305396155Z Traceback (most recent call last):\n2021-12-02T14:08:52.305396155Z   File "/code/program_starter.py", line 61, in <module>\n2021-12-02T14:08:52.305396155Z     user_params = json.loads(params, cls=RuntimeDecoder)\n2021-12-02T14:08:52.305396155Z   File "/usr/local/lib/python3.8/json/__init__.py", line 370, in loads\n2021-12-02T14:08:52.305396155Z     return cls(**kw).decode(s)\n2021-12-02T14:08:52.305396155Z   File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode\n2021-12-02T14:08:52.305396155Z     obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n2021-12-02T14:08:52.305396155Z   File "/usr/local/lib/python3.8/json/decoder.py", line 353, in raw_decode\n2021-12-02T14:08:52.305396155Z     obj, end = self.scan_once(s, idx)\n2021-12-02T14:08:52.305396155Z   File "/usr/local/lib/python3.8/site-packages/qiskit/providers/ibmq/runtime/utils.py", line 229, in object_hook\n2021-12-02T14:08:52.305396155Z     return _decode_and_deserialize(obj_val, qpy_serialization.load)[0]\n2021-12-02T14:08:52.305396155Z   File "/usr/local/lib/python3.8/site-packages/qiskit/providers/ibmq/runtime/utils.py", line 87, in _decode_and_deserialize\n2021-12-02T14:08:52.305396155Z     orig = deserializer(buff)\n2021-12-02T14:08:52.305396155Z   File "/usr/local/lib/python3.8/site-packages/qiskit/circuit/qpy_serialization.py", line 1053, in load\n2021-12-02T14:08:52.305396155Z     circuits.append(_read_circuit(file_obj))\n2021-12-02T14:08:52.305396155Z   File "/usr/local/lib/python3.8/site-packages/qiskit/circuit/qpy_serialization.py", line 1154, in _read_circuit\n2021-12-02T14:08:52.305396155Z     circ = QuantumCircuit(\n2021-12-02T14:08:52.305396155Z   File "/usr/local/lib/python3.8/site-packages/qiskit/circuit/quantumcircuit.py", line 195, in __init__\n2021-12-02T14:08:52.305396155Z     self.add_register(*regs)\n2021-12-02T14:08:52.305396155Z   File "/usr/local/lib/python3.8/site-packages/qiskit/circuit/quantumcircuit.py", line 1167, in add_register\n2021-12-02T14:08:52.305396155Z     regs = (QuantumRegister(regs[0], "q"), ClassicalRegister(regs[1], "c"))\n2021-12-02T14:08:52.305396155Z   File "/usr/local/lib/python3.8/site-packages/qiskit/circuit/register.py", line 86, in __init__\n2021-12-02T14:08:52.305396155Z     raise CircuitError(\n2021-12-02T14:08:52.305396155Z qiskit.circuit.exceptions.CircuitError: "Register size must be positive (int \'0\' was provided)"\n'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File ".\minimal_example - vqeclient gss.py", line 64, in <module>
    result = ground_state_solver.solve(problem=problem)
  File "C:\Users\poc\Anaconda3\envs\qiskit\lib\site-packages\qiskit_nature\algorithms\ground_state_solvers\ground_state_eigensolver.py", line 111, in solve
    raw_mes_result = self._solver.compute_minimum_eigenvalue(main_operator, aux_ops)
  File "C:\Users\poc\Anaconda3\envs\qiskit\lib\site-packages\qiskit_nature\runtime\vqe_program.py", line 284, in compute_minimum_eigenvalue
    raise RuntimeError(f"The job {job.job_id()} failed unexpectedly.") from exc
RuntimeError: The job c6kd626gkavn0ge25jng failed unexpectedly.

Steps to reproduce
ansatz = EfficientSU2()
backend = provider.get_backend('ibmq_qasm_simulator')
quantum_instance = QuantumInstance(backend=backend, optimization_level=3)
optimizer = SPSA(maxiter=10)
minimum_eigen_solver = VQEProgram(
ansatz=ansatz, optimizer=optimizer, provider=provider, backend=backend
)
result = ground_state_solver.solve(problem=problem)

Expected behavior

Suggested solutions
Error message might be explicit or Runtime VQEProgram might use predefined default parameters

Additional Information

  • Qiskit IBM Runtime version:
    qiskit 0.32.0
    qiskit-aer 0.9.1
    qiskit-aqua 0.9.5
    qiskit-experiments 0.1.0
    qiskit-finance 0.2.1
    qiskit-ibmq-provider 0.18.0
    qiskit-ignis 0.6.0
    qiskit-ionq 0.1.4
    qiskit-machine-learning 0.2.1
    qiskit-nature 0.2.2
    qiskit-optimization 0.2.3
    qiskit-terra 0.18.3
  • Python version: 3.8
  • Operating system: Windows

Runtime 0.1 - Overall Status

Scope

This issue is meant to give an overall status overview related to the enablement of IBMRuntimeService APIs for Cloud runtime support (0.1) in the qiskit-ibm-runtime library.

Status

Must have:

Theme IBMRuntimeService API Status Legacy Status Cloud
Authentication active_account
Authentication delete_account
Authentication save_account
Authentication accounts
Authentication logout 🚫 🚫
Programs delete_program
Programs pprint_programs
Programs program
Programs programs
Programs set_program_visibility
Programs update_program
Programs upload_program
Jobs delete_job
Jobs job
Jobs jobs
Jobs run
Jobs run_circuits 🚫 🚫
Jobs sample 🚫 🚫
Jobs estimate 🚫 🚫
Backends backends
Backends backend
Other my_reservations 🚫 🚫
BackendV2 🔜 🔜 #102
API Documentation
Tutorials ⚠️
Merge in qiskit-ibm repo

Nice to have (in priority order):

✅ = done (i.e. users can run IBMRuntimeService().xxx or IBMRuntimeService.yyy for static methods)
🚫 = not supported
🔜 = work in progress (links to a PR)
⚠️ = blocked / need more info

Fully automate the release process

What is the expected feature or enhancement?
As a maintainer, I want to release a new version with confidence in a fully automated way.

As-is
Some parts of the release (e.g. push to PyPi) are already automated and triggered when a tag is pushed. Others (e.g. generation of release notes, verification of tests) involve manual steps.

Reenable disabled pylint rules that we don't consider too verbose

What is the expected feature or enhancement?
This is a follow-up item for #40 (comment).

We have disabled a few pylint rules to unblock an update to the latest Python / pylint version. Below rules have been marked with a TODO and should be reenabled when the code has been fixed:

  • arguments-renamed (stay disabled)
  • bad-mcs-classmethod-argument,
  • consider-iterating-dictionary,
  • consider-using-dict-items,
  • consider-using-f-string (stay disabled),
  • consider-using-with (stay disabled),
  • differing-param-doc,
  • docstring-first-line-empty (stay disabled),
  • f-string-without-interpolation,
  • invalid-name,
  • missing-param-doc (stay disabled),
  • missing-type-doc,
  • no-member (stay disabled),
  • raise-missing-from (stay disabled),
  • redundant-returns-doc,
  • super-with-arguments,
  • unspecified-encoding,
  • use-dict-literal,
  • use-list-literal,

Revive IQX dashboard widget

What is the expected feature or enhancement?

In qiskit-ibmq-provider there was an IQX dashboard that displayed backends as well as legacy jobs. It'd be nice to have something similar, especially for cloud runtime since they don't show up on IQX.

Acceptance criteria

A user can see runtime backend and job information on a dashboard.

Revive or discontinue HTML representation for IBM Backends

What is the expected feature or enhancement?
In qiskit-ibmq-provider users could opt-in to HTML representation of IBM backends by importing qiskit.providers.ibmq.jupyter

# cf. https://github.com/Qiskit/qiskit-ibmq-provider/blob/master/docs/tutorials/2_jupyter_tools.ipynb
import qiskit.providers.ibmq.jupyter  # This is the where the magic happens (literally).
from qiskit.providers.ibmq import least_busy

backend = least_busy(...)
backend

As a result the backend information was displayed as an HTML widget
image

The related code has been ported to qiskit-ibm-runtime but not been updated to work with latest code changes. Therefore displaying a backend fails when qiskit_ibm_runtime.jupyter is imported. As this is not a documented API, it's not an issue that users are likely to hit.

import qiskit_ibm_runtime.jupyter
backend = # ...
backend

Acceptance criteria

  • Option 1 - HTML representation of IBM backends is documented, tested and works
  • Option 2 - HTML representation of IBM backends is discontinued, dead code paths have been removed

Failed cron job tests

Compiling all of the consistently failing cron job tests here to avoid constantly scrolling through all the logs
Also makes it easier to track

Tests that failed multiple times in past 30 days:

Cron prod

  • test_retrieve_interim_results, test_run_program_failed link
  • test_stream_results_done, test_retrieve_job_running link
  • test_job_logs link

Cron staging

  • test_callback_cancel_job link
  • test_interim_result_callback link
  • test_stream_results link

Slow test

  • test suite exceeds 6 hours link
  • test_callback_cancel_job, test_retrieve_interim_results link
  • test_retrieve_unauthorized_program_data link
  • test_retrieve_returned_jobs link

Terra main

  • test_run_program_real_device link
  • many failed jobs that don't fail consistently

will check the cron jobs daily to keep this issue updated

Allow user to specify human readable service instance name during authentication

What is the expected feature or enhancement?
As per the current approved design, we can pass IBM Cloud API Key (token) and CRN (locator) parameters to authenticate.
Since the CRN is long and not easy to remember, we could also provide another option for the user to specify the human readable service instance name in the locator parameter.

For example:

service = IBMRuntimeService(token=<token>, locator="Quantum Services-og")

Suggested Solution:

  1. Get IAM Access Token by passing API Key
curl -X POST 'https://iam.test.cloud.ibm.com/identity/token' -H 'Content-Type: application/x-www-form-urlencoded' -d 'grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey=<api_key>'
  1. Use IAM Access token from step 1 and service instance name (Ex: Quantum Services-og) to get the resource.
curl -X GET "https://resource-controller.test.cloud.ibm.com/v2/resource_instances?name=Quantum%20Services-og" -H "Authorization: Bearer <access_token>"

Then read the CRN from the resource data returned which looks like below, to make further calls to other runtime APIs.

{
  "rows_count": 1,
  "next_url": null,
  "resources": [
    {
      "id": "crn:v1:staging:public:quantum-computing:us-east:a/78d9efd23fdb4894837f663626efb044:7d4e1dd0-b3e1-415b-b601-5fc8b38dd8b2::",
      "guid": "7d4e1dd0-b3e1-415b-b601-5fc8b38dd8b2",
      "url": "/v2/resource_instances/7d4e1dd0-b3e1-415b-b601-5fc8b38dd8b2",
      "created_at": "2021-10-25T20:58:21.141685368Z",
      "updated_at": "2021-10-25T20:58:22.668667668Z",
      "deleted_at": null,
      "created_by": "IBMid-55000AJFHA",
      "updated_by": "",
      "deleted_by": "",
      "scheduled_reclaim_at": null,
      "restored_at": null,
      "scheduled_reclaim_by": "",
      "restored_by": "",
      "name": "Quantum Services-og",
      "region_id": "us-east",
      "account_id": "78d9efd23fdb4894837f663626efb044",
      "reseller_channel_id": "",
      "resource_plan_id": "88f4f591-8b8f-4fc7-94ba-7328d5027508",
      "resource_group_id": "c365e8f9d4114785b805b96aeb6962c7",
      "resource_group_crn": "crn:v1:staging:public:resource-controller::a/78d9efd23fdb4894837f663626efb044::resource-group:c365e8f9d4114785b805b96aeb6962c7",
      "target_crn": "crn:v1:staging:public:globalcatalog::::deployment:88f4f591-8b8f-4fc7-94ba-7328d5027508%3Aus-east95730",
      "allow_cleanup": false,
      "crn": "crn:v1:staging:public:quantum-computing:us-east:a/78d9efd23fdb4894837f663626efb044:7d4e1dd0-b3e1-415b-b601-5fc8b38dd8b2::",
      "state": "active",
      "type": "service_instance",
      "resource_id": "b6049020-80f4-11eb-a0f7-e35ec9b4054f",
      "dashboard_url": "http://test.cloud.ibm.com/qc-service-details",
      "last_operation": {
        "type": "create",
        "state": "succeeded",
        "async": false,
        "description": "Completed create instance operation"
      },
      "resource_aliases_url": "/v2/resource_instances/7d4e1dd0-b3e1-415b-b601-5fc8b38dd8b2/resource_aliases",
      "resource_bindings_url": "/v2/resource_instances/7d4e1dd0-b3e1-415b-b601-5fc8b38dd8b2/resource_bindings",
      "resource_keys_url": "/v2/resource_instances/7d4e1dd0-b3e1-415b-b601-5fc8b38dd8b2/resource_keys",
      "plan_history": [
        {
          "resource_plan_id": "88f4f591-8b8f-4fc7-94ba-7328d5027508",
          "start_date": "2021-10-25T20:58:21.141685368Z",
          "requestor_id": "IBMid-55000AJFHA"
        }
      ],
      "migrated": false,
      "controlled_by": "",
      "locked": false
    }
  ]
}

I don't like this solution since it makes 2 additional API calls, but it is up to the user to choose this method and sacrifice speed for convenience.

Note: We can throw a warning asking user to use CRN when multiple service instances with the same name are returned.

@daka1510 @jyu00 Thoughts or suggestions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.