Quantum System QRMI - Examples in Python#
Prerequisites#
Rust 1.85.1 or above
Python 3.11 or 3.12
Install the QRMI Python package
Install dependencies#
source ~/py311_qrmi_venv/bin/activate
pip install -r ../requirements.txt
Set environment variables#
Because QRMI is an environment variable driven software library, all
configuration parameters must be specified in environment variables. The
required environment variables are listed below. This example assumes
that a .env file is available under the current directory.
Environment variables |
Descriptions |
|---|---|
|
Quantum System endpoint URL |
|
IBM Cloud IAM endpoint
URL (e.g. |
|
IBM Cloud IAM API Key |
|
Cloud Resource Name (CRN) of the
provisioned Quantum System
instance, starting with
|
|
AWS Access Key ID to access S3 bucket |
|
AWS Secret Access Key to access S3 bucket |
|
S3 endpoint URL |
|
S3 bucket name |
|
S3 bucket region
name (e.g. |
|
Time (in seconds) after which job should time out and get cancelled. It is based on system execution time (not wall clock time). System execution time is the amount of time that the system is dedicated to processing your job. |
Create Qiskit Primitive input file as input#
Refer to this tool to generate. You can customise quantum circuits by editing the code.
Note
Use the file with name ending _params_only.json,
e.g. sampler_input_ibm_torino_params_only.json.
How to run this example#
Run example.py:
python example.py -h
usage: example.py [-h] backend input program_id
An example of IBM Quantum System QRMI
positional arguments:
backend backend name
input primitive input file
program_id 'estimator' or 'sampler'
options:
-h, --help show this help message and exit
For example:
export test_eagle_QRMI_IBM_QS_ENDPOINT=http://localhost:8080
export test_eagle_QRMI_IBM_QS_IAM_ENDPOINT=https://iam.cloud.ibm.com
export test_eagle_QRMI_IBM_QS_IAM_APIKEY=your_apikey
export test_eagle_QRMI_IBM_QS_SERVICE_CRN=your_instance
export test_eagle_QRMI_IBM_QS_AWS_ACCESS_KEY_ID=your_aws_access_key_id
export test_eagle_QRMI_IBM_QS_AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key
export test_eagle_QRMI_IBM_QS_S3_ENDPOINT=https://s3.us-east.cloud-object-storage.appdomain.cloud
export test_eagle_QRMI_IBM_QS_S3_BUCKET=test
export test_eagle_QRMI_IBM_QS_S3_REGION=us-east
export test_eagle_QRMI_JOB_TIMEOUT_SECONDS=86400
python example.py test_eagle sampler_input.json sampler