Python framework for creating, editing, and running Noisy Intermediate-Scale Quantum (NISQ) circuits.
Python package for writing, manipulating, and running quantum circuits on quantum computers and simulators.
Features – Installation – Quick Start – Documentation – Integrations – Community – Citing Cirq – Contact
Features
Cirq provides useful abstractions for dealing with todayβs noisy intermediate-scale quantum (NISQ) computers, where the details of quantum hardware are vital to achieving state-of-the-art results. Some of its features include:
- Flexible gate definitions and custom gates
- Parameterized circuits with symbolic variables
- Circuit transformation, compilation and optimization
- Hardware device modeling
- Noise modeling
- Multiple built-in quantum circuit simulators
- Integration with qsim for
- Interoperability with NumPy and
- Cross-platform compatibility
Installation
Cirq supports Python version 3.11 and later, and can be used on Linux, MacOS, and Windows, as well as Google Colab. For complete installation instructions, please refer to the Install section of the online Cirq documentation.
Quick Start β βHello Qubitβ Example
Here is a simple example to get you up and running with Cirq after you have installed it. Start a Python interpreter, and then type the following:
import cirq
Pick a qubit.
qubit = cirq.GridQubit(0, 0)
Create a circuit.
circuit = cirq.Circuit(
cirq.X(qubit)**0.5, # Square root of NOT.
cirq.measure(qubit, key='m') # Measurement.
)
print("Circuit:")
print(circuit)
Simulate the circuit several times.
simulator = cirq.Simulator()
result = simulator.run(circuit, repetitions=20)
print("Results:")
print(result)
Python should then print output similar to this:
Circuit:
(0, 0): βββX^0.5βββM('m')βββ
Results:
m=11000111111011001000
Congratulations! You have run your first quantum simulation in Cirq. You can continue to learn more by exploring the many Cirq tutorials described below.
Cirq Documentation
The primary documentation site for Cirq is the Cirq home page on the Quantum AI website. There and elsewhere, a variety of documentation for Cirq is available.
Tutorials
- [Video tutorials] on YouTube are an engaging way to learn Cirq.
- [Jupyter notebook-based tutorials] let you learn Cirq from your browser β no
- [Text-based tutorials] on the Cirq home page are great when combined with a
[Video tutorials]: https://www.youtube.com/playlist?list=PLpO2pyKisOjLVt_tDJ2K6ZTapZtHXPLB4 [Jupyter notebook-based tutorials]: https://colab.research.google.com/github/quantumlib/Cirq [Text-based tutorials]: https://quantumai.google/cirq [installation]: https://quantumai.google/cirq/start/install [basics]: https://quantumai.google/cirq/start/basics [Build]: https://quantumai.google/cirq/build [Simulate]: https://quantumai.google/cirq/simulate
Reference Documentation
- Docs for the [current stable release] correspond to what you get with
pip install cirq.
- Docs for the [pre-release] correspond to what you get with
pip install --upgrade cirq~=1.0.dev.
[current stable release]: https://quantumai.google/reference/python/cirq/all_symbols [pre-release]: https://quantumai.google/reference/python/cirq/all_symbols?version=nightly
Examples
- The examples subdirectory of the Cirq GitHub repo has many
- The Experiments page on the
Change log
- The Cirq releases page on
Integrations
Google Quantum AI has a suite of open-source software that lets you do more with Cirq. From high-performance simulators, to novel tools for expressing and analyzing fault-tolerant quantum algorithms, our software stack lets you develop quantum programs for a variety of applications.
| Your interests | Software to explore | |-------------------------------------------------|----------------------| | Quantum algorithms?
Fault-tolerant quantum computing (FTQC)? | [Qualtran] | | Large circuits and/or a lot of simulations? | [qsim] | | Circuits with thousands of qubits and millions of Clifford operations? | [Stim] | | Quantum error correction (QEC)? | [Stim] | | Chemistry and/or material science? | [OpenFermion]
[OpenFermion-FQE]
[OpenFermion-PySCF]
[OpenFermion-Psi4] | | Quantum machine learning (QML)? | [TensorFlow Quantum] | | Real experiments using Cirq? | [ReCirq] |
[Qualtran]: https://github.com/quantumlib/qualtran [qsim]: https://github.com/quantumlib/qsim [Stim]: https://github.com/quantumlib/stim [OpenFermion]: https://github.com/quantumlib/openfermion [OpenFermion-FQE]: https://github.com/quantumlib/OpenFermion-FQE [OpenFermion-PySCF]: https://github.com/quantumlib/OpenFermion-PySCF [OpenFermion-Psi4]: https://github.com/quantumlib/OpenFermion-Psi4 [TensorFlow Quantum]: https://github.com/tensorflow/quantum [ReCirq]: https://github.com/quantumlib/ReCirq
Community
Cirq has benefited from [contributions] by over 250 people and counting. We are dedicated to cultivating an open and inclusive community to build software for quantum computers, and have a community [code of conduct].
[contributions]: https://github.com/quantumlib/Cirq/graphs/contributors [code of conduct]: https://github.com/quantumlib/cirq/blob/main/CODEOFCONDUCT.md
Announcements
Stay on top of Cirq developments using the approach that best suits your needs:
- For releases and major announcements: sign up to the low-volume mailing list
cirq-announce].
- For releases only:
Cirq releases take place approximately every quarter.
[cirq-announce]: https://groups.google.com/g/cirq-announce [repository notifications]: https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/configuring-notifications [Cirq releases Atom feed]: https://github.com/quantumlib/Cirq/releases.atom [PyPI releases RSS feed]: https://pypi.org/rss/project/cirq/releases.xml
Questions and Discussions
- Have questions about Cirq? Post them to the [Quantum Computing
cirq]. You can also search past
questions using that tag β it's a great way to learn!
- Want meet other Cirq developers and participate in discussions? Join
[Quantum Computing Stack Exchange]: https://quantumcomputing.stackexchange.com [cirq]: https://quantumcomputing.stackexchange.com/questions/tagged/cirq [cirq-dev]: https://groups.google.com/g/cirq-dev
Contributions
- Have a feature request or bug report? [Open an issue on GitHub]!
- Want to develop Cirq code? Look at the [list of good first issues] to
[Open an issue on GitHub]: https://github.com/quantumlib/Cirq/issues/new/choose [list of good first issues]: https://github.com/quantumlib/Cirq/contribute [contribution guidelines]: https://github.com/quantumlib/cirq/blob/main/CONTRIBUTING.md [pull requests]: https://help.github.com/articles/about-pull-requests
Citing Cirq
When publishing articles or otherwise writing about Cirq, please cite the Cirq version you use β it will help others reproduce your results. We use Zenodo to preserve releases. The following links let you download the bibliographic record for the latest stable release of Cirq in some popular formats:
For formatted citations and records in other formats, as well as records for all releases of Cirq past and present, please visit the Cirq page on Zenodo.
Contact
For any questions or concerns not addressed here, please email quantum-oss-maintainers@google.com.
Disclaimer
This is not an officially supported Google product. This project is not eligible for the Google Open Source Software Vulnerability Rewards Program.
Copyright 2019 The Cirq Developers.