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": "SCARLET_CPU", "precision": "DOUBLE", "performance": "AUTOMATIC"} for qr:sim)
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

qr:sim requires an engine. It defaults to Scarlet, double precision, and automatic performance. The engine is SCARLET_CPU.

sampler = OpenQuantumSampler(
    backend="qr:sim",
    configuration_data={
        "engine": "SCARLET_CPU",
        "precision": "DOUBLE",
        "performance": "AUTOMATIC",
    },
)

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.6.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.6.0
File Size Uploaded Provenance Actions
openquantum_sdk_cirq-0.6.0.tar.gz 16.0 kB Without provenance Details for openquantum_sdk_cirq-0.6.0.tar.gz

Built distribution (wheel)

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

Total release size: 27.0 kB

Release files / openquantum_sdk_cirq-0.6.0.tar.gz

Download URL openquantum_sdk_cirq-0.6.0.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
511b90797fc8c9ecd4df307120aff4d86dc0440f42eee9c036efd0d4a9a6fe3d
BLAKE2b-256 checksum
How to use checksums
e3f121eedfabac78bcc03d8a7ddbf4c4ade4d1616791d6869e4a456e8c568f6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

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

Download URL openquantum_sdk_cirq-0.6.0-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd56837bb62ae8ec0b2c5172e29afd4dffc7faedfe8eb001a7cfc239f2a86163
BLAKE2b-256 checksum
How to use checksums
a9b33d48945f185bf2416c921c5fa5337379e9a776fc38f7eaf82627fe22621b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for openquantum-sdk-cirq 0.6.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.6.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