Chuyển đến nội dung
Skillpedia
Lập trình chung51k · #3438

cirq

Skill này làm gì

Cirq là công cụ để xây dựng và thử nghiệm chương trình máy tính lượng tử. Bạn có thể tạo mạch lượng tử, mô phỏng cách chúng hoạt động và chạy chúng trên máy tính lượng tử thật, đặc biệt là của Google.

Khi nào nên dùng

  • ✓Bạn muốn xây dựng và thử nghiệm mạch lượng tử bằng Python.
  • ✓Bạn cần chạy thí nghiệm trên phần cứng lượng tử của Google.
  • ✓Bạn muốn mô phỏng cách một mạch lượng tử hoạt động, kể cả các lỗi có thể xảy ra.

Liên kết skill

https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/cirq/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/cirq/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tạo một mạch lượng tử đơn giản với hai qubit, áp dụng cổng Hadamard cho một qubit và cổng CNOT giữa chúng, rồi cho tôi biết kết quả đo.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Cirq cho phép bạn định nghĩa các khối cơ bản của máy tính lượng tử, như qubit và cổng logic. Sau đó bạn ghép các khối này thành một mạch và dùng bộ mô phỏng hoặc phần cứng thật để xem kết quả.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Cirq - Quantum Computing with Python

Cirq is Google Quantum AI's open-source framework for designing, simulating, and running quantum circuits on quantum computers and simulators.

When to Use This Skill

Use this skill when:

  • Building, simulating, or optimizing NISQ circuits in Python
  • Running jobs on Google Quantum AI processors (via cirq-google) or partner backends (IonQ, Azure Quantum, AQT, Pasqal)
  • Modeling noise, compiling to hardware gatesets, or designing characterization experiments
  • Using parameter sweeps, transformers, or the ReCirq experiment patterns

For IBM hardware use qiskit; for quantum ML with autodiff use pennylane; for physics simulations use qutip.

Installation

Examples target Cirq 1.7.0 on Python 3.11+. Keep Cirq vendor packages on the matching release; independently versioned integrations such as Azure Quantum need their own compatibility check.

uv pip install "cirq-core==1.7.0"
# Optional OpenQASM import dependency
uv pip install ply

For hardware integration (pin matching versions for reproducibility):

# Google Quantum Engine (requires approved GCP project access)
uv pip install "cirq-google==1.7.0"

# IonQ
uv pip install "cirq-ionq==1.7.0"

# AQT (Alpine Quantum Technologies)
uv pip install "cirq-aqt==1.7.0"

# Pasqal
uv pip install "cirq-pasqal==1.7.0"

# Azure: use a SEPARATE environment; its current extras require Cirq <1.7.
uv pip install "qdk[azure,cirq]==1.32.3" "azure-quantum==3.13.0"

Pin all cirq-* packages in an environment to the same release. The Azure example targets its supported Cirq 1.6.1 stack separately; do not force Cirq 1.7.0 into it. Cirq 1.7.0 updates the IonQ adapter to API v0.4.

Local examples were checked with synthetic circuits. Hardware examples are illustrative and were checked against released source and provider documentation, without submitting cloud jobs. See review evidence.

Quick Start

Basic Circuit

import cirq
import numpy as np

# Create qubits
q0, q1 = cirq.LineQubit.range(2)

# Build circuit
circuit = cirq.Circuit(
    cirq.H(q0),              # Hadamard on q0
    cirq.CNOT(q0, q1),       # CNOT with q0 control, q1 target
    cirq.measure(q0, q1, key='result')
)

print(circuit)

# Simulate
simulator = cirq.Simulator(seed=42)
result = simulator.run(circuit, repetitions=1000)

# Display results
print(result.histogram(key='result'))

Parameterized Circuit

import sympy

# Define symbolic parameter
theta = sympy.Symbol('theta')

# Create parameterized circuit
circuit = cirq.Circuit(
    cirq.ry(theta)(q0),
    cirq.measure(q0, key='m')
)

# Sweep over parameter values
sweep = cirq.Linspace('theta', start=0, stop=2*np.pi, length=20)
results = simulator.run_sweep(circuit, params=sweep, repetitions=1000)

# Process results
for params, result in zip(sweep, results):
    theta_val = params['theta']
    counts = result.histogram(key='m')
    print(f"θ={theta_val:.2f}: {counts}")

Core Capabilities

Circuit Building

For comprehensive information about building quantum circuits, including qubits, gates, operations, custom gates, and circuit patterns, see:

Common topics:

  • Qubit types (GridQubit, LineQubit, NamedQubit)
  • Single and two-qubit gates
  • Parameterized gates and operations
  • Custom gate decomposition
  • Circuit organization with moments
  • Standard circuit patterns (Bell states, GHZ, QFT)
  • Import/export (OpenQASM, JSON)
  • Working with qudits and observables

Simulation

For detailed information about simulating quantum circuits, including exact simulation, noisy simulation, parameter sweeps, and the Quantum Virtual Machine, see:

Common topics:

  • Exact simulation (state vector, density matrix)
  • Sampling and measurements
  • Parameter sweeps (single and multiple parameters)
  • Noisy simulation
  • State histograms and visualization
  • Quantum Virtual Machine (QVM)
  • Expectation values and observables
  • Performance optimization

Circuit Transformation

For information about optimizing, compiling, and manipulating quantum circuits, see:

Common topics:

  • Transformer framework
  • Gate decomposition

…

Câu hỏi thường gặp

Mạch lượng tử là gì?

Mạch lượng tử giống như chương trình cho máy tính lượng tử. Chúng gồm các qubit (đơn vị cơ bản của thông tin lượng tử) và cổng lượng tử (phép toán làm thay đổi trạng thái của qubit).

Tôi có thể dùng Cirq trên mọi máy tính lượng tử không?

Cirq được tối ưu cho phần cứng của Google nhưng cũng dùng được với các nhà cung cấp khác như IonQ và Azure Quantum. Với phần cứng của IBM, tốt nhất nên dùng Qiskit.

Mô phỏng nhiễu là gì?

Máy tính lượng tử nhạy cảm với lỗi (nhiễu). Mô phỏng nhiễu trong Cirq giúp dự đoán những lỗi này có thể ảnh hưởng thế nào đến kết quả của mạch.

Chi tiết

Mô tả gốc của tác giả

Google quantum computing framework. Use when targeting Google Quantum AI hardware, designing noise-aware circuits, or running quantum characterization experiments. Best for Google hardware, noise modeling, and low-level circuit design. For IBM hardware use qiskit; for quantum ML with autodiff use pennylane; for physics simulations use qutip.

repo: K-Dense-AI/scientific-agent-skills

Độ phổ biến

Sao GitHub
51k
Vị trí xếp hạng
#3438
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự