/qiskit-ai-skills:migrate-qiskit-ibm-runtimefrom qiskit-ai-skills
Migrates qiskit-ibm-runtime workloads across major versions: V1 primitives to V2 interface, server-side V2 to client-side (Executor-backed) SamplerV2/EstimatorV2, plus non-primitive breaking changes like auth/channel, backend.run(), result streaming, and custom programs.
Ships in qiskit-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are migrating a qiskit-ibm-runtime workload from an older version up to the latest
release, and — when the installed runtime supports it — onward to the new client-side
(Executor-backed) SamplerV2 / EstimatorV2. The workload may exercise many breaking changes
across releases; each is a change described in registry.yaml, grouped by domain
(primitives are the bulk; account-channel, execution, programs, and misc-deprecations are the
rest). Your edits must be grounded in the selected change's guide — a local file, or a live url
for the documented ones — not in general knowledge. Follow these phases in order. Do not skip
Phase 1.
Read .claude/skills/migrate-qiskit-ibm-runtime/registry.yaml. It enumerates every supported
change with its domain, version window, detection triggers, grounding source, and status. Read
target_rule in full — it defines the two-layer destination (hop A = latest documented API;
hop B = client-side primitives, released in 0.50.0, grounded in a published guide) — and note
min_runtime_version and each change's status.
Parse $ARGUMENTS for up to three things:
id (e.g. v1-to-v2, server-to-client,
account-channel) or an unambiguous phrase. If present, use it instead of auto-selecting, but
still run Phase 2 detection as a sanity check and warn if the code shows no detect_primary
signal and the version window doesn't include it.Determine the source and target versions (opportunistic — a precise source version is not required):
IBMSampler/IBMEstimator ⇒ pre-0.5, auth= ⇒ pre-0.3, IBMRuntimeService
⇒ pre-0.6, circuit_indices ⇒ pre-0.15, quasi_dists/.values ⇒ the V1 era (pre-0.28),
backend.run( ⇒ pre-0.35, channel="ibm_quantum" ⇒ pre-0.42. Accept a user-supplied source
version if given. If nothing pins it, say so and proceed on trigger matches alone.qiskit-ibm-runtime version (e.g.
python -c "import qiskit_ibm_runtime as q; print(q.__version__)"). This fixes the latest
reachable API and decides whether hop B (client-side primitives, >= 0.50.0) is available.
If the package isn't installed, note that hop B can't be verified and continue with what you can.Grep the scoped code against every change's detect_primary and detect_secondary lists.
detect_primary match (usually the import source or a symbol absent from modern code)
assigns the change.detect_secondary match is broad and corroborating only — record the file path, line number,
and the literal matched line's text, and carry it forward so the user can eyeball-confirm a
genuine usage. Never assign a change on a secondary match alone.[applies_from, applies_to). For a code_evidence: environment change (state not visible by
grepping source, e.g. which fake-backend classes exist), rely on the version window and say so
rather than staying silent.already_migrated substrings as an early exit: a usage already on the
destination (e.g. importing from executor_sampler / executor_estimator) is reported and
skipped, unless there are still un-migrated usages elsewhere.If a forced change was given, honor it (with the warning above). Otherwise select every change
that detection or the version window includes. Group detected changes by domain for the
report, and do not migrate a construct you have not read — read enough surrounding code (PUB
construction, options tree, result post-processing, try/except blocks, account setup) to know which
checklist items actually apply.
Process detected changes in order (ascending), which puts documented hop-A changes before the
client-side hop-B destination. For each:
status is placeholder, or its guide source cannot be resolved (no url and the
local guide file is missing or absent), report the change as recognized but not yet supported
and make no edits for it. Say what would migrate and that the actions are not authored yet. This
is how the non-primitive domains behave until their guides are written.url, fetch it (WebFetch, or the
qiskit-docs MCP tools search_docs_tool / get_page_tool); otherwise read the local guide
file in full. Each change has exactly one of the two — a published page, or a local guide
file in this folder — so there is no local fallback for a url entry: if the fetch fails, say so and
make no edits for that change rather than migrating it from memory. Hop B is url-grounded
like hop A; the client-side primitives have their own published migration guide. Treat the guide's
incompatible-changes table(s) and worked sections as the authoritative checklist for Phase 5. If
any input, output, or option is unclear, consult the reference links at the bottom of the guide
before guessing.companion_guide or a companion_url (or the
guide states that it inherits/shares changes with another guide), resolve and read that companion
too — companion_url is fetched, companion_guide is read locally — and treat its checklist as
part of this change's checklist in Phase 5.
This is how a compound change (for example v1-to-v2, whose client-side destination is documented
in the shared server-to-client guide) picks up the shared changes without duplicating them.NoiseLearner → NoiseLearnerV3 migration) are part of the grounding when the code you
are migrating touches that surface: fetch the linked page too rather than working from general
knowledge. Doc links are written root-relative (/docs/guides/...); prefix
https://quantum.cloud.ibm.com to fetch them.>= 0.50.0. If it is older,
complete hop A, then report that the client-side destination requires an upgrade and stop short of
claiming the client-side migration is done.Apply the selected change's import_rewrite (from → to) pairs from the registry. Keep this generic
editing discipline (it holds for any change):
from ... import ... line with other names, split the
line so only the migrated names move to their new modules while unrelated names
(QiskitRuntimeService, Batch, Session, NoiseLearnerV3, …) stay on the original import.SamplerV2 as Sampler) and the code that depends on them.Any change-specific import caveat (for example, "don't collapse to the future top-level form") comes
from the guide and the registry entry's note — surface it, don't hard-code it here.
Walk each row of the guide's incompatible-changes table(s) against the usages found in Phase 2. The guide is the source of every specific change; this file only carries the generic policy:
id it belongs to) for every item so the user can
trace it back.Editing directives that the guide's terse rows do not spell out, and that you must apply on any change:
except tuple — don't replace it. If the
same block guards other calls, keep the original type and add the new one (e.g.
except (IBMInputValueError, RuntimeError)).$ARGUMENTS requested it.job.inputs[...], job.result().metadata[...], result data fields) are only what the guide
enumerates. If the guide does not show the path you need, say so and consult its reference links
— do not extrapolate a plausible-looking one.twirling_strategy="all") to illustrate the mechanism; that value belongs to that example,
not to every migration that touches the same option. If the source left the option unset,
carry over its class's documented default (check the source option class's docstring/field
default — don't assume it matches the destination API's own default, the two often differ), not
whatever value happens to appear in the guide. A wrong-but-plausible value here changes results
silently — it won't raise, and Phase 6's local verification only checks option paths/types, not
behavior — so re-derive rather than pattern-match.These checks catch the most common breakage without submitting hardware jobs. They test the shared client-side destination (hop B), so they are the same regardless of which change led there, and are kept self-contained here (they do not depend on the guide, which may be remote).
These checks exercise the migrated code. Very old source (the guide's "Older V1 syntax you may
need to modernize first" forms — IBMSampler / IBMEstimator, IBMRuntimeService,
context-manager/constructor-input usage, circuit_indices / observable_indices — as well as
removed non-primitive surface like backend.run()) generally won't even import on a current
qiskit-ibm-runtime, so run these checks only after the legacy forms have been normalized and
rewritten — never against the original code to conclude the migration failed.
from qiskit_ibm_runtime.executor_sampler import SamplerV2 and
from qiskit_ibm_runtime.executor_estimator import EstimatorV2 import cleanly. If they fail with
ModuleNotFoundError, the installed qiskit-ibm-runtime predates the client-side implementations
(registry min_runtime_version: 0.50.0) — report the required upgrade and stop short of claiming
the client-side (hop-B) migration is complete.SamplerV2 /
EstimatorV2 classes are deprecated and
constructing one emits a DeprecationWarning naming qiskit_ibm_runtime.executor_sampler.Sampler
/ qiskit_ibm_runtime.executor_estimator.Estimator as the replacement. If that warning appears
while verifying, a hop-B usage was missed: find the remaining server-side construction and migrate
it. The "have no effect in local testing mode" options warning below means the same thing.SamplerV2(mode=FakeManilaV2(), options=...)) and run a small circuit through it to
catch renamed/invented attributes before the user hits them at run time. Prefer a small fake
backend here regardless of which QPU the workload targets — this step checks option paths, and
mitigation now really runs locally (see below), so a 100+ qubit fake device buys nothing and can
exhaust memory.
Always Cliffordize the circuit before running it in local mode. A fake-backend run uses a
statevector/noisy simulator, whose cost grows exponentially with qubit count and depth — a
realistic workload circuit can hang or exhaust memory. Since the goal here is only to exercise
the option paths and types (not to reproduce physical results), reduce the circuit to a
Clifford one first: Clifford circuits simulate efficiently (stabilizer simulation) regardless of
size. Use ConvertISAToClifford, which rounds each RZ/RZZ/RX angle to the nearest multiple
of π/2:
from qiskit.transpiler import PassManager
from qiskit_ibm_runtime.transpiler.passes import ConvertISAToClifford
clifford = PassManager([ConvertISAToClifford()]).run(isa_circuit)
# then run `clifford` (not the original) through the fake-backend primitive
ConvertISAToClifford requires an ISA circuit as input (the output of
generate_preset_pass_manager(...).run(...) targeting the backend) — it raises ValueError on
any non-ISA gate. If the code you are verifying builds an abstract circuit and never transpiles
it, transpile it to the fake backend's ISA first, then Cliffordize. This is a verification-only
transformation: never apply it to the circuit the user actually submits to hardware, since it
changes the computation.
Two consequences of Cliffordizing that will break the local run if you don't account for them (both confirmed against 0.50.0):
.layout attribute is dropped. The Cliffordized circuit keeps the same qubit count but
clifford.layout is None, so observable.apply_layout(clifford.layout) fails. For Estimator,
lay the observable out from the pre-Clifford ISA circuit:
isa_obs = observable.apply_layout(isa_circuit.layout), then run (clifford, isa_obs).clifford.num_parameters becomes 0. A PUB that still carries a
parameter-values array will then fail coercion ("Length of () inconsistent ..."). For local
verification, drop the parameter array from the PUB (e.g. (clifford, isa_obs) instead of
(clifford, isa_obs, values)); the real hardware run keeps the original parametric circuit and
its values untouched.python -m py_compile <files>).Run these via Bash. If the environment can't be set up (no qiskit-ibm-runtime installed), say so
and mark verification as skipped rather than asserting the code works.
What a fake backend can and cannot verify. Local testing mode (Fake* backends) is useful but
does not exercise the real service path, so be precise about what a green run actually proves — do
not over-claim:
twirling, dynamical_decoupling, and
the resilience methods in local testing mode, so a fake-backend run exercises the mitigation
code path itself rather than only the option names (confirmed on 0.50.0: the same Bell-state ZZ
estimate on FakeManilaV2 moves from 0.870 at resilience_level=0 to 0.984 with
zne_mitigation=True, with no warning emitted). Three things still to be precise about:
FakeManilaV2, 5
qubits) or a noiseless AerSimulator, and Cliffordize as below. On a noiseless backend, ZNE has
nothing to extrapolate from and warns "No positive, finite standard errors were found; falling
back to an unweighted fit" — benign, and expected there.qiskit_ibm_runtime.SamplerV2 / EstimatorV2 on a fake backend emit UserWarning: Options {...} have no effect in local testing mode and return the unmitigated value (confirmed on
0.50.0). Treat that warning as a signal you are verifying pre-hop-B code, not as benign: the
migration to the executor_* primitives is incomplete.NoiseLearnerV3 has no local testing mode. If your migration added an explicit noise-learning
step (the guide's PEA/PEC section), you cannot run NoiseLearnerV3 against a fake backend to
verify it: its mode accepts only a real Backend, Session, or Batch, so there is no
simulator path. Do not attempt to construct or run it locally. Instead, verify the noise-learning
code by checking it against the API reference —
https://quantum.cloud.ibm.com/docs/api/qiskit-ibm-runtime/noise-learner-v3-noise-learner-v3.md
— confirming the constructor, run(instructions) input shape, and the unique-layer helper are
used as documented. Byte-compile still applies, but state clearly in the report that this part is
API-reference-verified only, not executed.Session/Batch CAN be constructed and run locally against a fake backend — unlike
NoiseLearnerV3 above, do not skip this. Session(fake_backend) / Batch(fake_backend)
construct without contacting any service, and SamplerV2(mode=session) /
SamplerV2(mode=batch) run exactly like passing the backend directly — local testing mode has no
session/batch concept, so it silently ignores the wrapper and executes locally (confirmed against
0.50.0: the returned job is a LocalRuntimeJob, no warning is emitted). This does not verify
session/batch semantics (queueing, max_time, sharing a backend lock across jobs) — only the
option paths and call syntax around mode=session / mode=batch, same as any other fake-backend
check. Use it to confirm the migrated Session/Batch construction and the primitive calls inside
it are well-formed, then note in the report that session/batch-specific behavior itself is
reference-verified only.
job.queue_info() removal (see the job-management-removed change)
was caught: running a Session/Batch-wrapped call against a fake backend produced a
LocalRuntimeJob whose dir() had no queue_info — which then turned out to be true of the
real-service RuntimeJobV2 too (confirmed against its API reference, not just the local job
class). A fake-backend run surfaces a missing/renamed job-object attribute exactly like it
surfaces a missing option-tree attribute; don't assume such an AttributeError is a
local-testing-mode-only artifact without checking the real job class's API reference too.Summarize in plain prose:
>= 0.50.0).domain, which change each file was assigned to, and any file
reported as already-migrated or recognized-but-placeholder (non-primitive domains that were
detected but whose actions aren't authored yet).id) it came from.SamplerV2/EstimatorV2. Remind that
client-side jobs may take longer (offer INFO logging if not already added).Do not claim the workload is fully migrated if any flagged item is unresolved, verification was skipped, or a detected non-primitive change is still a placeholder — say exactly what remains.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
5 skills in this plugin
/managed-workflows-quickstartHelp a researcher whose local quantum-classical workflow (AQC-Tensor, QAOA, SQD, VQE, Trotter/MPS, error mitigation, or any Python code) has outgrown their machine run it on IBM Quantum Managed Workflows — size it roughly, wrap it as a function, deploy it, run it, and scale it up. For their own use; not for contributing a template to qiskit-function-templates. Use when the kernel dies, the process is killed, or it runs out of memory; they shrink the active space, qubits, bond dimension, depth or samples to make it fit; optimizer loops, sweeps or many instances take hours; a laptop stays open overnight or while QPU jobs queue; they ask whether a GPU or a bigger machine would help; they want to run their own code as a Qiskit Function, or choose sizes_map or function_size./select-error-mitigationSelect and configure an error mitigation/suppression strategy for a Qiskit quantum workload, grounded in the capability registry in this skill directory. Use when the user runs /select-error-mitigation, or asks which error mitigation technique(s) to use for an Estimator, Sampler, or Executor workload./select-sqd-eigensolverChoose and integrate a solver for the diagonalization step of a sample-based quantum diagonalization (SQD) workflow — PySCF, Dice, SBD, or Fulqrum (which supplies the matrix-vector product, not an eigensolver). Use whenever the user runs /select-sqd-eigensolver or is deciding how to diagonalize in SQD, even if they name no solver: which SCI solver or sci_solver to pass to diagonalize_fermionic_hamiltonian; an SQD or configuration-recovery run that is too slow or out of memory; scaling past ~30 orbitals; RDMs for embedding or fragmentation; excited states or multiple roots; spin penalties or spin contamination; GPUs, MPI, mpirun or SPMD/collective launch; GDB or general non-product subspaces; swapping one solver for another; which eigensolver to pair with Fulqrum (scipy or PRIMME); the paper to cite or hosted documentation. Also use before telling the user whether a solver supports a capability. Not for circuit construction, sampling or other qiskit-addon-sqd steps that do not touch the solver.npx claudepluginhub qiskit/skills --plugin qiskit-ai-skillsOther plugins' skills for the same job