Alterlab qiskit

From AlterLab-IEU/AlterLab-Academic-Skills · View interactive version

Alterlab qiskit is an AI agent skill from the GitHub repository AlterLab-IEU/AlterLab-Academic-Skills. Builds, transpiles, and runs quantum circuits with Qiskit, IBM's quantum computing framework, including Qiskit Runtime primitives (Sampler/Estimator), circuit transpilation, and error mitigation on IBM Quantum hardware. Use when targeting IBM Quantum backends, transpiling circuits, running Runtime s

How to use this skill

Skill file

Qiskit

Overview

Qiskit is an open-source quantum computing framework. Build quantum circuits, optimize for hardware, execute on simulators or real quantum computers, and analyze results. Supports IBM Quantum (100+ qubit Heron and Nighthawk systems), IonQ, Amazon Braket, and other providers.

Keyless by default. The core of this skill — building and transpiling circuits and running them on local simulators (StatevectorSampler, StatevectorEstimator, Aer), including VQE/QAOA and textbook algorithms — runs entirely offline with no account or token. Submitting to IBM Quantum hardware through Qiskit Runtime is an optional add-on that uses an IBM Quantum token; with no token, transpile for the target backend and run on a (noisy) local simulator first.

Version note: Examples target Qiskit SDK 2.x (qiskit>=2,<3, Python 3.10+; current 2.5.x as of 2026-09) and qiskit-ibm-runtime ≥ 0.40 (current 0.49). Older tutorials break on these changes, so check any snippet you adapt against them:

When to Use This Skill

Use this skill when the user wants to:

Does NOT Trigger

| Scenario | Use Instead |

|----------|-------------|

| Google Quantum AI processors, Cirq-native circuits, or XEB/RB characterization in Cirq | alterlab-cirq |

| Gradient-trained hybrid quantum-classical models with PyTorch/JAX autodiff | alterlab-pennylane |

| Open-system dynamics — Lindblad master equations, decoherence, cavity QED | alterlab-qutip |

| Classical quantum-chemistry (DFT, conformers, pKa) with no quantum circuits | alterlab-rowan |

Hand-off rule. When the request matches a row above, open your answer by naming that skill by its exact id (for example alterlab-cirq) and saying in one line why it fits better, then stop applying this skill's procedure. Name it even when you also need to ask for missing input. If only part of the request is out of scope, name the skill for that part and do only the in-scope part. A brief general pointer is fine; the named skill does the work.

Key Features:

Quick Start

Installation

uv pip install "qiskit>=2,<3"
uv pip install "qiskit[visualization]" matplotlib   # circuit/result plotting
uv pip install qiskit-ibm-runtime                   # IBM hardware + Runtime primitives

First Circuit

from qiskit import QuantumCircuit
from qiskit.primitives import StatevectorSampler

# Create Bell state (entangled qubits)
qc = QuantumCircuit(2)
qc.h(0)           # Hadamard on qubit 0
qc.cx(0, 1)       # CNOT from qubit 0 to 1
qc.measure_all()  # Measure both qubits

# Run locally
sampler = StatevectorSampler()
result = sampler.run([qc], shots=1024).result()
counts = result[0].data.meas.get_counts()
print(counts)  # {'00': ~512, '11': ~512}

Visualization

from qiskit.visualization import plot_histogram

qc.draw('mpl')           # Circuit diagram
plot_histogram(counts)   # Results histogram

Core Capabilities

1. Setup and Installation

For detailed installation, authentication, and IBM Quantum account setup:

Topics covered:

2. Building Quantum Circuits

For constructing quantum circuits with gates, measurements, and composition:

Topics covered:

3. Primitives (Sampler and Estimator)

For executing quantum circuits and computing results:

Topics covered:

4. Transpilation and Optimization

For optimizing circuits and preparing for hardware execution:

Topics covered:

5. Visualization

For displaying circuits, results, and quantum states:

Topics covered:

6. Hardware Backends

For running on simulators and real quantum computers:

Topics covered:

7. Qiskit Patterns Workflow

For implementing the four-step quantum computing workflow:

Topics covered:

8. Quantum Algorithms and Applications

For implementing specific quantum algorithms:

Topics covered:

Workflow Decision Guide

If you need to:

Best Practices

Development Workflow

  1. Start with simulators: Test locally before using hardware

```python

from qiskit.primitives import StatevectorSampler

sampler = StatevectorSampler()

```

  1. Always transpile: Optimize circuits before execution

```python

from qiskit import transpile

qc_optimized = transpile(qc, backend=backend, optimization_level=3)

```

  1. Use appropriate primitives:
  1. Choose execution mode:

Performance Optimization

Hardware Execution

Common Patterns

Pattern 1: Simple Circuit Execution

from qiskit import QuantumCircuit, transpile
from qiskit.primitives import StatevectorSampler

qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()

sampler = StatevectorSampler()
result = sampler.run([qc], shots=1024).result()
counts = result[0].data.meas.get_counts()

Pattern 2: Hardware Execution with Transpilation

from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2 as Sampler
from qiskit.transpiler import generate_preset_pass_manager

service = QiskitRuntimeService()
backend = service.least_busy(operational=True, simulator=False)

# Hardware only accepts ISA circuits (native gates + connectivity)
pm = generate_preset_pass_manager(backend=backend, optimization_level=3)
qc_isa = pm.run(qc)

sampler = Sampler(mode=backend)          # job mode; pass a Session/Batch for other modes
job = sampler.run([qc_isa], shots=1024)
counts = job.result()[0].data.meas.get_counts()

Pattern 3: Variational Algorithm (VQE)

from qiskit_ibm_runtime import Session, EstimatorV2 as Estimator
from scipy.optimize import minimize

# Transpile once, then lay the observable out on the same physical qubits —
# an un-mapped observable does not match the ISA circuit's width.
ansatz_isa = pm.run(ansatz)
hamiltonian_isa = hamiltonian.apply_layout(ansatz_isa.layout)

with Session(backend=backend) as session:      # paid plans; use Batch on the Open Plan
    estimator = Estimator(mode=session)

    def cost_function(params):
        # parameter values travel in the PUB — no re-transpiling per iteration
        result = estimator.run([(ansatz_isa, hamiltonian_isa, params)]).result()
        return float(result[0].data.evs)

    result = minimize(cost_function, initial_params, method='COBYLA')

Additional Resources

Part of the AlterLab Academic Skills suite.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.