✨ Add examples/discover_backends.py for IQM QC discovery and selection - #146
Draft
marcelwa wants to merge 7 commits into
Draft
✨ Add examples/discover_backends.py for IQM QC discovery and selection#146marcelwa wants to merge 7 commits into
marcelwa wants to merge 7 commits into
Conversation
QDMI-on-IQM has no example that enumerates available IQM quantum computers and picks one by constraint, mirroring the discovery pattern used by QRMI (list resources, filter, then target the match). No Python/C++ binding currently exposes the server's QC list (each QDMI session is scoped to a single QC), so the example issues the same `api/v1/quantum-computers` request the session already performs internally, then queries each candidate's qubit count and two-qubit gate fidelity through the regular public IQMBackend/QDMI Target API. Assisted-by: Claude Sonnet 5 via Claude Code
Assisted-by: Claude Sonnet 5 via Claude Code
Assisted-by: Claude Sonnet 5 via Claude Code
Assisted-by: Claude Sonnet 5 via Claude Code
Assisted-by: Claude Sonnet 5 via Claude Code
Assisted-by: Claude Sonnet 5 via Claude Code
Query status, per-site T1/T2, and per-operation fidelity through the public mqt.core.fomac Device/Site/Operation API (already available on the existing mqt-core~=3.7.0 pin) instead of the private QDMIBackend._device attribute the script previously avoided reaching into. Correct the "Future direction" note: mqt-core PR #1912 does not fix multi-QC enumeration, since IQM's own C++ device implementation resolves exactly one QC per opened session regardless of mqt-core's device registry; #1912 is relevant only as the mechanism for registering already-known aliases, not as a discovery fix. Assisted-by: Claude Sonnet 5 via Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Summary
Adds
examples/discover_backends.py, a third example alongsidemqt_bench.pyand
qsci_h2.pythat demonstrates discovery rather than targeting asingle, already-known backend: it lists the quantum computers available on an
IQM Server, queries each one's qubit count and (where exposed) two-qubit gate
fidelity, and selects the largest QC that satisfies a
--min-qubitsconstraint, printing what was found and what was chosen.
Motivation
This mirrors the "list resources → filter by constraint → use the match"
pattern used in two 2026 arXiv papers on QRMI, a related IBM/Pasqal-led effort
to integrate quantum resources into HPC schedulers:
service.resources(), picks one,and prints
qrmi.metadata()before building a transpile target.qsub -l qpu=PASQAL_FRESNEL,qpu_ready=1,qpu_slots=6 job.sh— select-by-nameplus numeric constraints (readiness, capacity).
QDMI-on-IQM already exposes the underlying device-property API
(
docs/usage.md: qubit count, coupling map, T1/T2, gate fidelities), but hadno example exercising discovery end-to-end.
What's actually discoverable today (and the resulting design)
Investigating the C++ session-init path (
src/iqm_device.cpp,Process_static_quantum_architecture) and the Python/FoMaC layer(
python/iqm/qdmi/qiskit.py,mqt.core.fomac) turned up:by ID, alias, or "first available" during
IQM_QDMI_device_session_init. The full list of QCs is fetchedonce internally (
GET api/v1/quantum-computers) purely to resolve thatselection — it is not returned to the caller and there is no
Python/C++ binding exposing it.
mqt.core.fomac.Session.get_devices()looked promising but listsstatically registered FoMaC devices (e.g. the DDSIM simulator), not
dynamically loaded IQM QCs, so it doesn't help here either.
reachable through the existing public API once a QC is selected:
IQMBackend(qc_alias=...)plus the standard QiskitTarget(erroronInstructionProperties). T1/T2 is only reachable via a privateQDMIBackend._deviceattribute frommqt-core, so the example reportstwo-qubit gate fidelity as the "calibration quality" signal instead and
documents that limitation rather than reaching into private internals.
Given that, this PR does not add or change any C++/Python binding. The
example issues the same
api/v1/quantum-computersREST call the sessionalready performs internally (documented as a limitation directly in the
script's docstring and in
docs/examples.md), then uses only the existingpublic
IQMBackend/TargetAPI for everything else. A proper "list QCs"binding would be a reasonable, separately-scoped follow-up if this pattern
turns out to be broadly useful, but felt out of scope for a single example
script.
Other changes
noxfile.py: wirediscover_backends.pyinto theexamplesnox session(
--backend sim/--backend iqm), matching the existing two examples.pyproject.toml: addrequests.**totool.ty.analysis.allowed-unresolved-imports,following the existing pattern for example-only dependencies not required by
the core library.
docs/examples.md: new "Discovering and Selecting Backends" section with aliteralincludeof the script and asim-backendcode-cell, matching theexisting two examples' documentation style.
CHANGELOG.md:[Unreleased]entry.Update: Added a documented future-direction note (script docstring +
docs/examples.md) about the IQM Server API's queue-length /availability-window signal (apparently cloud/Resonance-oriented, unconfirmed
for on-prem, not currently surfaced through QDMI-on-IQM's bindings) — no
speculative code calling it.
Update: Replaced the T1/T2/status workarounds with the public
mqt.core.fomacDevice/Site/OperationAPI (Device.status(),Site.t1()/t2(),Operation.fidelity()— all already available on theexisting
mqt-core~=3.7.0pin, no dependency change needed) instead ofreaching into the private
QDMIBackend._deviceattribute. Also corrected thefuture-direction note: verified against the actual installed
mqt-corewheelthat upstream PR munich-quantum-toolkit/core#1912 does not fix multi-QC
enumeration — IQM's own C++ device implementation
(
IQM_QDMI_device_session_initinsrc/iqm_device.cpp) resolves exactly oneQC per opened session regardless of
mqt-core's device registry, so #1912 isrelevant only as the mechanism for registering already-known aliases, not as
a fix for the enumeration problem itself.
Test plan
uvx nox -s lintpasses (ruff,ty— including the newrequestsimport —rumdl, license headers, etc.)uvx nox -s tests-3.14passes (28 passed, 3 skipped live-IQM tests;unchanged — no Python source under
python/iqm/qdmi/was touched, so nonew tests were needed)
uvx nox -s examples -- --backend simpasses, including the newdiscover_backends.py --backend sim --min-qubits 3invocation--backend iqm/ live IQM discovery (would require real IQMServer credentials; intentionally not exercised in this session per
task constraints)
🤖 Generated with Claude Code