✨ Add an optional packaged QDMI Driver extension - #2230
Conversation
9e7ae7b to
15473b3
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
15473b3 to
1496655
Compare
e81a275 to
5c00537
Compare
5c00537 to
8a351cf
Compare
burgholzer
left a comment
There was a problem hiding this comment.
This one also triggered quite a couple of general comments that also apply down the stack and should be considered in the next iteration.
| freezes its registry. Staging the packaged library does not select it as the | ||
| generic Client driver. The first successful raw standard or targeted session | ||
| allocation selects a Client driver. A later targeted-session initialization or | ||
| device query failure does not undo that selection. |
There was a problem hiding this comment.
I believe that some of this will (have to) change based on the review in the PR this is stacked on.
There was a problem hiding this comment.
The wording here and throughout will have to be adapted based on the feedback on nomenclature in the lower PRs.
| class Device; | ||
| class Operation; | ||
|
|
||
| namespace default_driver { |
There was a problem hiding this comment.
Is "default_driver" really what we want to use in terms of nomenclature?
Maybe "builtin_driver" would already be better.
Outside of MQT Core, I'd generally like to refer to it as the MQT Core QDMI Driver. I am not sure how well this flows internally in the project.
Maybe the driver we have could be framed as the QDMI Driver, while the framework also offers support for third-party drivers.
This already affects a lower PR in the stack and should correspondingly be updated there already.
| if (auto xdg = environmentUtf8("XDG_CONFIG_HOME")) { | ||
| appendIfFile(files, pathFromUtf8(*xdg) / "mqt-core" / "qdmi.json"); | ||
| } else if (auto home = environmentUtf8("HOME")) { | ||
| appendIfFile(files, | ||
| pathFromUtf8(*home) / ".config" / "mqt-core" / "qdmi.json"); |
There was a problem hiding this comment.
Is the Utf8 in these names really that important? I'd argue we can just drop it (likely already in a PR further down the stack)
| /// Stages one low-precedence package manifest before the driver is frozen. | ||
| auto stagePackageManifest(const std::filesystem::path& path) -> int; | ||
|
|
||
| /// Freezes and returns the staged package manifests. | ||
| [[nodiscard]] auto freezePackageManifests() | ||
| -> std::vector<std::filesystem::path>; | ||
|
|
||
| /// Reopens package-manifest staging after driver construction fails. | ||
| void rollbackPackageManifestFreeze(); |
There was a problem hiding this comment.
Another nomenclature thing "Package Manifest" does not sound like the very best fit.
Maybe "Device Library Manifest" or something more in the direction of "Device Record(s)". I am pretty sure there is good established terminology in CS for that that we can comfortably apply to quantum. This also already applies further down the stack.
| LoadedClient::AddManifest addManifest{}; | ||
| LoadedClient::SessionAllocForDevice sessionAllocForDevice{}; |
There was a problem hiding this comment.
Does it make sense to list these as separate members here, or would it make more sense to define some kind of Extension POD to aggregate the extension functionality. Might make it easier if we want to extend it in the future.
There was a problem hiding this comment.
The added code here does not only feel overly complex, it also feels like it does not really concern this PR but rather #2229 and the implementation there.
Since this adds quite a bit of complexity, it may make sense to already fold the relevant parts into #2229 and look at the big picture as to whether the added complexity really makes sense or whether there is a more minimal but equally powerful solution.
| constexpr auto WARNING_MODE = "MQT_CORE_QDMI_TEST_DEVICE_WARNING"; | ||
|
|
||
| [[nodiscard]] auto warningMode() -> std::string_view { | ||
| const auto* const value = std::getenv(WARNING_MODE); | ||
| return value == nullptr ? std::string_view{} : std::string_view{value}; | ||
| } | ||
|
|
||
| [[nodiscard]] auto successfulStatus(const std::string_view operation) -> int { | ||
| const auto mode = warningMode(); | ||
| return mode == "all" || mode == operation || | ||
| (mode == "children-null" && operation == "children") | ||
| ? QDMI_WARN_GENERAL | ||
| : QDMI_SUCCESS; | ||
| } |
There was a problem hiding this comment.
This whole warning handling feels like it is adding something that we have not really used before. No one in the QDMI community that I know of has been using warnings so far, so I am not sure the ecosystem is equipped to deal with the consequences of getting QDMI_WARN_GENERAL instead of QDMI_SUCCESS.
Obviously, we could set a good precedent here, but this feels like it does not necessarily belong in this PR stack, but rather a follow-up.
This would probably also mandate something like "warnings as errors", which only further complicates the design.
For now, I think we should stick with logging warnings, but not making use of QDMI_WARN_GENERAL
There was a problem hiding this comment.
We should absolutely make sure that all of these tests added here are genuinely useful or just pin down implementation details instead of asserting useful/expected behavior. This holds for the entire PR stack!
There was a problem hiding this comment.
Let's try to minimize test files that only contain a single test. If we continue like this, we'll have more test files than actual library files, which is certainly not sustainable. Mitigate that in the next round of iteration on the entire stack.
Do not add tests simply to meet the 90% coverage target. If it cannot reasonably be met without going out of ones way, it should be purposely decided that it is not necessary to cover all possible failure conditions.
Assisted-by: GPT-5.6 Sol via Codex
8a351cf to
5565e80
Compare
🤖 AI text below 🤖
Description
Add an optional private extension to MQT Core's packaged QDMI Driver without extending the standard QDMI Client ABI.
This pull request:
RECORDmetadata without importing provider packages;default_driverAPIs; andDependencies
This PR is stacked directly on #2233. That PR pins QDMI #513, stacked on QDMI #512 and #511.
Validation
d6ce0da02cba1a3b903f0b046ef23af6f00edc6a;The preceding runtime-equivalent head passed Windows x64, Windows ARM, Windows Python, Slurm, C++ coverage, and all Codecov patch gates. Hosted CI is pending for the final lint-only amendment.
AI assistance: OpenAI Codex assisted with implementation, review, testing, and this description.
Checklist
If PR contains AI-assisted content:
🤖 *AI text below* 🤖(titles are exempt).