Fire Opal RIKEN Client
This is the Fire Opal client integration for RIKEN quantum computing infrastructure using a gRPC client.
Architecture Overview
- Client: Qiskit
SamplerV2implementation that sends circuits to Fire Opal server for optimization - Server: gRPC service that performs Fire Opal preprocessing/postprocessing
Installation
Choose the version that matches where you are logged in:
- Fugaku: install the
sqcversion. - R-CCS cloud: install the
ibmversion.
Fugaku
Complete these steps before you install:
- Create a JHPC Quantum account. Sign up here: https://idp.qc.r-ccs.riken.jp/realms/jhpc-quantum/account
- Set up and install your CA certificate and JWT token in your Fugaku home directory. The JWT token must be located at
$HOME/.sqc_rpc_sched/jwt.token. - Set up your Python environment by following this guide: https://github.com/jhpc-quantum/documents/blob/main/Qiskit_JHPC_Quantum_user_guide.md
After you finish the steps above, install the sqc version:
pip install 'qctrl-fire-opal-riken-client[sqc]'
R-CCS cloud
The steps above are not required for R-CCS cloud. Install the ibm version:
pip install 'qctrl-fire-opal-riken-client[ibm]'
Usage
Here is a small example of how to use the Fire Opal RIKEN client with Qiskit. This communicates with a gRPC server to perform Fire Opal optimizations on a quantum circuit before executing it. Once the job is complete, post-processed results are returned from the job.result() call.
The only difference between Fugaku (sqc) and R-CCS cloud (ibm) is how the QiskitRuntimeService channel and backend are set up, as noted in the comments below.
from qiskit import QuantumCircuit
from fireopalrikenclient.sampler import FireOpalSampler
from qiskit_ibm_runtime import QiskitRuntimeService
# Create circuit.
circuit = QuantumCircuit(2)
circuit.h(0)
circuit.cx(0, 1)
circuit.measure_all()
# Create sampler with Fire Opal preprocessing.
#
# On Fugaku (`sqc`), use the `jhpc_quantum` channel and the `ibm_sqc` backend.
# No `token` or `instance` is needed here, since those are provided by your
# SQC environment setup.
service = QiskitRuntimeService(channel="jhpc_quantum")
sampler = FireOpalSampler(mode=service.backend("ibm_sqc"))
#
# On R-CCS cloud (`ibm`), use the `ibm_quantum_platform` channel and the
# `ibm_kobe` backend. Replace `token` and `instance` with your `ibm_kobe`
# credentials provided by RIKEN.
# service = QiskitRuntimeService(token="...", instance="...", channel="ibm_quantum_platform")
# sampler = FireOpalSampler(mode=service.backend("ibm_kobe"))
# Run circuit with 1024 shots using Fire Opal optimization.
sampler_pub = (circuit, None, 1024)
job = sampler.run([sampler_pub])
result = job.result()
# Access the results
print(f"Number of pub results: {len(result)}")
print(f"Metadata: {result.metadata}")
# Access individual pub results by iterating over the result
for i, pub_result in enumerate(result):
print(f"Pub {i}: {pub_result}")
# Or access a single pub result directly by index
print(f"First pub result: {result[0]}")
Simulate dynamics (preview)
Note: Simulate Dynamics is a preview feature. It is currently only supported on R-CCS cloud with the
ibmversion of the client (ibm_kobe). Importingfireopalrikenclient.dynamicswith thesqcversion installed raises aNotImplementedError.
FireOpalSimulateDynamics simulates the time evolution of a 1D Fermi-Hubbard model on the device and returns the error-mitigated expectation values of the requested observables at each time step. Fire Opal compiles the simulation into a set of circuits, which are run on the device. Once the job is complete, job.result() post-processes the device results and returns a FermiHubbardSolution.
from fireopalrikenclient.simulate_dynamics import (
FireOpalSimulateDynamics,
ModelType,
SimulationType,
SparseOccupationOperators,
)
from qiskit_ibm_runtime import QiskitRuntimeService
# Replace `token` and `instance` with your `ibm_kobe` credentials provided by RIKEN.
service = QiskitRuntimeService(token="...", instance="...", channel="ibm_quantum_platform")
backend = service.backend("ibm_kobe")
# Define the 1D Fermi-Hubbard model and the time-evolution scheme.
model = ModelType(hopping_amplitude=1.0, on_site_interaction=4.0, chemical_potential=0.0)
simulation = SimulationType(time_step=0.1, step_count=10)
# The initial state has one character per site (at most 64 sites):
# "u" (spin up), "d" (spin down), "b" (both) or "e" (empty).
initial_state = "udbe"
# Measure the spin-up occupation of site 0 and the total occupation of site 1.
observables = [
SparseOccupationOperators(operators=[[("Nup", 0)]], coefficients=[1.0]),
SparseOccupationOperators(
operators=[[("Nup", 1)], [("Ndn", 1)]], coefficients=[1.0, 1.0]
),
]
job = FireOpalSimulateDynamics(mode=backend).run(
model=model,
initial_state=initial_state,
simulation=simulation,
observables=observables,
shot_count=1024,
)
solution = job.result()
# One list of expectation values (one per time step) for each observable.
for observable, values in zip(solution.observables, solution.observable_expectation_values):
print(f"{observable}: {values}")
print(f"Provider job IDs: {solution.provider_job_ids}")
print(f"Warnings: {solution.warnings}")
Monte Carlo integration (preview)
Note: Monte Carlo integration is a preview feature. It is currently only supported on R-CCS cloud with the
ibmversion of the client (ibm_kobe), in job mode: pass the backend asmode, not aSessionorBatch. Importingfireopalrikenclient.monte_carlowith thesqcversion installed raises aNotImplementedError.
FireOpalMonteCarloIntegrator estimates an expectation value with quantum Monte Carlo integration. The integration is adaptive: Fire Opal designs each round's circuits from the results of the rounds before it, so it runs as one device job per round. run() submits the first round and returns a job that runs the remaining rounds in the background, and job.result() waits for the MonteCarloResult.
import numpy as np
from qiskit import QuantumCircuit, QuantumRegister
from fireopalrikenclient.monte_carlo import FireOpalMonteCarloIntegrator
from qiskit_ibm_runtime import QiskitRuntimeService
# Replace `token` and `instance` with your `ibm_kobe` credentials provided by RIKEN.
service = QiskitRuntimeService(token="...", instance="...", channel="ibm_quantum_platform")
backend = service.backend("ibm_kobe")
# Estimate E[f(X)] for X uniform on {0, 1, 2, 3} and f(x) = sin^2(pi * x / 12).
# The preparation circuit loads the distribution into `state` and rotates the single
# `output` qubit so that P(output = 1) = E[f(X)], which is what the integrator estimates.
state = QuantumRegister(2, "state")
output = QuantumRegister(1, "output")
preparation = QuantumCircuit(state, output)
preparation.h(state)
preparation.cry(np.pi / 6, state[0], output[0])
preparation.cry(np.pi / 3, state[1], output[0])
integrator = FireOpalMonteCarloIntegrator(
mode=backend,
options={"max_iteration_count": 10, "target_variance": 1e-4},
)
problem = {"preparation_circuit": preparation}
job = integrator.run(problem) # Prints the task ID.
result = job.result()
print(f"Estimate: {result.estimate} +/- {result.variance ** 0.5}")
print(f"Iterations: {result.iteration_count}")
print(f"Provider job IDs: {result.provider_job_ids}")
If the Python process stops before the integration finishes, for example when a notebook is closed, continue it with the task ID that run() printed. The server keeps the integration's progress for 10 days.
job = integrator.resume(task_id="...", problem=problem)
result = job.result()
Metadata
Release files for qctrl-fire-opal-riken-client 1.7.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qctrl_fire_opal_riken_client-1.7.1.tar.gz | 137.2 kB | Without provenance | Details for qctrl_fire_opal_riken_client-1.7.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| qctrl_fire_opal_riken_client-1.7.1-py3-none-any.whl | Python 3 | none | any | Details for qctrl_fire_opal_riken_client-1.7.1-py3-none-any.whl |
Total release size: 295.7 kB
Release files / qctrl_fire_opal_riken_client-1.7.1.tar.gz
| Download URL | qctrl_fire_opal_riken_client-1.7.1.tar.gz |
|---|---|
| Size | 137.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
887aca4a8e848e9b5cdb2985b62174c12aae0356d4a3ecf064c26db57c470697
|
|
BLAKE2b-256 checksum How to use checksums |
08b1356c68b24c0dadcd2c92f773f1b40c9d83b0939c5af1d2adc20eff2c3d56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.0 CPython/3.11.17 Linux/6.17.0-1022-azure
|
Release files / qctrl_fire_opal_riken_client-1.7.1-py3-none-any.whl
| Download URL | qctrl_fire_opal_riken_client-1.7.1-py3-none-any.whl |
|---|---|
| Size | 158.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4fd86efc6b0eb9dafd0e4bb3a03abf8ab73b29d4bdf1acb74e51faba847dd813
|
|
BLAKE2b-256 checksum How to use checksums |
9b24a847f7472748029d9214d604202364454a131397e062b3e4e280c20da7cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.0 CPython/3.11.17 Linux/6.17.0-1022-azure
|
Security for qctrl-fire-opal-riken-client 1.7.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.