|
| 1 | +# <!-- H1 title omitted because our logo acts as the title. --> |
| 2 | + |
| 3 | +<div align="center"> |
| 4 | +<img width="280px" height="135px" alt="Cirq logo" |
| 5 | +src="https://raw.githubusercontent.com/quantumlib/Cirq/refs/heads/main/docs/images/Cirq_logo_color.svg"> |
| 6 | + |
| 7 | +Python package for writing, manipulating, and running [quantum |
| 8 | +circuits](https://en.wikipedia.org/wiki/Quantum_circuit) on quantum computers |
| 9 | +and simulators. |
| 10 | + |
| 11 | +[](https://github.com/quantumlib/Cirq/blob/main/LICENSE) |
| 13 | +[](https://www.python.org/downloads/) |
| 15 | +[](https://pypi.org/project/cirq) |
| 17 | +[](https://doi.org/10.5281/zenodo.4062499) |
| 19 | + |
| 20 | +[Features](#features) – |
| 21 | +[Installation](#installation) – |
| 22 | +[Quick Start](#quick-start--hello-qubit-example) – |
| 23 | +[Documentation](#cirq-documentation) – |
| 24 | +[Integrations](#integrations) – |
| 25 | +[Community](#community) – |
| 26 | +[Citing Cirq](#citing-cirq) – |
| 27 | +[Contact](#contact) |
| 28 | + |
| 29 | +</div> |
| 30 | + |
| 31 | +## Features |
| 32 | + |
| 33 | +Cirq provides useful abstractions for dealing with today’s [noisy |
| 34 | +intermediate-scale quantum](https://arxiv.org/abs/1801.00862) (NISQ) computers, |
| 35 | +where the details of quantum hardware are vital to achieving state-of-the-art |
| 36 | +results. Some of its features include: |
| 37 | + |
| 38 | +* Flexible gate definitions and custom gates |
| 39 | +* Parameterized circuits with symbolic variables |
| 40 | +* Circuit transformation, compilation and optimization |
| 41 | +* Hardware device modeling |
| 42 | +* Noise modeling |
| 43 | +* Multiple built-in quantum circuit simulators |
| 44 | +* Integration with [qsim](https://github.com/quantumlib/qsim) for |
| 45 | + high-performance simulation |
| 46 | +* Interoperability with [NumPy](https://numpy.org) and |
| 47 | + [SciPy](https://scipy.org) |
| 48 | +* Cross-platform compatibility |
| 49 | + |
| 50 | +## Installation |
| 51 | + |
| 52 | +Cirq supports Python version 3.10 and later, and can be used on Linux, MacOS, |
| 53 | +and Windows, as well as [Google Colab](https://colab.google). For complete |
| 54 | +installation instructions, please refer to the |
| 55 | +[Install](https://quantumai.google/cirq/start/install) section of the online |
| 56 | +Cirq documentation. |
| 57 | + |
| 58 | +## Quick Start – “Hello Qubit” Example |
| 59 | + |
| 60 | +Here is a simple example to get you up and running with Cirq after you have |
| 61 | +installed it. Start a Python interpreter, and then type the following: |
| 62 | + |
| 63 | +```python |
| 64 | +import cirq |
| 65 | + |
| 66 | +# Pick a qubit. |
| 67 | +qubit = cirq.GridQubit(0, 0) |
| 68 | + |
| 69 | +# Create a circuit. |
| 70 | +circuit = cirq.Circuit( |
| 71 | + cirq.X(qubit)**0.5, # Square root of NOT. |
| 72 | + cirq.measure(qubit, key='m') # Measurement. |
| 73 | +) |
| 74 | +print("Circuit:") |
| 75 | +print(circuit) |
| 76 | + |
| 77 | +# Simulate the circuit several times. |
| 78 | +simulator = cirq.Simulator() |
| 79 | +result = simulator.run(circuit, repetitions=20) |
| 80 | +print("Results:") |
| 81 | +print(result) |
| 82 | +``` |
| 83 | + |
| 84 | +Python should then print output similar to this: |
| 85 | + |
| 86 | +```text |
| 87 | +Circuit: |
| 88 | +(0, 0): ───X^0.5───M('m')─── |
| 89 | +Results: |
| 90 | +m=11000111111011001000 |
| 91 | +``` |
| 92 | + |
| 93 | +Congratulations! You have run your first quantum simulation in Cirq. You can |
| 94 | +continue to learn more by exploring the [many Cirq tutorials](#tutorials) |
| 95 | +described below. |
| 96 | + |
| 97 | +## Cirq Documentation |
| 98 | + |
| 99 | +The primary documentation site for Cirq is the [Cirq home page on the Quantum |
| 100 | +AI website](https://quantumai.google/cirq). There and elsewhere, a variety of |
| 101 | +documentation for Cirq is available. |
| 102 | + |
| 103 | +### Tutorials |
| 104 | + |
| 105 | +* [Video tutorials] on YouTube are an engaging way to learn Cirq. |
| 106 | +* [Jupyter notebook-based tutorials] let you learn Cirq from your browser – no |
| 107 | + installation needed. |
| 108 | +* [Text-based tutorials] on the Cirq home page are great when combined with a |
| 109 | + local [installation] of Cirq on your computer. After starting with the |
| 110 | + [basics], you'll be ready to dive into tutorials on circuit building and |
| 111 | + circuit simulation under the [Build] and [Simulate] tabs, respectively. Check |
| 112 | + out the other tabs for more! |
| 113 | + |
| 114 | +[Video tutorials]: https://www.youtube.com/playlist?list=PLpO2pyKisOjLVt_tDJ2K6ZTapZtHXPLB4 |
| 115 | +[Jupyter notebook-based tutorials]: https://colab.research.google.com/github/quantumlib/Cirq |
| 116 | +[Text-based tutorials]: https://quantumai.google/cirq |
| 117 | +[installation]: https://quantumai.google/cirq/start/install |
| 118 | +[basics]: https://quantumai.google/cirq/start/basics |
| 119 | +[Build]: https://quantumai.google/cirq/build |
| 120 | +[Simulate]: https://quantumai.google/cirq/simula |
| 121 | + |
| 122 | +### Reference Documentation |
| 123 | + |
| 124 | +* Docs for the [current stable release] correspond to what you get with |
| 125 | + `pip install cirq`. |
| 126 | +* Docs for the [pre-release] correspond to what you get with |
| 127 | + `pip install cirq~=1.0.dev`. |
| 128 | + |
| 129 | +[current stable release]: https://quantumai.google/reference/python/cirq/all_symbols |
| 130 | +[pre-release]: https://quantumai.google/reference/python/cirq/all_symbols?version=nightly |
| 131 | + |
| 132 | +### Examples |
| 133 | + |
| 134 | +* The [examples subdirectory](./examples/) of the Cirq GitHub repo has many |
| 135 | + programs illustrating the application of Cirq to everything from common |
| 136 | + textbook algorithms to more advanced methods. |
| 137 | +* The [Experiments page](https://quantumai.google/cirq/experiments/) on the |
| 138 | + Cirq documentation site has yet more examples, from simple to advanced. |
| 139 | + |
| 140 | +### Change log |
| 141 | + |
| 142 | +* The [Cirq releases](https://github.com/quantumlib/cirq/releases) page on |
| 143 | + GitHub lists the changes in each release. |
| 144 | + |
| 145 | +## Integrations |
| 146 | + |
| 147 | +Google Quantum AI has a suite of open-source software that lets you do more |
| 148 | +with Cirq. From high-performance simulators, to novel tools for expressing and |
| 149 | +analyzing fault-tolerant quantum algorithms, our software stack lets you |
| 150 | +develop quantum programs for a variety of applications. |
| 151 | + |
| 152 | +<div align="center"> |
| 153 | + |
| 154 | +| Your interests | Software to explore | |
| 155 | +|-------------------------------------------------|----------------------| |
| 156 | +| Quantum algorithms?<br>Fault-tolerant quantum computing (FTQC)? | [Qualtran] | |
| 157 | +| Large circuits and/or a lot of simulations? | [qsim] | |
| 158 | +| Circuits with thousands of qubits and millions of Clifford operations? | [Stim] | |
| 159 | +| Quantum error correction (QEC)? | [Stim] | |
| 160 | +| Chemistry and/or material science? | [OpenFermion]<br>[OpenFermion-FQE]<br>[OpenFermion-PySCF]<br>[OpenFermion-Psi4] | |
| 161 | +| Quantum machine learning (QML)? | [TensorFlow Quantum] | |
| 162 | +| Real experiments using Cirq? | [ReCirq] | |
| 163 | + |
| 164 | +</div> |
| 165 | + |
| 166 | +[Qualtran]: https://github.com/quantumlib/qualtran |
| 167 | +[qsim]: https://github.com/quantumlib/qsim |
| 168 | +[Stim]: https://github.com/quantumlib/ssim |
| 169 | +[OpenFermion]: https://github.com/quantumlib/openfermion |
| 170 | +[OpenFermion-FQE]: https://github.com/quantumlib/OpenFermion-FQE |
| 171 | +[OpenFermion-PySCF]: https://github.com/quantumlib/OpenFermion-PySCF |
| 172 | +[OpenFermion-Psi4]: https://github.com/quantumlib/OpenFermion-Psi4 |
| 173 | +[TensorFlow Quantum]: https://github.com/tensorflow/quantum |
| 174 | +[ReCirq]: https://github.com/quantumlib/ReCirq |
| 175 | + |
| 176 | +## Community |
| 177 | + |
| 178 | +<a href="https://github.com/quantumlib/Cirq/graphs/contributors"><img |
| 179 | +width="160em" alt="Total number of contributors to Cirq" |
| 180 | +src="https://img.shields.io/github/contributors/quantumlib/cirq?label=Contributors&logo=github&color=ccc&style=flat-square"/></a> |
| 181 | + |
| 182 | +Cirq has benefited from [open-source contributions] by over 200 people and |
| 183 | +counting. We are dedicated to cultivating an open and inclusive community to |
| 184 | +build software for quantum computers, and have a [code of conduct] for our |
| 185 | +community. |
| 186 | + |
| 187 | +[open-source contributions]: https://github.com/quantumlib/Cirq/graphs/contributors |
| 188 | +[code of conduct]: https://github.com/quantumlib/cirq/blob/main/CODE_OF_CONDUCT.md |
| 189 | + |
| 190 | +### Announcements |
| 191 | + |
| 192 | +Stay on top of Cirq developments using the approach that best suits your needs: |
| 193 | + |
| 194 | +* For releases and major announcements: sign up to the low-volume mailing list |
| 195 | + [`cirq-announce`]. |
| 196 | +* For releases only: |
| 197 | + * Via GitHub notifications: configure [repository notifications] for Cirq. |
| 198 | + * Via Atom/RSS from GitHub: subscribe to the GitHub [Cirq releases Atom feed]. |
| 199 | + * Via RSS from PyPI: subscribe to the [PyPI releases RSS feed] for Cirq. |
| 200 | + |
| 201 | +Cirq releases take place approximately every quarter. |
| 202 | + |
| 203 | +[`cirq-announce`]: https://groups.google.com/forum/#!forum/cirq-announce |
| 204 | +[repository notifications]: https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/configuring-notifications |
| 205 | +[Cirq releases Atom feed]: https://github.com/quantumlib/Cirq/releases.atom |
| 206 | +[PyPI releases RSS feed]: https://pypi.org/rss/project/cirq/releases.xml |
| 207 | + |
| 208 | +### Questions and Discussions |
| 209 | + |
| 210 | +* Do you have questions about using Cirq? Post them to the [Quantum Computing |
| 211 | + Stack Exchange] and tag them with the [`cirq`] tag. You can also search past |
| 212 | + questions using that tag – it's a great way to learn! |
| 213 | +* Would you like to get more involved in Cirq development? _Cirq Cynq_ is our |
| 214 | + biweekly virtual meeting of contributors to discuss everything from issues to |
| 215 | + ongoing efforts, as well as to ask questions. Become a member of |
| 216 | + [_cirq-dev_](https://groups.google.com/forum/#!forum/cirq-dev) to get an |
| 217 | + automatic meeting invitation! |
| 218 | + |
| 219 | +[Quantum Computing Stack Exchange]: https://quantumcomputing.stackexchange.com |
| 220 | +[`cirq`]: https://quantumcomputing.stackexchange.com/questions/tagged/cirq |
| 221 | + |
| 222 | +### Issues and Pull Requests |
| 223 | + |
| 224 | +* Do you have a feature request or want to report a bug? [Open an issue on |
| 225 | + GitHub] to report it! |
| 226 | +* Do you have a code contribution? Read our [contribution guidelines], then |
| 227 | + open a [pull request]! |
| 228 | + |
| 229 | +[Open an issue on GitHub]: https://github.com/quantumlib/Cirq/issues/new/choose |
| 230 | +[contribution guidelines]: https://github.com/quantumlib/cirq/blob/main/CONTRIBUTING.md |
| 231 | +[pull request]: https://help.github.com/articles/about-pull-requests |
| 232 | + |
| 233 | +## Citing Cirq<a name="how-to-cite-cirq"></a> |
| 234 | + |
| 235 | +When publishing articles or otherwise writing about Cirq, please cite the Cirq |
| 236 | +version you use – it will help others reproduce your results. We use Zenodo to |
| 237 | +preserve releases. The following links let you download the bibliographic |
| 238 | +record for the latest stable release of Cirq in some popular formats: |
| 239 | + |
| 240 | +<div align="center"> |
| 241 | + |
| 242 | +[](https://citation.doi.org/format?doi=10.5281/zenodo.4062499&style=bibtex) |
| 244 | +[](https://citation.doi.org/metadata?doi=10.5281/zenodo.4062499) |
| 246 | + |
| 247 | +</div> |
| 248 | + |
| 249 | +For formatted citations and records in other formats, as well as records for |
| 250 | +all releases of Cirq past and present, please visit the [Cirq page on |
| 251 | +Zenodo](https://doi.org/10.5281/zenodo.4062499). |
| 252 | + |
| 253 | +## Contact |
| 254 | + |
| 255 | +For any questions or concerns not addressed here, please email |
| 256 | +<quantum-oss-maintainers@google.com>. |
| 257 | + |
| 258 | +## Disclaimer |
| 259 | + |
| 260 | +Cirq is not an official Google product. Copyright 2019 The Cirq Developers. |
0 commit comments