♻️ Redesign QDMI device management - #1901
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
MatthiasReumann
left a comment
There was a problem hiding this comment.
This is a great start into the QDMI rewrite! 🚀
I've gone through the code a couple of times now and the following comments are the result of that.
However, currently this can't construct devices at runtime, right? As of now this simply loads dynamic libraries, I think 🤔.
66b0be6 to
b050c37
Compare
78f00ef to
330c111
Compare
|
@MatthiasReumann I am through with another iteration here. Feel free to take another look. I may try to split this into two changes, one that is v3.x compatible but adds the configurability and a separate one that contains the breaking change of dropping the client interface and combining driver and FoMaC. Also pinging @marcelwa @flowerthrower @ystade here for awareness. |
MatthiasReumann
left a comment
There was a problem hiding this comment.
Solid improvements! 🚀
I've left two minor requests and some questions / thoughts in the open discussion above.
Otherwise, I've nothing to complain than we should probably add a bit more documentation on the caching, shared_ptr, lifetime logic to the respective classes. I am pretty sure Codex can help with that ;)
There was a problem hiding this comment.
.hpp file in src folder
There was a problem hiding this comment.
🤖 AI text below 🤖
Fixed. The private implementation header is now src/qdmi/DeviceApi.hpp, and all includes use the .hpp name.
There was a problem hiding this comment.
LLMs at their best. This was obviously not the intended consequence here.
But I still think it is fine to have the private header in the source file here. Otherwise, people would get the idea that they can include this header.
81dd10e to
fc24a9c
Compare
768b78c to
466e58e
Compare
🤖 *AI text below* 🤖 ## Summary This PR extracts the additive, MQT Core 3.x-compatible QDMI configuration foundation from #1901. It adds stable device identities and configurable discovery while retaining the current client interface, `qdmi::Driver`, FoMaC, Qiskit, and neutral-atom APIs. The breaking object-model refactor remains in #1901 and will be rebased onto this foundation. ## What changed - Discover versioned definitions from `qdmi.json`, `[tool.qdmi]`, environment configuration, packaged fragments, and C++ runtime overrides. - Merge definitions by stable device ID with field-wise precedence, explicit disabled-ID reservation, strict validation, relative-path resolution, and explicit or isolated configuration modes. - Register and open devices by stable ID through C++, FoMaC, and Python. Fresh opens create independent sessions and apply per-call overrides without changing the configured client catalog. - Generate relocatable fragments for built-in devices and export neutral `QDMI_DEVICE_ID`, `QDMI_DEVICE_PREFIX`, and `QDMI_MANIFEST_NAME` CMake target metadata. Installed consumers can copy selected device runtimes without project-specific loader code. - Vendor the current toml++ single header used by the native TOML parser. - Document administration, project, environment, C++, Python, relocation, and static-consumer workflows. ## Compatibility and impact The public QDMI client C interface, `MQT::CoreQDMIDriver`, the FoMaC object model, and the existing Qiskit and neutral-atom APIs remain available. The unstable C++ `Driver::addDynamicDeviceLibrary` and Python `add_dynamic_device_library` entry points are replaced by `DeviceDefinition` registration and stable-ID opening; `UPGRADING.md` documents that migration. Configuration discovery and registration do not load device code. A library is loaded when a stable ID is explicitly opened or when the configured client catalog is first materialized. Separately installed device wheels are not scanned automatically; they can register a fallback definition or have their runtime and generated fragment colocated by the consuming build. ## Validation - Release configure and complete 471-step build with LLVM/MLIR 22.1.3 - QDMI Driver suite: 109 passed - Registry suite: 12 passed - FoMaC suite: 174 passed - Neutral-atom FoMaC suite: 2 passed - Imported-device consumer tests: 2 passed - DDSIM suite: 45 passed - QIR JIT, runtime, and runner suites: 9, 63, and 5 passed - Python stub generation through the aggregate wheel target - `uvx nox -s lint` - `git diff --check` Fixes #1362 Fixes #1363
976a9b2 to
4925b38
Compare
🤖 *AI text below* 🤖 Replace the singleton driver and C client with public device registries, immutable manager snapshots, and direct lifetime-safe device state. Preserve current configuration, adapters, bindings, and QDMI object behavior. Assisted-by: GPT-5.6 via Codex
4925b38 to
c191421
Compare
|
I am closing this PR for now. The discussions in the recent weeks have led to the conclusion that the client interface is indeed worth keeping. The evidence for that is #2226, #2229, #2230, #2231 |
🤖 AI text below 🤖
Summary
This PR replaces the overlapping FoMaC and client-driver layers with one public
QDMI device-management flow:
DeviceRegistry → DeviceManager → DeviceThe same object model is used by C++, Python, Qiskit, and the neutral-atom
adapter. The branch now contains only this v4 redesign on top of current
main; the configurable-device foundation from #1912 is already merged.What changed
DeviceRegistrydiscovers configured definitions and supports idempotentfallback registration without loading device code.
DeviceManagerowns an immutable registry snapshot, opens a fresh devicesession for every call, and isolates
openAll()failures by stable device ID.Device,Site,Operation, andJobretain the runtime state required bytheir QDMI handles, so derived objects may safely outlive their manager and
parent wrappers.
canonical path and symbol prefix. Replacement waits for the prior generation
to finish finalization before initializing again.
DeviceDefinitionandSessionParametersaccept path-like library andauthentication-file arguments.
✨ Add binary-safe QDMI program handling to FoMaC #1957: textual formats include the terminating null byte, while binary
formats and
program_bytespreserve exact bytes.objects.
the registry and object model build without bundled devices, while
device-specific bindings, tests, and wheel contents follow their respective
CMake options.
qdmi::Driverpublic APIs are removed;UPGRADING.mddocumentsthe v4 migration.
Configuration and integration
The implementation reuses the merged #1912 configuration contracts:
qdmi.json,[tool.qdmi], stable-ID merging, disabled-ID reservations,relocatable CMake metadata, and runtime manifests. It does not add another
parser or discovery mechanism.
Integration work with QDMI-on-IQM, Amazon Braket, and the QDMI templates led to
an immutable manager, one registration boundary, per-open session overrides,
and direct runtime ownership by the returned object graph.
Independently installed device wheels remain explicit: they expose their
library path and register a fallback definition before constructing a manager.
User configuration and disabled definitions retain precedence.
Validation
skipped by their fixtures
passed
uvx nox -s lintgit diff --check