OQTOPUS QRMI - Examples in Rust#


Prerequisites#

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

{device_id}_QRMI_OQTOPUS_URL

OQTOPUS Cloud API endpoint

{device_id}_QRMI_OQTOPUS_API_TOKEN

OQTOPUS Cloud API token

{device_id}_QRMI_OQTOPUS_PROXY

Proxy(Optional)

{device_id}_QRMI_OQTOPUS_TIMEOUT

HTTP request timeout seconds. (e.g. 30.0)

{device_id}_QRMI_OQTOPUS_RETRY_BACKOFF_SECONDS

Exponential backoff base seconds.(e.g. 0.2)

{device_id}_QRMI_OQTOPUS_RETRY_STATUS_CODES

HTTP status codes treated as retryable. (e.g. 429,500,502,503)

{device_id}_QRMI_OQTOPUS_RETRY_METHODS

HTTP methods treated as retryable.(e.g. GET,POST)

Create OQTOPUS program input file as input#

Refer to this tool to generate. You can customise quantum circuits by editing the code.

How to build this example#

cargo clean
cargo build --release

How to run this example#

../target/release/qrmi-example-oqtopus -h
QRMI for OQTOPUS - Example

Usage: qrmi-example-oqtopus [OPTIONS] --device-id <DEVICE_ID> --input <INPUT> --name <NAME>

Options:
  -d, --device-id <DEVICE_ID>  device ID
  -i, --input <INPUT>          QASM file
  -n, --name <NAME>            job name
  -s, --shots <SHOTS>          # of shots. If omitted, OQTOPUS's default shot count is used
  -h, --help                   Print help
  -V, --version                Print version

For example:

# .env
qulacs_QRMI_OQTOPUS_URL=https://demo-api.oqtopus.io
qulacs_QRMI_OQTOPUS_API_TOKEN=your api token
PY_BRIDGE_PATH=<path/to/liboqtopus_py_bridge.so>

../target/release/qrmi-example-oqtopus --device-id qulacs --input ../../../task_runner/oqtopus/bell_state.txt --name "QRMI Rust example" --shots 500