Quantum Computing
Cirq and other frameworks
Цели урока
- Understand key differences between Cirq and Qiskit: Moments and explicit topology
- Use PennyLane for quantum ML with automatic differentiation
- Understand the Amazon Braket model: multi-QPU through a single API
- Select the right framework for a given problem
Qiskit is not the only option. Google, Xanadu, and Amazon built their own frameworks with different philosophies. Understanding the ecosystem makes it possible to pick the right tool for the job, rather than bending the job to fit the tool.
- **Google Quantum AI:** the entire stack runs on Cirq - from algorithm to Sycamore control
- **Xanadu:** PennyLane powers photonic quantum computers (Borealis)
- **AWS:** Braket is integrated into SageMaker for quantum ML in production
- **OpenQASM 3.0:** portability standard - write once, run anywhere
Google Cirq: architecture and gate model
Google built **Cirq** for a specific purpose: programming its own Sycamore processors. Unlike Qiskit, Cirq is designed from the ground up for NISQ devices - noisy processors with limited connectivity. This shows in the API: a Cirq circuit cannot be written without considering the hardware topology.
The key difference from Qiskit is explicit **Moment** control. A Moment is a set of gates executing simultaneously in one quantum clock cycle. Cirq exposes this scheduling directly, which matters for minimizing coherence time usage.
Google Cirq is used internally at Google Quantum AI. The circuit for the quantum supremacy demonstration on Sycamore (2019) was implemented in Cirq. Public access to Google QPUs is currently limited to research programs.
What is a Moment in Cirq?
PennyLane: quantum machine learning
**PennyLane** by Xanadu is a library for quantum machine learning (QML). The core idea: quantum circuits as differentiable functions compatible with PyTorch and TensorFlow. Circuit parameters are optimized by gradient descent - the same way neural network weights are trained.
PennyLane implements the **parameter-shift rule** for computing analytic gradients of quantum circuits. Unlike numerical finite differences, this is an exact method requiring no small step size.
Parameter-shift rule: the gradient of a parametric gate R(theta) is computed as [f(theta + pi/2) - f(theta - pi/2)] / 2. This is an analytically exact result, not an approximation. That is why PennyLane works without classical backpropagation through quantum hardware.
Why does PennyLane use the parameter-shift rule instead of standard backpropagation?
Amazon Braket: cloud quantum computing service
**Amazon Braket** is AWS's cloud platform for quantum computing. Unlike IBM (only its own processors), Braket provides access to multiple hardware vendors: IonQ (ion traps), Rigetti (superconductors), OQC, and others. Pricing is per QPU usage time.
Braket integrates with Amazon SageMaker for hybrid quantum-classical ML. PennyLane supports Braket as a backend - the same PennyLane code runs on any Braket device without algorithm changes.
Braket supports **parallel batch tasks**: submit thousands of circuit variants at once and collect results. This is useful for variational algorithms that need to evaluate many parameter configurations.
The main difference between Amazon Braket and IBM Quantum:
Framework comparison: choosing the right tool
Qiskit, Cirq, PennyLane, and Braket solve different problems. The choice depends on the goal: algorithmic research, NISQ experiments, QML, or multi-cloud hardware access.
| Framework | Company | Strength | Hardware | Abstraction |
|---|---|---|---|---|
| Qiskit | IBM | Full stack, ecosystem | IBM Quantum | High |
| Cirq | NISQ, timing control | Google Sycamore* | Low | |
| PennyLane | Xanadu | QML, autodiff | Multi-backend | High |
| Braket | Amazon | Multi-QPU, AWS cloud | IonQ, Rigetti, OQC | Medium |
* Google Sycamore is available only to selected researchers through the Google Quantum AI program.
In practice, frameworks are combined: PennyLane supports Qiskit and Braket as backends. Cirq circuits can be converted to Qiskit via `cirq-core`. The common portable format is **OpenQASM**, supported by all frameworks.
For building a hybrid quantum-classical neural network with PyTorch, the best choice is:
Quantum framework ecosystem
- Cirq: explicit Moments, topology control, optimal for NISQ research
- PennyLane: QML, parameter-shift rule, PyTorch/TF integration
- Amazon Braket: multi-QPU via AWS - IonQ, Rigetti, OQC
- Frameworks combine: PennyLane works on top of Qiskit and Braket
- OpenQASM 3.0 - portable format across all frameworks
Related topics
Frameworks implement algorithms from earlier lessons and provide hardware access.
- Qiskit: programming quantum computers — Base framework, context for comparison
- VQE and variational algorithms — Primary use case for PennyLane
- NISQ era and quantum algorithms — Why framework choice matters
Вопросы для размышления
- Why does explicit Moment control in Cirq matter for NISQ devices with limited coherence time?
- How does the parameter-shift rule differ from numerical gradients - in which cases does this matter?
- Is it better to build a production QML system on one framework or combine multiple?