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.

Install

Hot:8

Download and extract to your skills directory

Copy command and send to AI Agent for auto-install:

Download and install this skill https://openskills.cc/api/download?slug=k-dense-ai-skills-cirq&locale=en&source=copy

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 processors

  • cirq-ionq: IonQ trapped-ion QPUs and simulators

  • azure-quantum[cirq]: IonQ and Quantinuum backends on Azure Quantum

  • cirq-aqt: AQT superconducting quantum devices

  • cirq-pasqal: Pasqal neutral-atom devices
  • Each 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:

  • The target hardware is a Google Quantum AI processor, such as Sycamore, Weber, or Willow

  • You need detailed noise modeling and low-level circuit design

  • You use platforms integrated with Cirq, such as IonQ, AQT, or Pasqal

  • Compatibility with Google’s quantum software ecosystem is important
  • Choose Qiskit when:

  • The target hardware is an IBM Quantum device

  • You need Qiskit-specific quantum machine learning modules, such as Qiskit Machine Learning

  • You use IBM’s quantum intermediate representation (QIR) ecosystem
  • Other complementary frameworks:

  • PennyLane: Suitable for quantum machine learning tasks that require automatic differentiation

  • QuTiP: Suitable for quantum physics simulations and open quantum system research
  • 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:

  • Access to Google Quantum AI hardware is restricted and requires approval

  • Different processors have different qubit topologies and gate sets

  • It is recommended to test circuits on a simulator first

  • Use calibration data to select the best qubits

  • Consider implementing error mitigation techniques
  • 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:

  • The time complexity of density matrix simulation is O(2^2n), so computational costs increase rapidly as the number of qubits grows

  • For pure-state circuits, prefer the state vector simulator, with complexity O(2n)

  • Noise modeling can be applied only to critical operations to balance accuracy and performance

  • Use parameter sweeps to study the effects of different noise levels in batches