Cirq

A hardware-aware library that gives fine control over qubit placement, timing and noise.

by Google Quantum AI · Python · Moderate · Open source (Apache 2.0 per its repository; check) · reviewed December 2026

What it is

Cirq is Google Quantum AI’s open-source Python library. It was designed for noisy, intermediate-scale devices, so it puts physical details such as qubit layout, moments of simultaneous gates and noise channels in front of the programmer.

It is a favourite for research code that needs to say exactly where gates go and what noise acts on them, and it is the natural framework for Google’s own hardware experiments.

  • Qubits are objects with a position, such as LineQubit and GridQubit, not just numbers.
  • A circuit is a list of Moments, each holding gates that act at the same time.
  • Simulation and noise are first-class, with a clean way to attach noise models.

Core ideas

Qubit objects
LineQubit, GridQubit and NamedQubit describe where a qubit lives.
Moment
A slice of the circuit where gates run in parallel.
Measurement keys
Each measurement has a key that labels its results.
Simulators
cirq.Simulator for pure states and cirq.DensityMatrixSimulator for noisy ones.

Install and first program

Install

pip install cirq

Bell state

import cirq

q0, q1 = cirq.LineQubit.range(2)
circuit = cirq.Circuit(
    cirq.H(q0),
    cirq.CNOT(q0, q1),
    cirq.measure(q0, q1, key="m"),
)

result = cirq.Simulator().run(circuit, repetitions=1000)
print(result.histogram(key="m"))   # counts of 0 and 3 (the bit strings 00 and 11)

The histogram key is the measured bits read as an integer, so 00 appears as 0 and 11 as 3. Not executed in this site’s build environment; check it against your installed version.

A noisy simulation

import cirq

q0, q1 = cirq.LineQubit.range(2)
circuit = cirq.Circuit(
    cirq.H(q0),
    cirq.CNOT(q0, q1),
    cirq.measure(q0, q1, key="m"),
)

noisy = cirq.DensityMatrixSimulator(noise=cirq.depolarize(0.05))
print(noisy.run(circuit, repetitions=1000).histogram(key="m"))
# some 01 and 10 results (1 and 2) now appear

Depolarising noise is applied after each gate, so wrong results appear. The Noise and Decoherence Lab on this site explains the channel.

Strengths

  • →Direct control of qubit layout and gate timing
  • →Clear model for noise and density-matrix simulation
  • →Clean, readable circuit objects
  • →The framework used with Google’s hardware work
  • →Companion simulators such as qsim for faster runs

Weaknesses

  • →Smaller community and fewer beginner resources than Qiskit
  • →More boilerplate for common tasks
  • →Access to Google hardware is limited
  • →Fewer high-level application packages

Hardware access

Google Quantum AI hardware is the native target, with limited access. Some other providers have Cirq integrations. Check Google’s documentation for what is currently available to outside users.

Ecosystem

  • cirq-google: Google devices and calibration data
  • qsim and qsimcirq: faster simulators
  • OpenFermion: a related library for chemistry problems
  • Import from and export to OpenQASM

Choose it when

  • Research that needs explicit qubit placement and noise
  • Learning how circuits map to device layouts
  • Working with Google’s published experiments
  • Code that reads like the circuit diagram

Look elsewhere when

  • First-time learners who want the most tutorials
  • Projects that must run on IBM hardware without extra glue

Common pitfalls

  • A circuit run with simulator.run needs measurements, or there is nothing to return. Use simulate when you want the final state.
  • Qubits are objects. Using the wrong qubit type can fail when a circuit is validated for a device.
  • Different libraries print results in different bit orders. Cirq prints the first qubit on the left.
  • cirq-google and the core package are separate installs.

A learning path

  1. Install cirq and build the Bell circuit below.
  2. Print the circuit and read its moments.
  3. Add a noise channel with the density-matrix simulator.
  4. Place the circuit on GridQubits and explore device constraints.

Ratings

Editorial ratings from 0 to 3, not benchmarks.

Beginner friendliness
1
Quantum machine learning
1
IBM hardware
0
Google hardware
3
Many hardware providers
1
GPU simulation
1
Circuit compilation
2
Fault-tolerant planning
1
Low-level control
3

Compared with others

Learn more on QuantumAtlas

Questions

Is Cirq harder than Qiskit?

It asks you to think about qubits and moments explicitly, which some people find clearer and others find heavier. There are fewer beginner resources.

Can I run Cirq on IBM hardware?

Not directly. You would convert the circuit, for example through OpenQASM, and run it with another tool.

What is qsim?

A separate high-performance simulator that works with Cirq.

Sources

Frameworks change often. The official documentation is the final word on versions, devices and prices.