Skip to content

♻️ Redesign QDMI device management - #1901

Closed
burgholzer wants to merge 1 commit into
mainfrom
agent/qdmi-integration-redesign
Closed

♻️ Redesign QDMI device management#1901
burgholzer wants to merge 1 commit into
mainfrom
agent/qdmi-integration-redesign

Conversation

@burgholzer

@burgholzer burgholzer commented Jul 14, 2026

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

Summary

This PR replaces the overlapping FoMaC and client-driver layers with one public
QDMI device-management flow:

DeviceRegistry → DeviceManager → Device

The 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

  • DeviceRegistry discovers configured definitions and supports idempotent
    fallback registration without loading device code.
  • DeviceManager owns an immutable registry snapshot, opens a fresh device
    session for every call, and isolates openAll() failures by stable device ID.
  • Device, Site, Operation, and Job retain the runtime state required by
    their QDMI handles, so derived objects may safely outlive their manager and
    parent wrappers.
  • A process-wide weak cache shares compatible live device libraries by
    canonical path and symbol prefix. Replacement waits for the prior generation
    to finish finalization before initializing again.
  • Python DeviceDefinition and SessionParameters accept path-like library and
    authentication-file arguments.
  • Text and binary program submission preserve the contracts introduced by
    ✨ Add binary-safe QDMI program handling to FoMaC #1957: textual formats include the terminating null byte, while binary
    formats and program_bytes preserve exact bytes.
  • Qiskit and neutral-atom integrations use the unified manager and device
    objects.
  • The optional bundled-device switches introduced by 🐛 Make MQT Core composable as a CMake subproject #1965 remain effective:
    the registry and object model build without bundled devices, while
    device-specific bindings, tests, and wheel contents follow their respective
    CMake options.
  • The FoMaC and qdmi::Driver public APIs are removed; UPGRADING.md documents
    the 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

  • complete Release build with LLVM/MLIR 22
  • all 3,882 CTest cases passed; two device job-ID cases were intentionally
    skipped by their fixtures
  • separate configuration with all bundled devices disabled: 12 registry tests
    passed
  • Python 3.14: 397 passed, 3 upstream-Qiskit skips
  • Python stub generation
  • warning-as-error documentation build
  • full uvx nox -s lint
  • git diff --check

@burgholzer burgholzer self-assigned this Jul 14, 2026
@burgholzer burgholzer added refactor Anything related to code refactoring major Major version update QDMI Anything related to QDMI labels Jul 14, 2026
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.77804% with 27 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/qdmi/Device.cpp 96.0% 20 Missing ⚠️
src/qdmi/DeviceRegistry.cpp 94.2% 4 Missing ⚠️
src/qdmi/DeviceState.cpp 96.3% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@MatthiasReumann MatthiasReumann left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🤔.

Comment thread include/mqt-core/qdmi/DeviceManager.hpp Outdated
Comment thread include/mqt-core/qdmi/Device.hpp Outdated
Comment thread include/mqt-core/qdmi/Device.hpp Outdated
Comment thread src/qdmi/DeviceManager.cpp Outdated
Comment thread src/qdmi/DeviceManager.cpp Outdated
Comment thread include/mqt-core/qdmi/DeviceManager.hpp Outdated
@mergify mergify Bot added the conflict label Jul 15, 2026
@burgholzer
burgholzer force-pushed the agent/qdmi-integration-redesign branch 2 times, most recently from 66b0be6 to b050c37 Compare July 15, 2026 11:54
@mergify mergify Bot removed the conflict label Jul 15, 2026
@burgholzer
burgholzer force-pushed the agent/qdmi-integration-redesign branch from 78f00ef to 330c111 Compare July 15, 2026 14:13
@burgholzer

Copy link
Copy Markdown
Member Author

@MatthiasReumann I am through with another iteration here. Feel free to take another look.
Note that this does not yet touch the SC and NA devices and makes them configurable. That would be a follow-up.
I still believe this is shaping up quite nicely.

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.
That also might be a nice separation of concerns.

Also pinging @marcelwa @flowerthrower @ystade here for awareness.
If you want a very quick overview of the changes, read https://github.com/munich-quantum-toolkit/core/blob/agent/qdmi-integration-redesign/UPGRADING.md#qdmi-device-management-has-been-redesigned.

@MatthiasReumann MatthiasReumann left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ;)

Comment thread src/qdmi/DeviceApi.hpp

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.hpp file in src folder

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI text below 🤖

Fixed. The private implementation header is now src/qdmi/DeviceApi.hpp, and all includes use the .hpp name.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/qdmi/DeviceApi.cpp
@mergify mergify Bot added the conflict label Jul 25, 2026
@burgholzer
burgholzer force-pushed the agent/qdmi-integration-redesign branch from 81dd10e to fc24a9c Compare July 27, 2026 14:56
@mergify mergify Bot removed the conflict label Jul 27, 2026
@burgholzer
burgholzer force-pushed the agent/qdmi-integration-redesign branch 2 times, most recently from 768b78c to 466e58e Compare July 27, 2026 15:52
@burgholzer
burgholzer changed the base branch from main to codex/qdmi-configuration-foundation July 27, 2026 18:39
burgholzer added a commit that referenced this pull request Jul 29, 2026
🤖 *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
Base automatically changed from codex/qdmi-configuration-foundation to main July 29, 2026 19:36
@mergify mergify Bot added the conflict label Jul 29, 2026
@burgholzer
burgholzer force-pushed the agent/qdmi-integration-redesign branch 2 times, most recently from 976a9b2 to 4925b38 Compare July 30, 2026 07:45
@mergify mergify Bot removed the conflict label Jul 30, 2026
@mergify mergify Bot added the conflict label Jul 30, 2026
🤖 *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
@burgholzer
burgholzer force-pushed the agent/qdmi-integration-redesign branch from 4925b38 to c191421 Compare August 19, 2026 00:14
@burgholzer

Copy link
Copy Markdown
Member Author

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
The QDMI v1.4 release will enable truly exchangeable QDMI drivers, which requires a stable (C) interface; the client interface. We are still tweaking the wording around all of this.
But we are no longer conflating the Driver implementation and the C++ QDMI abstraction.

@burgholzer burgholzer closed this Aug 27, 2026
@mergify mergify Bot removed the conflict label Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

major Major version update QDMI Anything related to QDMI refactor Anything related to code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants