# Cirq

**Cirq** 是 Google 推出的一个开源 Python 库，用于编写、操作和优化量子电路，并在量子计算机和量子模拟器上运行这些电路。<sup>[1](https://quantumai.google/cirq/start/intro)</sup> 它由 Google AI Quantum 团队在 2018 年 8 月于第一届量子软件与量子机器学习国际研讨会（QSML）上以公开 alpha 版发布，采用 Apache 2.0 许可证，面向含噪中等规模量子（NISQ）计算机设计——发布时被描述为具有约 50 至 100 个量子比特和高保真度量子门的设备。<sup>[2](https://opensource.googleblog.com/2018/08/cirq-open-source-framework-nisq-algorithms.html)</sup> 其最显著的设计选择是：程序必须感知目标设备的架构特性，而不是把硬件隐藏在干净整洁的设备抽象层之后。<sup>[1](https://quantumai.google/cirq/start/intro)</sup>

| 关键事实 | 详情 |
|---|---|
| 用途 | 用于在 NISQ 硬件上编写、优化和运行量子电路的 Python 框架，具备设备感知的量子门放置与调度能力<sup>[1](https://quantumai.google/cirq/start/intro)</sup><sup> • </sup><sup>[2](https://opensource.googleblog.com/2018/08/cirq-open-source-framework-nisq-algorithms.html)</sup> |
| 核心模型 | 电路（Circuit）是时刻（Moment）的集合，每个时刻是一组在同一抽象时间片中作用的操作（Operation）；量子比特由操作隐式定义<sup>[1](https://quantumai.google/cirq/start/intro)</sup> |
| 许可证与语言 | Apache License 2.0；主要用 Python 编写（92.7%）；支持 Python 3.11 及更高版本，可在 Linux、MacOS、Windows 和 Google Colab 上运行<sup>[3](https://github.com/quantumlib/Cirq/)</sup> |
| 硬件目标 | 通过 cirq_google 支持 Google Sycamore 和 Willow 处理器，以及 AQT、IonQ、Pasqal、IQM 等厂商和 Azure Quantum<sup>[4](https://quantumai.google/cirq/google/devices)</sup><sup> • </sup><sup>[5](https://opensource.googleblog.com/2022/07/Cirq-Turns-1.0.html)</sup> |
| 模拟 | 内置波函数模拟器和密度矩阵模拟器；qsim 后端的复杂度为 g·2<sup>n</sup>，曾用于 2019 年量子霸权基准测试<sup>[1](https://quantumai.google/cirq/start/intro)</sup><sup> • </sup><sup>[6](https://pypi.org/project/qsimcirq/)</sup> |
| 标志性应用 | 2019 年 Sycamore 超越经典采样实验的电路是用 Cirq 编写并运行的<sup>[7](https://www.nature.com/articles/s41586-019-1666-5)</sup> |
| 发布节奏 | 大约每季度发布一次；2022 年 7 月发布 1.0 版；v1.7.0 于 2026-06-30 发布<sup>[3](https://github.com/quantumlib/Cirq/)</sup><sup> • </sup><sup>[5](https://opensource.googleblog.com/2022/07/Cirq-Turns-1.0.html)</sup> |

## 设计与核心概念

Cirq 让用户对量子电路拥有精细调控能力：使用原生门指定门行为、在设备上恰当地放置门，并在量子硬件的约束内调度门的时间。<sup>[2](https://opensource.googleblog.com/2018/08/cirq-open-source-framework-nisq-algorithms.html)</sup> 文档将目标类别界定为具有 O(100) 个量子比特、可执行 O(1000) 个门的 NISQ 设备，并指出与那些将程序和设备干净分离的框架不同，Cirq 要求程序感知目标设备的架构特性。<sup>[1](https://quantumai.google/cirq/start/intro)</sup>

**电路、时刻与操作。** 一个 `Circuit` 是 `Moment` 对象的集合，而一个 `Moment` 是一组在同一抽象时间片中作用的 `Operation` 对象的集合。电路中的 `Qubit` 对象由操作隐式定义；量子比特不能被分配给电路。<sup>[1](https://quantumai.google/cirq/start/intro)</sup> 该框架是命令式的：用户通过在量子比特上按序排列门操作来显式构建电路，电路可以用 `Circuit` 对象或 `Schedule` 对象表示。<sup>[8](https://arxiv.org/html/2504.08876v2)</sup> 列出的特性包括灵活的门定义、带符号变量的参数化电路、电路变换与优化、硬件设备建模、噪声建模，以及多个内置模拟器。<sup>[3](https://github.com/quantumlib/Cirq/)</sup>

**噪声建模。** Cirq 在算子求和表示中支持噪声，可对密度矩阵演化建模，并提供 `NoiseModel` 对象，可按操作、按时刻或在时刻列表范围内添加噪声。<sup>[1](https://quantumai.google/cirq/start/intro)</sup> 一篇量子工具包综述以同样的术语描述了这一机制：噪声通过信道、噪声模型和测量门来表达，相干误差实现为门，非相干误差实现为概率性操作，另有内置的电路变换器用于对齐和延迟测量。<sup>[9](https://arxiv.org/html/2302.08884)</sup>

## 模拟后端

Cirq 自带用于波函数和密度矩阵的内置模拟器，可以用蒙特卡洛方法或全密度矩阵模拟来处理含噪量子信道。<sup>[1](https://quantumai.google/cirq/start/intro)</sup> 对于更大的电路，Cirq 可以通过 qsimcirq 接口使用 **qsim** 作为其模拟库。<sup>[6](https://pypi.org/project/qsimcirq/)</sup> qsim 是一个全状态向量模拟器，其总运行时间与 g·2<sup>n</sup> 成正比，其中 g 是双量子比特门的数量，n 是量子比特的数量；它使用门融合、单精度算术、AVX/FMA 向量化指令和 OpenMP 多线程。<sup>[6](https://pypi.org/project/qsimcirq/)</sup> Google 博客将 qsim 描述为用 AVX/FMA 向量化和可选 GPU 加速编写的高性能状态向量模拟器。<sup>[5](https://opensource.googleblog.com/2022/07/Cirq-Turns-1.0.html)</sup>

一篇 2023 年的综述指出，Cirq 的内置模拟器最多只能处理 20 个量子比特，而用 C++ 和 OpenMP 编写的 qsim 可以在 Intel 90 核 Xeon 处理器上模拟多达 40 个量子比特。<sup>[9](https://arxiv.org/html/2302.08884)</sup>

**量子虚拟机** 将设备、含噪模拟、真实噪声模型和虚拟引擎接口结合起来，生成一个 `cirq.SimulatedLocalEngine`，它可以几乎与硬件设备互换使用。<sup>[1](https://quantumai.google/cirq/start/intro)</sup>

## 硬件目标与生态系统

Cirq 是 Google 硬件团队用来编写在 Google 量子计算硬件上运行的量子程序的通用语言。<sup>[5](https://opensource.googleblog.com/2022/07/Cirq-Turns-1.0.html)</sup> cirq_google 模块提供静态设备布局：`cirq_google.Sycamore` 和 `cirq_google.Sycamore23` 分别代表早期的 54 量子比特和 23 量子比特 Sycamore 处理器，而 `cirq_google.Willow105` 为 Willow 处理器系列提供 105 量子比特的静态布局，支持 CZ 门和 PhasedXZGate 门。<sup>[4](https://quantumai.google/cirq/google/devices)</sup> 硬件提供一种称为 Willow 门的门，可通过 `cirq_google.WILLOW` 访问，等价于 FSimGate(π/2, π/9)，执行部分交换加上对 |11⟩ 的受控相位旋转。<sup>[4](https://quantumai.google/cirq/google/devices)</sup> 设备布局可以通过 `engine.get_processor(processor_id).get_device()` 从 Quantum Engine API 查询，也可以从 `SimulatedProcessorWithLocalDeviceRecord` 查询。<sup>[4](https://quantumai.google/cirq/google/devices)</sup>

Google 硬件施加了具体的调度限制：电路总运行时间限制在约 40 微秒以内，超过此限制的电路会返回“Program too long”错误码，设备遵循 Cirq 电路的时刻结构，串行执行相继的时刻。<sup>[4](https://quantumai.google/cirq/google/devices)</sup>

2022 年 Cirq 1.0 的公告列出，用 Cirq 编写的程序可通过 AQT、IonQ、Pasqal、Rigetti 和 IQM 等厂商运行，也可在 Azure Quantum 上运行。<sup>[5](https://opensource.googleblog.com/2022/07/Cirq-Turns-1.0.html)</sup> IonQ 的文档指出，自 Cirq v0.12.0 起，Cirq-Ionq 模块支持在 Cirq 框架内将电路运行于 IonQ 的离子阱系统上。<sup>[10](https://docs.ionq.com/sdks)</sup>

Cirq 仓库向用户推荐满足相邻需求的配套项目：Qualtran 用于容错量子计算，qsim 用于大规模模拟，Stim 用于 Clifford 电路和量子纠错，OpenFermion 用于化学，TensorFlow Quantum 用于量子机器学习，ReCirq 用于真实实验。<sup>[3](https://github.com/quantumlib/Cirq/)</sup>

## 在标志性研究中的作用

2019 年 Google 的“使用可编程超导处理器的量子霸权”实验使用了 Sycamore 处理器——一个由 54 个 transmon 量子比特组成的二维阵列，每个量子比特可调谐地耦合到矩形晶格中的四个最近邻——Cirq 就是用来编写和运行其电路的框架。<sup>[7](https://www.nature.com/articles/s41586-019-1666-5)</sup> 该处理器在约 200 秒内对一个量子电路的一个实例采样了一百万次，作者将其基准定为最先进的经典超级计算机约 10,000 年的工作量；采样的 53 量子比特状态空间对应维度 2<sup>53</sup>（约 10<sup>16</sup>），其连通性被选择为与表面码纠错向前兼容。<sup>[7](https://www.nature.com/articles/s41586-019-1666-5)</sup> 设备文档指出，超越经典的结果使用了 53 个量子比特，因为有一个量子比特发生了故障。<sup>[4](https://quantumai.google/cirq/google/devices)</sup> qsim 被用来产生发表在《自然》第 574 卷上的标志性交叉熵基准测试结果。<sup>[6](https://pypi.org/project/qsimcirq/)</sup>

后来的实验也在 Cirq 工具链上运行：“在量子处理器上实现拓扑有序态”（Satzinger 等，《科学》374, 1237-1241, 2021）是用 ReCirq 代码运行的，Cirq 还被用于帮助开发 Quantum Chess。<sup>[5](https://opensource.googleblog.com/2022/07/Cirq-Turns-1.0.html)</sup>

## 与 Qiskit 及其他 SDK 的比较

最强的定量比较来自 2025 年发表在《自然·计算科学》上的一项同行评审研究，该研究包含 1,000 多项测试，测量了多达 930 个量子比特和 O(10<sup>6</sup>) 个双量子比特门的电路在七个 SDK（包括 Cirq、Qiskit、Tket、BQSKit、Staq 和 Braket）上的性能。<sup>[11](https://www.nature.com/articles/s43588-025-00792-y)</sup> Cirq 构建一组哈密顿量模拟电路（test_DTC100_set_build）的速度比最接近的竞争对手 Qiskit 快 55 倍。<sup>[11](https://www.nature.com/articles/s43588-025-00792-y)</sup> 然而，Qiskit 是唯一通过所有电路构建测试的 SDK，用时 2.0 秒，Tket 以 14.2 秒位居其次，BQSKit 最慢，为 50.9 秒；Qiskit 在参数绑定测试中以 13.5 倍的差距优于其他 SDK。<sup>[11](https://www.nature.com/articles/s43588-025-00792-y)</sup> 因此两者各有优势：Cirq 在测量的哈密顿量电路构建工作负载上领先，而 Qiskit 在构建覆盖面和参数绑定上领先。

厂商的说法则指向另一方向。IBM 在 THINK 2024 上报告称，Qiskit 在性能测试中领先于量子 SDK，并将 Qiskit 定位为全栈产品，包括 SDK、Functions、Transpiler Service、Serverless、Runtime Primitives 和 Code Assistant。<sup>[12](https://www.ibm.com/quantum/blog/qiskit-performance)</sup> 一项定性比较研究将 Cirq 与 TensorFlow Quantum、Qiskit、Q#、PennyLane、Amazon Braket、XACC、ProjectQ 和 Forest 一起评估，讨论了每个框架的特点、优势和劣势。<sup>[13](https://inspirehep.net/literature/2905546)</sup>

## 近期发展

Cirq 于 2022 年 7 月达到 1.0 版，建立了稳定的 API，其中破坏性变更只在主版本号变更时发生。<sup>[5](https://opensource.googleblog.com/2022/07/Cirq-Turns-1.0.html)</sup> 此后继续以大约每季度一次的频率发布，v1.7.0 于 2026-06-30 发布，最后一次仓库推送在 2026-07-07。<sup>[3](https://github.com/quantumlib/Cirq/)</sup>

近期版本跟踪 Google Willow 时代的硬件和平台变化。1.6.0 版添加了一个名为“willow_pink”的量子虚拟机来模拟最先进的 Google 处理器，并在弃用后移除了 cirq-rigetti 子包，将遗留代码指向最终的 cirq-rigetti-1.5.0 版本。<sup>[14](https://github.com/quantumlib/cirq/releases)</sup> 随后一个版本添加了对 Python 3.14 和 protobuf-6 的支持，将 NumPy 最低版本提高到 2.1，并建立了一套基于 pytest-benchmarks 的性能基准测试套件。<sup>[14](https://github.com/quantumlib/cirq/releases)</sup> 其他近期变化包括改进的 Quantum Engine 序列化、用于量子比特频率和耦合的模拟式控制实验的类、IonQ 客户端更新至 IonQ API 0.4 版，以及因服务速率限制而失败的引擎请求重试。<sup>[14](https://github.com/quantumlib/cirq/releases)</sup> 一个补丁版本 v1.6.1 修复了 `cirq.kraus` 中的一个缺陷，该缺陷会导致它在某些情况下返回错误的近零矩阵。<sup>[14](https://github.com/quantumlib/cirq/releases)</sup>

## 采用情况与局限性

该仓库采用 Apache License 2.0 许可证，主要用 Python 编写（92.7%），截至检索日期有 5,009 颗星和 270 名贡献者；它创建于 2017-12-14。<sup>[3](https://github.com/quantumlib/Cirq/)</sup> 安装需要在 Linux、MacOS、Windows 或 Google Colab 上使用 Python 3.11 或更高版本。<sup>[3](https://github.com/quantumlib/Cirq/)</sup>

一篇量子工具包综述报告了 Cirq 的主要缺点：Google Sycamore 处理器不提供公共云访问，社区支持相对较低，平台因其继承的复杂性、缺乏教程和社区有限以及低层 API 而学习难度较大。<sup>[9](https://arxiv.org/html/2302.08884)</sup> 这些局限与 Cirq 在电路构建性能上经测量的优势<sup>[11](https://www.nature.com/articles/s43588-025-00792-y)</sup> 以及它作为 Google 自家处理器和研究项目编程层的角色<sup>[5](https://opensource.googleblog.com/2022/07/Cirq-Turns-1.0.html)</sup> 形成对照。

## References

1. [Introduction to Cirq, Google Quantum AI documentation](https://quantumai.google/cirq/start/intro)
2. [Announcing Cirq: an open source framework for NISQ algorithms, Google Open Source Blog (2018)](https://opensource.googleblog.com/2018/08/cirq-open-source-framework-nisq-algorithms.html)
3. [quantumlib/Cirq GitHub repository](https://github.com/quantumlib/Cirq/)
4. [Google devices, Cirq documentation, Google Quantum AI](https://quantumai.google/cirq/google/devices)
5. [Cirq Turns 1.0, Google Open Source Blog (2022)](https://opensource.googleblog.com/2022/07/Cirq-Turns-1.0.html)
6. [qsimcirq v0.22.1, PyPI](https://pypi.org/project/qsimcirq/)
7. [Quantum supremacy using a programmable superconducting processor, Nature (2019)](https://www.nature.com/articles/s41586-019-1666-5)
8. [Is Productivity in Quantum Programming Equivalent to Expressiveness?, arXiv (2025)](https://arxiv.org/html/2504.08876v2)
9. [Quantum Computing Toolkit: From Nuts and Bolts to Sack of Tools, arXiv (2023)](https://arxiv.org/html/2302.08884)
10. [IonQ SDKs documentation](https://docs.ionq.com/sdks)
11. [Benchmarking the performance of quantum computing software for quantum circuit creation, manipulation and compilation, Nature Computational Science (2025)](https://www.nature.com/articles/s43588-025-00792-y)
12. [Qiskit leads quantum SDKs in performance, testing shows, IBM Quantum blog (2024)](https://www.ibm.com/quantum/blog/qiskit-performance)
13. [A Qualitative Evaluation of Multiple Quantum Computing Frameworks, INSPIRE record](https://inspirehep.net/literature/2905546)
14. [Cirq releases, GitHub](https://github.com/quantumlib/cirq/releases)

---
*Initially written Oct 15, 2026*

Topic: 物质世界与数学 › 物理学 › 量子物理学 › Quantum information science › Quantum computing and algorithms

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/cirq

English original: https://www.edgepedia.org/cirq
