-
-
Notifications
You must be signed in to change notification settings - Fork 72
✨ Integrate QDMI Devices #1687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MatthiasReumann
wants to merge
37
commits into
main
Choose a base branch
from
feat/arch-option-and-qdmi
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
✨ Integrate QDMI Devices #1687
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
3833e0d
Add transpilation step and TODOs
MatthiasReumann fdb9060
🎨 pre-commit fixes
pre-commit-ci[bot] b0ff8a2
Merge branch 'main' into feat/arch-option-and-qdmi
MatthiasReumann 00db463
Merge branch 'feat/arch-option-and-qdmi' of https://github.com/munich…
MatthiasReumann f9c2c6b
🎨 pre-commit fixes
pre-commit-ci[bot] 287e1d2
Merge branch 'main' into feat/arch-option-and-qdmi
MatthiasReumann 7b885fa
🎨 pre-commit fixes
pre-commit-ci[bot] db347db
Implement initial QDMI integration
MatthiasReumann 436382f
Merge branch 'feat/arch-option-and-qdmi' of https://github.com/munich…
MatthiasReumann 51636d3
🎨 pre-commit fixes
pre-commit-ci[bot] 793f50f
Restructure main
MatthiasReumann 9b65ba7
Merge branch 'feat/arch-option-and-qdmi' of https://github.com/munich…
MatthiasReumann 70a188a
Merge branch 'main' into feat/arch-option-and-qdmi
MatthiasReumann 6d7db6b
Add SuperconductingDevice class
MatthiasReumann 042a093
Integrate into Compiler
MatthiasReumann 8e43cf8
🎨 pre-commit fixes
pre-commit-ci[bot] e8d31b5
Merge branch 'main' into feat/arch-option-and-qdmi
MatthiasReumann d95ae33
Don't link unncessary libraries
MatthiasReumann 672162b
Apply bunny suggestions
MatthiasReumann 3691dcd
Merge branch 'main' into feat/arch-option-and-qdmi
MatthiasReumann 7f1791a
Final touches
MatthiasReumann 569b51f
Merge branch 'main' into feat/arch-option-and-qdmi
MatthiasReumann 5fc2635
Implement JSON config
MatthiasReumann 340a52b
🎨 pre-commit fixes
pre-commit-ci[bot] 65cbaf8
Fix lint
MatthiasReumann 1af70f7
Merge branch 'feat/arch-option-and-qdmi' of https://github.com/munich…
MatthiasReumann efd3817
Merge branch 'main' into feat/arch-option-and-qdmi
MatthiasReumann 9b766a7
Merge branch 'main' into feat/arch-option-and-qdmi
MatthiasReumann 8b62b27
🎨 pre-commit fixes
pre-commit-ci[bot] 879825d
Remove discovery file
MatthiasReumann d6e3ee2
Update CHANGELOG.md
MatthiasReumann 6e89142
Merge branch 'feat/arch-option-and-qdmi' of https://github.com/munich…
MatthiasReumann 18423a5
🎨 pre-commit fixes
pre-commit-ci[bot] b94f9b4
Add missing include
MatthiasReumann 8f7d137
Add 'CONFIGURE_DEPENDS'
MatthiasReumann f7d7c41
Add "is_object" check
MatthiasReumann 0983e04
Merge branch 'feat/arch-option-and-qdmi' of https://github.com/munich…
MatthiasReumann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| /* | ||
| * Copyright (c) 2023 - 2026 Chair for Design Automation, TUM | ||
| * Copyright (c) 2025 - 2026 Munich Quantum Software Company GmbH | ||
| * All rights reserved. | ||
| * | ||
| * SPDX-License-Identifier: MIT | ||
| * | ||
| * Licensed under the MIT License | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "fomac/FoMaC.hpp" | ||
| #include "qdmi/driver/Driver.hpp" | ||
|
|
||
| #include <llvm/Support/raw_ostream.h> | ||
| #include <mlir/Support/LLVM.h> | ||
|
|
||
| #include <memory> | ||
|
|
||
| namespace mlir::qdmi { | ||
| namespace impl { | ||
|
|
||
| struct DeviceConfig { | ||
| /// Library name/path | ||
| std::string libName; | ||
| /// Prefix for function names | ||
| std::string prefix; | ||
| /// Device session configuration | ||
| ::qdmi::DeviceSessionConfig deviceConfig; | ||
| }; | ||
|
|
||
| struct Config { | ||
| /// Read and parse the given QDMI JSON config file. | ||
| /// The function expects the following JSON structure, where some attributes | ||
| /// may be omitted depending on the use-case. | ||
| /// { | ||
| /// "session": { | ||
| /// "token": "...", | ||
| /// "authFile": "...", | ||
| /// "authUrl": "...", | ||
| /// "username": "...", | ||
| /// "password": "...", | ||
| /// "projectId": "...", | ||
| /// "custom1": "...", | ||
| /// "custom2": "...", | ||
| /// "custom3": "...", | ||
| /// "custom4": "...", | ||
| /// "custom5": "..." | ||
| /// }, | ||
| /// "devices": [ | ||
| /// { | ||
| /// "libName": "...", | ||
| /// "prefix": "...", | ||
| /// "deviceConfig": { | ||
| /// "baseUrl": "...", | ||
| /// "token": "...", | ||
| /// "authFile": "...", | ||
| /// "authUrl": "...", | ||
| /// "username": "...", | ||
| /// "password": "...", | ||
| /// "custom1": "...", | ||
| /// "custom2": "...", | ||
| /// "custom3": "...", | ||
| /// "custom4": "...", | ||
| /// "custom5": "..." | ||
| /// } | ||
| /// } | ||
| /// ] | ||
| /// } | ||
| static Config read(StringRef path); | ||
|
|
||
| fomac::SessionConfig session; | ||
| SmallVector<DeviceConfig, 0> devices; | ||
| }; | ||
| } // namespace impl | ||
|
|
||
| /// Return parameterized session. | ||
| /// Applies the provided session config and loads the specified QDMI devices. | ||
| fomac::Session prepareSession(StringRef configPath); | ||
|
|
||
| /// Return unparameterized session. | ||
| /// Applies default session config and does not load any dynamic QDMI devices. | ||
| fomac::Session prepareSession(); | ||
|
|
||
| /// Output a list of all available QDMI devices to @p os. | ||
| void listAvailableDevices(fomac::Session& session, | ||
| llvm::raw_ostream& os = llvm::outs()); | ||
|
|
||
| /// Find a QDMI device with the given name and return its FoMaC class. | ||
| std::shared_ptr<fomac::Device> getDevice(fomac::Session& session, | ||
| StringRef name); | ||
| } // namespace mlir::qdmi | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /* | ||
| * Copyright (c) 2023 - 2026 Chair for Design Automation, TUM | ||
| * Copyright (c) 2025 - 2026 Munich Quantum Software Company GmbH | ||
| * All rights reserved. | ||
| * | ||
| * SPDX-License-Identifier: MIT | ||
| * | ||
| * Licensed under the MIT License | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "fomac/FoMaC.hpp" | ||
| #include "mlir/Support/Graph.h" | ||
|
|
||
| #include <mlir/Support/LLVM.h> | ||
|
|
||
| #include <cstddef> | ||
| #include <memory> | ||
|
|
||
| namespace mlir { | ||
| class SuperconductingDevice { | ||
| public: | ||
| /// Construct a superconducting device from qubits and a coupling map. | ||
| /// A coupling is a directed edge from qubit u → v. Thus, for undirected | ||
| /// architectures, for each (u, v) the coupling also contains (v, u). | ||
| SuperconductingDevice(ArrayRef<size_t> qubits, | ||
| const DenseSet<std::pair<size_t, size_t>>& coupling) | ||
| : coupling_(qubits, coupling), dist_(coupling_.getDistMatrix()), | ||
| device_(nullptr) {} | ||
|
|
||
| /// Construct a superconducting device from a QDMI device. | ||
| /// Assumes that the given QDMI device is a superconducting device that has | ||
| /// a coupling map. | ||
| explicit SuperconductingDevice(std::shared_ptr<fomac::Device> device) | ||
| : coupling_(getCouplingGraph(device)), dist_(coupling_.getDistMatrix()), | ||
| device_(std::move(device)) {} | ||
|
|
||
| /// Return the device's number of qubits. | ||
| [[nodiscard]] size_t nqubits() const; | ||
|
|
||
| /// Return true if two qubits are adjacent. | ||
| [[nodiscard]] bool areAdjacent(size_t u, size_t v) const; | ||
|
|
||
| /// Return the length of the shortest path between two qubits. | ||
| [[nodiscard]] size_t distanceBetween(size_t u, size_t v) const; | ||
|
MatthiasReumann marked this conversation as resolved.
|
||
|
|
||
| /// Return the qubit identifiers. | ||
| [[nodiscard]] SmallVector<size_t> qubits() const; | ||
|
|
||
| /// Return all neighbours of a qubit. | ||
| [[nodiscard]] ArrayRef<size_t> neighboursOf(size_t u) const; | ||
|
|
||
| /// Return the max degree (connectivity) of any qubit of the device. | ||
| [[nodiscard]] size_t maxDegree() const; | ||
|
|
||
| private: | ||
| /// Construct graph object from QDMI device. | ||
| static Graph getCouplingGraph(const std::shared_ptr<fomac::Device>& device); | ||
|
|
||
| Graph coupling_; | ||
| Graph::DistanceMatrix dist_; | ||
| std::shared_ptr<fomac::Device> device_; | ||
| }; | ||
| } // namespace mlir | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.