|
| 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 |
| 106 | + tutorials](https://www.youtube.com/playlist?list=PLpO2pyKisOjLVt_tDJ2K6ZTapZtHXPLB4) |
| 107 | + on YouTube are an engaging way to learn Cirq. |
| 108 | +* [Jupyter notebook-based |
| 109 | + tutorials](https://colab.research.google.com/github/quantumlib/Cirq) let you |
| 110 | + learn Cirq from your browser – no installation needed. |
| 111 | +* [Text-based tutorials](https://quantumai.google/cirq) on the Cirq home page |
| 112 | + are great when combined with a local |
| 113 | + [installation](https://quantumai.google/cirq/start/install) of Cirq on your |
| 114 | + computer. After starting with the |
| 115 | + [basics](https://quantumai.google/cirq/start/basics), you'll be ready to dive |
| 116 | + into tutorials on circuit building and circuit simulation under the |
| 117 | + [Build](https://quantumai.google/cirq/build) and |
| 118 | + [Simulate](https://quantumai.google/cirq/simula) tabs, respectively. Check |
| 119 | + out the other tabs for more! |
| 120 | + |
| 121 | +### Reference Documentation |
| 122 | + |
| 123 | +* Docs for the [current stable |
| 124 | + release](https://quantumai.google/reference/python/cirq/all_symbols) |
| 125 | + correspond to what you get with `pip install cirq`. |
| 126 | +* Docs for the |
| 127 | + [pre-release](https://quantumai.google/reference/python/cirq/all_symbols?version=nightly) |
| 128 | + correspond to what you get with `pip install cirq~=1.0.dev`. |
| 129 | + |
| 130 | +### Examples |
| 131 | + |
| 132 | +* The [examples subdirectory](./examples/) of the Cirq GitHub repo has many |
| 133 | + programs illustrating the application of Cirq to everything from common |
| 134 | + textbook algorithms to more advanced methods. |
| 135 | +* The [Experiments page](https://quantumai.google/cirq/experiments/) on the |
| 136 | + Cirq documentation site has yet more examples, from simple to advanced. |
| 137 | + |
| 138 | +### Change log |
| 139 | + |
| 140 | +* The [Cirq releases](https://github.com/quantumlib/cirq/releases) page on |
| 141 | + GitHub lists the changes in each release. |
| 142 | + |
| 143 | +## Integrations |
| 144 | + |
| 145 | +Google Quantum AI has a suite of open-source software that lets you do more |
| 146 | +with Cirq. From high-performance simulators, to novel tools for expressing and |
| 147 | +analyzing fault-tolerant quantum algorithms, our software stack lets you |
| 148 | +develop quantum programs for a variety of applications. |
| 149 | + |
| 150 | +<div align="center"> |
| 151 | + |
| 152 | +| Your interests | Software to explore | |
| 153 | +|-------------------------------------------------|----------------------| |
| 154 | +| Quantum algorithms?<br>Fault-tolerant quantum computing (FTQC)? | [Qualtran](https://github.com/quantumlib/qualtran) | |
| 155 | +| Large circuits and/or a lot of simulations? | [qsim](https://github.com/quantumlib/qsim) | |
| 156 | +| Circuits with thousands of qubits and millions of Clifford operations? | [Stim](https://github.com/quantumlib/ssim) | |
| 157 | +| Quantum error correction (QEC)? | [Stim](https://github.com/quantumlib/ssim) | |
| 158 | +| Chemistry and/or material science? | [OpenFermion](https://github.com/quantumlib/openfermion)<br>[OpenFermion-FQE](https://github.com/quantumlib/OpenFermion-FQE)<br>[OpenFermion-PySCF](https://github.com/quantumlib/OpenFermion-PySCF)<br>[OpenFermion-Psi4](https://github.com/quantumlib/OpenFermion-Psi4) | |
| 159 | +| Quantum machine learning (QML)? | [TensorFlow Quantum](https://github.com/tensorflow/quantum) | |
| 160 | +| Real experiments using Cirq? | [ReCirq](https://github.com/quantumlib/ReCirq) | |
| 161 | + |
| 162 | +</div> |
| 163 | + |
| 164 | +## Community |
| 165 | + |
| 166 | +<a href="https://github.com/quantumlib/Cirq/graphs/contributors"><img |
| 167 | +align="right" width="160em" alt="Total number of contributors to Cirq" |
| 168 | +src="https://img.shields.io/github/contributors/quantumlib/cirq?label=Contributors&logoColor=white&logo=github&color=cccccc&style=flat-square"/></a> |
| 169 | + |
| 170 | +Cirq has benefited from [open-source |
| 171 | +contributions](https://github.com/quantumlib/Cirq/graphs/contributors) by over |
| 172 | +200 people and counting. We are dedicated to cultivating an open and inclusive |
| 173 | +community to build software for quantum computers, and have a [code of |
| 174 | +conduct](https://github.com/quantumlib/cirq/blob/main/CODE_OF_CONDUCT.md) for |
| 175 | +our community. |
| 176 | + |
| 177 | +### Announcements |
| 178 | + |
| 179 | +Stay on top of Cirq developments using the approach that best suits your needs: |
| 180 | + |
| 181 | +* For releases and major announcements: sign up to the low-volume mailing list |
| 182 | + [`cirq-announce`](https://groups.google.com/forum/#!forum/cirq-announce). |
| 183 | +* For releases only: |
| 184 | + * Via GitHub notifications: configure [GitHub repository |
| 185 | + notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/configuring-notifications) |
| 186 | + for the Cirq repository. |
| 187 | + * Via Atom/RSS from GitHub: subscribe to the GitHub [Cirq releases Atom |
| 188 | + feed](https://github.com/quantumlib/Cirq/releases.atom). |
| 189 | + * Via RSS from PyPI: subscribe to the [PyPI releases RSS |
| 190 | + feed](https://pypi.org/rss/project/cirq/releases.xml) for Cirq. |
| 191 | + |
| 192 | +Cirq releases take place approximately every quarter. |
| 193 | + |
| 194 | +### Questions and Discussions |
| 195 | + |
| 196 | +* Do you have questions about using Cirq? Post them to the [Quantum Computing |
| 197 | + Stack Exchange](https://quantumcomputing.stackexchange.com/) and tag them |
| 198 | + with the |
| 199 | + [`cirq`](https://quantumcomputing.stackexchange.com/questions/tagged/cirq) |
| 200 | + tag. You can also search past questions using that tag – it's a great way to |
| 201 | + learn! |
| 202 | +* Would you like to get more involved in Cirq development? _Cirq Cynq_ is our |
| 203 | + biweekly virtual meeting of contributors to discuss everything from issues to |
| 204 | + ongoing efforts, as well as to ask questions. Become a member of |
| 205 | + [_cirq-dev_](https://groups.google.com/forum/#!forum/cirq-dev) to get an |
| 206 | + automatic meeting invitation! |
| 207 | + |
| 208 | +### Issues and Pull Requests |
| 209 | + |
| 210 | +* Do you have a feature request or want to report a bug? [Open an issue on |
| 211 | + GitHub](https://github.com/quantumlib/Cirq/issues/new/choose) to report it! |
| 212 | +* Do you have a code contribution? Read our [contribution |
| 213 | + guidelines](https://github.com/quantumlib/cirq/blob/main/CONTRIBUTING.md), |
| 214 | + then open a [pull |
| 215 | + request](https://help.github.com/articles/about-pull-requests)! |
| 216 | + |
| 217 | +## Citing Cirq |
| 218 | + |
| 219 | +When publishing articles or otherwise writing about Cirq, please cite the Cirq |
| 220 | +version you use – it will help others reproduce your results. We use Zenodo to |
| 221 | +preserve releases. The following links let you download the bibliographic |
| 222 | +record for the latest stable release of Cirq in various popular formats: |
| 223 | + |
| 224 | +<div align="center"> |
| 225 | + |
| 226 | +[](https://zenodo.org/records/8161252/export/bibtex) |
| 228 | +[](https://zenodo.org/records/8161252/export/marcxml) |
| 230 | +[](https://zenodo.org/records/8161252/export/csl) |
| 232 | + |
| 233 | +</div> |
| 234 | + |
| 235 | +For formatted citations and records in other formats, as well as records for |
| 236 | +all releases of Cirq past and present, visit the [Cirq page on |
| 237 | +Zenodo](https://doi.org/10.5281/zenodo.4062499). |
| 238 | + |
| 239 | +## Contact |
| 240 | + |
| 241 | +For any questions or concerns not addressed here, please email |
| 242 | + |
| 243 | + |
| 244 | +## Disclaimer |
| 245 | + |
| 246 | +Cirq is not an official Google product. Copyright 2019 The Cirq Developers. |
0 commit comments