Cirq Plugin Overview¶
Beta
The Cirq plugin is in beta. It works end to end, but the API and defaults may still change. We'd love your feedback: join the Quantum Rings community.
The openquantum-sdk[cirq] plugin connects Cirq to the Open Quantum platform, letting you run Cirq circuits on real QPU hardware. It builds on the Core SDK (openquantum-sdk) for authentication and job submission.
Cirq is an open-source Python framework for writing, manipulating, and optimizing quantum circuits, created and maintained by Google Quantum AI. Learn more at the Cirq website and the Cirq GitHub repository.
Installation¶
This pulls in cirq-core and openquantum-sdk. There is no entry-point registration step: you import OpenQuantumSampler and use it anywhere a cirq.Sampler is accepted.
What the Plugin Does¶
Cirq exports OpenQASM natively (cirq.Circuit.to_qasm()), so — unlike the Qrisp plugin — it does not route through the Qiskit plugin. OpenQuantumSampler is a thin cirq.Sampler. When you call run (or any sampler method), the plugin:
- Resolves parameters for each circuit in the sweep.
- Serializes the resolved circuit to OpenQASM. Cirq maps all qubits onto a single
qreg q[N], which is exactly what the platform precompiler requires. - Submits it through the Core SDK scheduler.
- Reconstructs the platform's
{bitstring: count}histogram into a nativecirq.Result, soresult.histogram(...),result.measurements, and friends work as usual.
Because it implements run_sweep, the standard cirq.Sampler methods — run, sample, run_sweep, and run_batch — all work.
Quick Example¶
import cirq
from cirq_openquantum import OpenQuantumSampler
sampler = OpenQuantumSampler(
backend="rigetti:cepheus-1-108q",
client_id="s_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
Tip
Set OPENQUANTUM_CLIENT_ID and OPENQUANTUM_CLIENT_SECRET as environment variables to avoid passing credentials in code. See the Authentication guide.
Key Components¶
| Component | Description |
|---|---|
| OpenQuantumSampler | cirq.Sampler subclass. Implements run_sweep() to execute circuits on Open Quantum. |
| result_from_counts | Rebuilds a cirq.ResultDict from a platform counts histogram. |
| Core session | Shared OpenQuantumClient auth, token caching, and job submission. |
Supported Backends¶
The plugin works with any backend on the Open Quantum platform, identified by its short_code (e.g. "ionq:forte-1", "rigetti:cepheus-1-108q"). Discover backends with the Core SDK or the Open Quantum Portal.
Shot-Based Execution Only¶
Open Quantum is a shot-based platform. Every execution requires a finite number of shots, set via the repetitions argument to run / sample / run_sweep. Every circuit must contain at least one measurement; the QASM exporter does not add measurements for you.
Next Steps¶
- Getting Started — install, authenticate, and run.
- Supported Operations — gates, measurements, and bit ordering.
- Examples — Bell states, parameter sweeps, and backend selection.
- Troubleshooting — auth, backend config, and common errors.