Chuyển đến nội dung
Skillpedia
Agent51k · #3551

qiskit

Skill này làm gì

Qiskit là công cụ để tạo và chạy chương trình trên máy tính lượng tử. Nó cho phép bạn xây dựng mạch lượng tử, mô phỏng cách chúng hoạt động và gửi chúng để chạy trên máy thật.

Khi nào nên dùng

  • ✓Khi bạn muốn thử nghiệm ý tưởng điện toán lượng tử trên máy của mình.
  • ✓Khi chuẩn bị và gửi thí nghiệm lên máy tính lượng tử của IBM.
  • ✓Khi phát triển thuật toán lượng tử cần mô phỏng hoặc chạy trên phần cứng thật.

Liên kết skill

https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/qiskit/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/qiskit/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 H cho qubit thứ nhất và cổng CX giữa hai qubit, rồi mô phỏng kết quả.”

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

Cách hoạt động

Qiskit chuyển các chỉ dẫn của bạn thành các phép toán lượng tử mà máy tính lượng tử có thể hiểu. Nó có thể mô phỏng các phép toán này trên máy tính thông thường hoặc gửi đến bộ xử lý lượng tử thật.

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.

Qiskit

Use current Qiskit 2.x APIs to build circuits, prepare hardware-compatible instruction set architecture (ISA) circuits, and execute them through V2 primitives.

Reviewed 2026-10-01 with local tests on qiskit==2.5.2, qiskit-ibm-runtime==0.50.0, and qiskit-aer==0.17.2. IBM account, QPU, session, and batch examples are illustrative and documentation/source-checked; no remote workloads were submitted. See references/sources.md for the verification boundary.

Runtime 0.50 deprecates the top-level SamplerV2/EstimatorV2 implementations. New code imports Sampler from qiskit_ibm_runtime.executor_sampler and Estimator from qiskit_ibm_runtime.executor_estimator. These still implement the V2 PUB interface, using client-side processing and Executor. Use option models from qiskit_ibm_runtime.options_models.

Choose the Right Path

Goal Recommended interface
Ideal evolution with finite-shot sampling qiskit.primitives.StatevectorSampler
Exact local expectation values qiskit.primitives.StatevectorEstimator
High-performance or noisy simulation Qiskit Aer
IBM QPU sampling qiskit_ibm_runtime.executor_sampler.Sampler
IBM QPU expectation values and mitigation qiskit_ibm_runtime.executor_estimator.Estimator
Backend without native primitives BackendSamplerV2 or BackendEstimatorV2
Open-system or master-equation dynamics Prefer QuTiP
Differentiable quantum machine learning Prefer PennyLane unless Qiskit integration is required

Installation

Create an isolated environment and install only the components needed:

uv venv --python 3.13
source .venv/bin/activate

# Core SDK plus plotting support
uv pip install "qiskit[visualization]==2.5.2"

# Add only when needed
uv pip install "qiskit-ibm-runtime==0.50.0"
uv pip install "qiskit-aer==0.17.2"

Do not install qiskit-terra; it was superseded by the qiskit distribution. Qiskit Runtime, Aer, Nature, Machine Learning, Optimization, and Algorithms are separate distributions.

For IBM account setup, CI-safe credential handling, optional packages, and environment repair, read references/setup.md.

Core Workflow

Follow this sequence for every hardware-oriented workload:

  1. Map the problem to a circuit and, for Estimator, one or more observables.
  2. Optimize the parameterized circuit once for the selected backend.
  3. Apply the layout to every observable.
  4. Execute ISA circuits through a V2 primitive using Primitive Unified Blocs (PUBs).
  5. Analyze register-aware results, metadata, uncertainty, and resource usage.

Do not bind and retranspile a parameterized circuit inside every optimizer iteration. Transpile the parameterized circuit once, then pass parameter arrays in PUBs.

Quick Local Sampling

from qiskit import QuantumCircuit
from qiskit.primitives import StatevectorSampler

circuit = QuantumCircuit(2)
circuit.h(0)
circuit.cx(0, 1)
circuit.measure_all()  # creates the classical register named "meas"

sampler = StatevectorSampler(seed=7)
pub_result = sampler.run([circuit], shots=1024).result()[0]
counts = pub_result.data.meas.get_counts()
print(counts)

Sampler V2 preserves shots and classical-register structure. Access the register by its actual name; measure_all() uses meas.

For circuits with multiple classical registers, each register’s counts are a marginal distribution. Preserve shot alignment when computing cross-register correlations; multiplying marginal frequencies destroys those correlations. Use SamplerPubResult.join_data with an explicit register order for joint bitstrings and record that order in the result labels. Qiskit 2.5.2 puts the first joined BitArray register in the least-significant bits, contrary to the current docstring; verify with an asymmetric state. See references/primitives.md.

Quick Local Estimation

import numpy as np
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
from qiskit.primitives import StatevectorEstimator
from qiskit.quantum_info import SparsePauliOp

theta = Parameter("theta")
circuit = QuantumCircuit(2)
circuit.ry(theta, 0)
circuit.cx(0, 1)

observable = SparsePauliOp.from_list([("ZZ", 1.0), ("XX", 0.5)])
parameter_values = [[0.0], [np.pi / 4], [np.pi / 2]]

estimator = StatevectorEstimator(seed=7)
pub = (circuit, observable, parameter_values)

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

“Primitives” trong Qiskit là gì?

Primitives là các khối xây dựng cơ bản giúp đơn giản hóa cách bạn làm việc với bộ mô phỏng và phần cứng lượng tử, chẳng hạn lấy kết quả lấy mẫu hoặc giá trị kỳ vọng.

“Transpilation” là gì?

Transpilation là quá trình tối ưu mạch lượng tử của bạn để nó chạy hiệu quả trên phần cứng lượng tử cụ thể bạn đang dùng.

Tôi có thể dùng Qiskit trên máy tính của mình không?

Có, bạn có thể dùng Qiskit để mô phỏng mạch lượng tử trên máy tính cục bộ, không cần máy tính lượng tử thật.

Chi tiết

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

Builds, simulates, transpiles, and executes quantum circuits with Qiskit and IBM Quantum Runtime. Use for Qiskit 2.x circuits and operators, V2 Sampler or Estimator primitives, target-aware transpilation, local or noisy simulation, IBM QPU execution, Runtime sessions or batches, error mitigation, and Qiskit ecosystem packages.

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

Độ phổ biến

Sao GitHub
51k
Vị trí xếp hạng
#3551
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ự