Skip to main content

Cirq-Open Quantum Plugin

Beta. This plugin is in beta; its API and defaults may still change. Feedback is welcome in the Quantum Rings community.

A Cirq sampler that submits circuits to the Open Quantum platform. Write circuits with Cirq and run them on real quantum hardware.

How it works

Cirq exports OpenQASM natively (cirq.Circuit.to_qasm()), so this plugin does not depend on the Qiskit plugin. OpenQuantumSampler is a thin cirq.Sampler:

  • OpenQuantumClient.from_env (Core SDK) handles authentication and backend discovery.
  • Each resolved circuit is serialized to OpenQASM and submitted through the framework-agnostic SchedulerClient.
  • Platform counts are reconstructed into cirq.Result objects.

Because it implements run_sweep, the standard cirq.Sampler methods — run, sample, run_sweep, and run_batch — all work.

Installation

# Plugin (and core SDK)
pip install openquantum-sdk-cirq

# or via extras:
pip install "openquantum-sdk[cirq]"

This pulls in cirq-core and openquantum-sdk.

Quick Start

import cirq
from cirq_openquantum import OpenQuantumSampler

sampler = OpenQuantumSampler(
    backend="ionq:forte-1",
    client_id="your_client_id",
    client_secret="your_client_secret",
)

q = cirq.LineQubit.range(2)
circuit = cirq.Circuit([
    cirq.H(q[0]),
    cirq.CNOT(q[0], q[1]),
    cirq.measure(*q, key="m"),
])

result = sampler.run(circuit, repetitions=1024)
print(result.histogram(key="m"))
# Counter({0: ~512, 3: ~512})   # 00 and 11

Circuits must contain at least one cirq.measure(...); the QASM exporter does not add measurements for you.

Authentication

Resolved in this order:

  1. Pre-built client — pass client=OpenQuantumClient(...) for full control (saved accounts, custom URLs, keyring).
  2. Bearer token — pass token= or set OPENQUANTUM_TOKEN.
  3. Client credentials — pass client_id= + client_secret= or set OPENQUANTUM_CLIENT_ID + OPENQUANTUM_CLIENT_SECRET.
Parameter Environment Variable Description
token OPENQUANTUM_TOKEN Bearer token
client_id OPENQUANTUM_CLIENT_ID OAuth2 client ID
client_secret OPENQUANTUM_CLIENT_SECRET OAuth2 client secret
OPENQUANTUM_SDK_KEY Path to an SDK-key JSON file ({client_id, client_secret})
organization_id OPENQUANTUM_ORGANIZATION_ID Organization UUID (optional if single org)
scheduler_url OPENQUANTUM_SCHEDULER_URL Scheduler API base, when the argument is omitted
management_url OPENQUANTUM_MANAGEMENT_URL Management API base, when the argument is omitted
keycloak_base OPENQUANTUM_KEYCLOAK_BASE Keycloak base, when the argument is omitted
realm OPENQUANTUM_KEYCLOAK_REALM Keycloak realm, when the argument is omitted

from_env() raises AuthenticationError when no credential resolves. The older OPENQUANTUM_*_BASE URL names are not read here; those remain an MCP-only fallback.

Configuration

Parameter Default Description
backend required Backend class ID or short_code (e.g. "ionq:forte-1")
job_subcategory_id "oth:oth" Workload subcategory (set the most specific match)
execution_plan "auto" "auto", "public", "private", an enum, or a plan UUID. "auto" picks the cheapest plan
queue_priority "auto" "auto", "standard", "priority", "instant", an enum, or a priority UUID. "auto" picks the cheapest priority
export_format "qasm3" "qasm2" or "qasm3"
configuration_data {} Backend-specific config passthrough (e.g. {"engine": "amber_quantum_rings"})
reverse_bits True Reverse platform bitstrings to Cirq's big-endian order
verbose False Print submission progress and credit cost to stdout
job_timeout_seconds 86400 Max wait for job completion (1 day)

Shots are set per run via repetitions and injected into configuration_data.

Backend-specific configuration

Some backends require extra fields. The free Quantum Rings simulator (qr:gpu-gb10) requires an engine:

sampler = OpenQuantumSampler(
    backend="qr:gpu-gb10",
    configuration_data={"engine": "amber_quantum_rings"},
)

Bit ordering

The platform returns counts little-endian (the first classical bit is the rightmost character, Qiskit-style), while Cirq is big-endian (the first measured qubit is the most-significant bit). The sampler reverses each bitstring by default (reverse_bits=True) so the mapping is correct, verified live against an asymmetric |10> state. Set reverse_bits=False only for a backend that returns counts big-endian.

License

Apache License 2.0

Metadata

Release files for openquantum-sdk-cirq 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openquantum-sdk-cirq 0.5.0
File Size Uploaded Provenance Actions
openquantum_sdk_cirq-0.5.0.tar.gz 15.7 kB Without provenance Details for openquantum_sdk_cirq-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for openquantum-sdk-cirq 0.5.0
File Interpreter ABI Platform Actions
openquantum_sdk_cirq-0.5.0-py3-none-any.whl Python 3 none any Details for openquantum_sdk_cirq-0.5.0-py3-none-any.whl

Total release size: 26.6 kB

Release files / openquantum_sdk_cirq-0.5.0.tar.gz

Download URL openquantum_sdk_cirq-0.5.0.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a19176031c91138ef88337c03beb65b0346a9124a5c23930647f9cf26d7e7652
BLAKE2b-256 checksum
How to use checksums
e1ad575b0a6e2da69c1c9c3cc43d229860ddd8729578a66e8187d7f1fedfd360
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / openquantum_sdk_cirq-0.5.0-py3-none-any.whl

Download URL openquantum_sdk_cirq-0.5.0-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f269c3a95e77f4596bf789de5674e5c936cd92ca98cfe51d7d867f6050bd1d66
BLAKE2b-256 checksum
How to use checksums
55098a392c059598f4b461dbe0ce78bd7510c7108456041aa0317474a8eebbda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for openquantum-sdk-cirq 0.5.0

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.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page