-
-
Notifications
You must be signed in to change notification settings - Fork 31
🎨 [NA] Add Dummy Decomposer to Zoned NA Compiler #902
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||||||||||||||||
| /* | ||||||||||||||||||
| * 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 "na/zoned/Types.hpp" | ||||||||||||||||||
|
|
||||||||||||||||||
| #include <vector> | ||||||||||||||||||
|
|
||||||||||||||||||
| namespace na::zoned { | ||||||||||||||||||
| /** | ||||||||||||||||||
| * The Abstract Base Class for the Decomposer of the MQT's Zoned Neutral Atom | ||||||||||||||||||
| * Compiler. | ||||||||||||||||||
| */ | ||||||||||||||||||
|
Comment on lines
+18
to
+21
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor typo in documentation comment. There's an extra space in "The Abstract Base Class" (double space after "The"). Proposed fix-/**
- * The Abstract Base Class for the Decomposer of the MQT's Zoned Neutral Atom
- * Compiler.
- */
+/**
+ * The Abstract Base Class for the Decomposer of the MQT's Zoned Neutral Atom
+ * Compiler.
+ */📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| class DecomposerBase { | ||||||||||||||||||
| public: | ||||||||||||||||||
| virtual ~DecomposerBase() = default; | ||||||||||||||||||
| /** | ||||||||||||||||||
| * This function defines the interface of the decomposer. | ||||||||||||||||||
| * @param singleQubitGateLayers are the layers of single-qubit gates that are | ||||||||||||||||||
| * meant to be first decomposed into the native gate set. | ||||||||||||||||||
| * @return the new single-qubit gate layers | ||||||||||||||||||
| */ | ||||||||||||||||||
| [[nodiscard]] virtual auto decompose( | ||||||||||||||||||
| const std::vector<SingleQubitGateRefLayer>& singleQubitGateLayers) const | ||||||||||||||||||
| -> std::vector<SingleQubitGateLayer> = 0; | ||||||||||||||||||
| }; | ||||||||||||||||||
| } // namespace na::zoned | ||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,54 @@ | ||||||||||
| /* | ||||||||||
| * 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 "na/zoned/Architecture.hpp" | ||||||||||
| #include "na/zoned/Types.hpp" | ||||||||||
| #include "na/zoned/decomposer/DecomposerBase.hpp" | ||||||||||
|
|
||||||||||
| #include <vector> | ||||||||||
|
|
||||||||||
| namespace na::zoned { | ||||||||||
| /** | ||||||||||
| * The class NoOpDecomposer implements a dummy no-op decomposer that just copies | ||||||||||
| * every operation. | ||||||||||
| */ | ||||||||||
| class NoOpDecomposer : public DecomposerBase { | ||||||||||
|
|
||||||||||
| public: | ||||||||||
| /// The configuration of the NoOpDecomposer | ||||||||||
| struct Config { | ||||||||||
| template < | ||||||||||
| typename BasicJsonType, | ||||||||||
| nlohmann::detail::enable_if_t< | ||||||||||
| nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> | ||||||||||
| friend void to_json(BasicJsonType& /* unused */, | ||||||||||
| const Config& /* unused */) {} | ||||||||||
|
|
||||||||||
| template < | ||||||||||
| typename BasicJsonType, | ||||||||||
| nlohmann::detail::enable_if_t< | ||||||||||
| nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> | ||||||||||
| friend void from_json(const BasicJsonType& /* unused */, | ||||||||||
| Config& /* unused */) {}; | ||||||||||
|
Comment on lines
+40
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Minor: Remove trailing semicolon after function body. The semicolon after the closing brace of Suggested fix friend void from_json(const BasicJsonType& /* unused */,
- Config& /* unused */) {};
+ Config& /* unused */) {}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| }; | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Create a new NoOpDecomposer. | ||||||||||
| */ | ||||||||||
| NoOpDecomposer(const Architecture& /* unused */, const Config& /* unused */) { | ||||||||||
| } | ||||||||||
|
|
||||||||||
| [[nodiscard]] auto decompose( | ||||||||||
| const std::vector<SingleQubitGateRefLayer>& singleQubitGateLayers) const | ||||||||||
| -> std::vector<SingleQubitGateLayer> override; | ||||||||||
| }; | ||||||||||
| } // namespace na::zoned | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /* | ||
| * 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 | ||
| */ | ||
|
|
||
| #include "na/zoned/decomposer/NoOpDecomposer.hpp" | ||
|
|
||
| #include "ir/QuantumComputation.hpp" | ||
| #include "na/zoned/Architecture.hpp" | ||
|
|
||
| #include <utility> | ||
| #include <vector> | ||
|
|
||
| namespace na::zoned { | ||
| auto NoOpDecomposer::decompose( | ||
| const std::vector<SingleQubitGateRefLayer>& singleQubitGateLayers) const | ||
| -> std::vector<SingleQubitGateLayer> { | ||
| std::vector<SingleQubitGateLayer> result; | ||
| result.reserve(singleQubitGateLayers.size()); | ||
| for (const auto& layer : singleQubitGateLayers) { | ||
| SingleQubitGateLayer newLayer; | ||
| newLayer.reserve(layer.size()); | ||
| for (const auto& opRef : layer) { | ||
| newLayer.emplace_back(opRef.get().clone()); | ||
| } | ||
| result.emplace_back(std::move(newLayer)); | ||
| } | ||
| return result; | ||
| } | ||
| } // namespace na::zoned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Clarify the distinction between the two layer types in documentation.
Lines 22 and 25 have identical comments, but
SingleQubitGateRefLayer(non-owning references) andSingleQubitGateLayer(owning unique pointers) serve different purposes in the decomposer pipeline. Consider distinguishing them in the documentation.📝 Suggested documentation improvement
📝 Committable suggestion
🤖 Prompt for AI Agents