cirq
Google quantum computing framework. Use when targeting Google Quantum AI hardware, designing noise-aware circuits, or running quantum characterization experiments. Best for Google hardware, noise modeling, and low-level circuit design. For IBM hardware use qiskit; for quantum ML with autodiff use pennylane; for physics simulations use qutip.
Author
Category
Development ToolsInstall
Download and extract to your skills directory
Copy command and send to AI Agent for auto-install:
Cirq - Google’s Quantum Computing Framework
Skills Overview
Cirq is an open-source Python quantum computing framework developed by Google Quantum AI for designing, simulating, and running quantum circuits. It is particularly well suited for circuit development on NISQ (Noisy Intermediate-Scale Quantum) devices and integration with Google quantum hardware.
Use Cases
1. Google Quantum AI Hardware Development and Execution
When you need to run circuits on Google’s Sycamore, Weber, or Willow quantum processors, Cirq provides comprehensive hardware integration support. Through the cirq-google package, you can compile circuits to the device’s native gate set, select optimal qubits, submit jobs, and manage computational tasks. Note that access to Google Quantum AI hardware requires an approved GCP project.
For other quantum hardware providers, Cirq also supports platforms such as IonQ (trapped-ion QPUs), Azure Quantum (IonQ and Quantinuum backends), AQT (Alpine Quantum Technologies), and Pasqal (neutral-atom devices), enabling a multi-cloud quantum computing strategy.
2. Quantum Noise Modeling and Circuit Optimization
When studying the noise characteristics of real quantum devices, Cirq provides a rich set of noise-modeling tools. You can use noise models such as depolarizing channels, amplitude damping, and phase damping, and add gate-specific, qubit-specific, or thermal noise effects. With the density matrix simulator, you can accurately simulate the behavior of noisy circuits and combine it with randomized benchmarking and XEB (Cross-Entropy Benchmarking) for noise characterization.
Cirq’s transformer framework also supports circuit optimization, including gate merging, Z-gate ejecting, removal of negligible operations, qubit routing, and SWAP insertion. These features help reduce circuit depth and gate count, improving execution fidelity on real hardware.
3. Variational Quantum Algorithms and Experiment Design
When implementing variational algorithms such as VQE (Variational Quantum Eigensolver), QAOA (Quantum Approximate Optimization Algorithm), or QPE (Quantum Phase Estimation), Cirq provides a complete experimental design pattern. Parameterized circuits, parameter sweeps, data collection, and the ReCirq framework support systematic quantum experiment workflows.
Through integration with optimization libraries such as SciPy, you can easily build templates for variational algorithms. For complex experiments, ReCirq provides reusable patterns for data generation, collection, and analysis. It supports parallel data acquisition, statistical analysis, and fidelity estimation, making it suitable for quantum characterization, verification, and validation (QCVV) research.
Core Features
1. Quantum Circuit Construction and Simulation
Cirq supports multiple qubit types (GridQubit, LineQubit, and NamedQubit) and provides a rich collection of single-qubit and two-qubit gates, including Hadamard, CNOT, RY, and RZ. It can be used to construct parameterized circuits and custom gates. Circuits are organized by moments (Moment), support standard quantum circuit patterns such as Bell states, GHZ states, and the quantum Fourier transform (QFT), and support import and export in OpenQASM and JSON formats.
For simulation, Cirq provides a state vector simulator for pure states, which is more efficient, and a density matrix simulator for mixed states and noisy systems. It supports sampling, measurement, parameter sweeps, state histogram visualization, and expectation-value calculations. For large circuits, the Quantum Virtual Machine (QVM) provides hardware-accurate simulation to help verify circuit behavior before actual execution.
2. Hardware Integration and Circuit Compilation
Cirq integrates with major quantum hardware platforms through dedicated provider packages:
cirq-google: Google Quantum AI’s Sycamore, Weber, and Willow processorscirq-ionq: IonQ trapped-ion QPUs and simulatorsazure-quantum[cirq]: IonQ and Quantinuum backends on Azure Quantumcirq-aqt: AQT superconducting quantum devicescirq-pasqal: Pasqal neutral-atom devicesEach integration includes device topology representation, qubit selection, authentication, and job management. They also support circuit optimization for hardware-specific gate sets to ensure that circuits comply with device constraints.
3. Noise Modeling and Error Mitigation
Cirq provides systematic noise-modeling capabilities, including noise channels (depolarization, amplitude damping, and phase damping), noise models (constant, gate-specific, qubit-specific, and thermal noise), readout noise, and noise visualization such as heat maps. Combined with noise characterization techniques such as randomized benchmarking and XEB, as well as error mitigation methods, these capabilities enable comprehensive evaluation and improvement of circuit performance on real hardware.
Frequently Asked Questions
What are the differences between Cirq and Qiskit? How should I choose?
Cirq and Qiskit are both mainstream quantum computing frameworks, but they target different quantum hardware ecosystems:
Choose Cirq when:
Choose Qiskit when:
Other complementary frameworks:
In most cases, choosing the native framework maintained by the target hardware provider provides the best support and the latest features.
How do I run a circuit on Google Quantum AI hardware?
Running a circuit on Google Quantum AI hardware requires the following steps:
1. Prepare the environment and access permissions
# Install the Cirq Google package
uv pip install "cirq-google==1.6.1"You need an approved GCP project and must configure Google Cloud authentication.
2. Create and optimize the circuit
import cirq_google as cg
# Create a circuit
circuit = cirq.Circuit(...)
# Compile for the device gate set
processor = engine.get_processor(processor_id)
circuit = cg.compile_circuit(circuit, device=processor.get_device())3. Submit the job
project_id = os.environ['GOOGLE_CLOUD_PROJECT']
engine = cg.Engine(project_id=project_id)
sampler = engine.get_sampler(processor_id='weber')
result = sampler.run(circuit, repetitions=1000)Considerations:
How does Cirq simulate noisy quantum circuits?
Cirq provides a flexible noise-modeling mechanism. A typical workflow is as follows:
1. Add noise to the circuit
# Add global noise
noisy_circuit = circuit.with_noise(cirq.depolarize(p=0.01))
# Add noise to specific gates
from cirq import InsertStrategy
noisy_circuit = cirq.Circuit()
for moment in circuit:
for op in moment:
noisy_circuit.append(op)
if cirq.has_unitary(op):
noisy_circuit.append(cirq.depolarize(p=0.001).on(op.qubits))2. Use the density matrix simulator
simulator = cirq.DensityMatrixSimulator()
result = simulator.run(noisy_circuit, repetitions=1000)3. Build a complex noise model
# Qubit-specific noise
noise_model = cirq.noise_model(
gate_specific_noise={
cirq.CNOT: cirq.depolarize(p=0.005),
cirq.X: cirq.amplitude_damp(gamma=0.02)
},
qubit_specific_noise={
q(0): cirq.phase_damp(gamma=0.01)
}
)Performance considerations: