Skip to content

Commit dfedc6a

Browse files
ystadeCopilotpre-commit-ci[bot]denialhaag
authored
✨ [NA] Add IDS Placement Method (#862)
## Description ### Summary by CodeRabbit #### New Features - Introduced PlacementMethod configuration enum with astar and ids placement algorithm options - Added placement_method parameter to RoutingAwareCompiler for flexible algorithm selection during compilation #### Tests - Extended test coverage with new placement configuration scenarios and comprehensive test cases ### Walkthrough This PR refactors the quantum placement system by replacing AStarPlacer with HeuristicPlacer, introducing a configurable placement method enum (ASTAR and IDS) exposed to Python, modernizing method signatures to use shared_ptr-based nodes, and updating the placer configuration pipeline to accept placement method parameters in both C++ and Python interfaces. ## Checklist: <!--- This checklist serves as a reminder of a couple of things that ensure your pull request will be merged swiftly. --> - [x] The pull request only contains commits that are focused and relevant to this change. - [x] I have added appropriate tests that cover the new/changed functionality. - [x] I have updated the documentation to reflect these changes. - [x] I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals. - [ ] I have added migration instructions to the upgrade guide (if needed). - [x] The changes follow the project's style guidelines and introduce no new warnings. - [x] The changes are fully tested and pass the CI checks. - [x] I have reviewed my own code changes. --------- Signed-off-by: Yannick Stade <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel Haag <[email protected]>
1 parent 6ad4099 commit dfedc6a

File tree

10 files changed

+1082
-451
lines changed

10 files changed

+1082
-451
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ _If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md#unreleased)._
1313

1414
### Added
1515

16+
- ✨ Add iterative diving search as a more efficient placement heuristic method ([#862]) ([**@ystade**])
1617
- ✨ Add relaxed routing method to the zoned neutral atom compiler ([#859]) ([**@ystade**])
1718

1819
### Changed
@@ -173,6 +174,7 @@ _📚 Refer to the [GitHub Release Notes] for previous changelogs._
173174
<!-- PR links -->
174175

175176
[#874]: https://github.com/munich-quantum-toolkit/qmap/pull/874
177+
[#862]: https://github.com/munich-quantum-toolkit/qmap/pull/862
176178
[#859]: https://github.com/munich-quantum-toolkit/qmap/pull/859
177179
[#848]: https://github.com/munich-quantum-toolkit/qmap/pull/848
178180
[#847]: https://github.com/munich-quantum-toolkit/qmap/pull/847

bindings/na/zoned/zoned.cpp

Lines changed: 54 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "na/zoned/Compiler.hpp"
1414
#include "na/zoned/code_generator/CodeGenerator.hpp"
1515
#include "na/zoned/layout_synthesizer/PlaceAndRouteSynthesizer.hpp"
16-
#include "na/zoned/layout_synthesizer/placer/AStarPlacer.hpp"
16+
#include "na/zoned/layout_synthesizer/placer/HeuristicPlacer.hpp"
1717
#include "na/zoned/layout_synthesizer/placer/VertexMatchingPlacer.hpp"
1818
#include "na/zoned/layout_synthesizer/router/IndependentSetRouter.hpp"
1919

@@ -53,6 +53,16 @@ PYBIND11_MODULE(MQT_QMAP_MODULE_NAME, m, py::mod_gil_not_used()) {
5353
return self.exportNAVizMachine();
5454
});
5555

56+
//===--------------------------------------------------------------------===//
57+
// Placement Method Enum
58+
//===--------------------------------------------------------------------===//
59+
py::native_enum<na::zoned::HeuristicPlacer::Config::Method>(
60+
m, "PlacementMethod", "enum.Enum")
61+
.value("astar", na::zoned::HeuristicPlacer::Config::Method::ASTAR)
62+
.value("ids", na::zoned::HeuristicPlacer::Config::Method::IDS)
63+
.export_values()
64+
.finalize();
65+
5666
//===--------------------------------------------------------------------===//
5767
// Routing Method Enum
5868
//===--------------------------------------------------------------------===//
@@ -140,37 +150,44 @@ PYBIND11_MODULE(MQT_QMAP_MODULE_NAME, m, py::mod_gil_not_used()) {
140150
{
141151
const na::zoned::RoutingAwareCompiler::Config defaultConfig;
142152
routingAwareCompiler.def(
143-
py::init([](const na::zoned::Architecture& arch,
144-
const std::string& logLevel, const double maxFillingFactor,
145-
const bool useWindow, const size_t windowMinWidth,
146-
const double windowRatio, const double windowShare,
147-
const float deepeningFactor, const float deepeningValue,
148-
const float lookaheadFactor, const float reuseLevel,
149-
const size_t maxNodes,
150-
const na::zoned::IndependentSetRouter::Config::Method
151-
routingMethod,
152-
const double preferSplit, const bool warnUnsupportedGates)
153-
-> na::zoned::RoutingAwareCompiler {
154-
na::zoned::RoutingAwareCompiler::Config config;
155-
config.logLevel = spdlog::level::from_str(logLevel);
156-
config.schedulerConfig.maxFillingFactor = maxFillingFactor;
157-
config.layoutSynthesizerConfig.placerConfig = {
158-
.useWindow = useWindow,
159-
.windowMinWidth = windowMinWidth,
160-
.windowRatio = windowRatio,
161-
.windowShare = windowShare,
162-
.deepeningFactor = deepeningFactor,
163-
.deepeningValue = deepeningValue,
164-
.lookaheadFactor = lookaheadFactor,
165-
.reuseLevel = reuseLevel,
166-
.maxNodes = maxNodes,
167-
};
168-
config.layoutSynthesizerConfig.routerConfig = {
169-
.method = routingMethod, .preferSplit = preferSplit};
170-
config.codeGeneratorConfig = {.warnUnsupportedGates =
171-
warnUnsupportedGates};
172-
return {arch, config};
173-
}),
153+
py::init(
154+
[](const na::zoned::Architecture& arch, const std::string& logLevel,
155+
const double maxFillingFactor, const bool useWindow,
156+
const size_t windowMinWidth, const double windowRatio,
157+
const double windowShare,
158+
const na::zoned::HeuristicPlacer::Config::Method placementMethod,
159+
const float deepeningFactor, const float deepeningValue,
160+
const float lookaheadFactor, const float reuseLevel,
161+
const size_t maxNodes, const size_t trials,
162+
const size_t queueCapacity,
163+
const na::zoned::IndependentSetRouter::Config::Method
164+
routingMethod,
165+
const double preferSplit, const bool warnUnsupportedGates)
166+
-> na::zoned::RoutingAwareCompiler {
167+
na::zoned::RoutingAwareCompiler::Config config;
168+
config.logLevel = spdlog::level::from_str(logLevel);
169+
config.schedulerConfig.maxFillingFactor = maxFillingFactor;
170+
171+
config.layoutSynthesizerConfig.placerConfig = {
172+
.useWindow = useWindow,
173+
.windowMinWidth = windowMinWidth,
174+
.windowRatio = windowRatio,
175+
.windowShare = windowShare,
176+
.method = placementMethod,
177+
.deepeningFactor = deepeningFactor,
178+
.deepeningValue = deepeningValue,
179+
.lookaheadFactor = lookaheadFactor,
180+
.reuseLevel = reuseLevel,
181+
.maxNodes = maxNodes,
182+
.trials = trials,
183+
.queueCapacity = queueCapacity,
184+
};
185+
config.layoutSynthesizerConfig.routerConfig = {
186+
.method = routingMethod, .preferSplit = preferSplit};
187+
config.codeGeneratorConfig = {.warnUnsupportedGates =
188+
warnUnsupportedGates};
189+
return {arch, config};
190+
}),
174191
py::keep_alive<1, 2>(), "arch"_a,
175192
"log_level"_a = spdlog::level::to_short_c_str(defaultConfig.logLevel),
176193
"max_filling_factor"_a = defaultConfig.schedulerConfig.maxFillingFactor,
@@ -182,6 +199,8 @@ PYBIND11_MODULE(MQT_QMAP_MODULE_NAME, m, py::mod_gil_not_used()) {
182199
defaultConfig.layoutSynthesizerConfig.placerConfig.windowRatio,
183200
"window_share"_a =
184201
defaultConfig.layoutSynthesizerConfig.placerConfig.windowShare,
202+
"placement_method"_a =
203+
defaultConfig.layoutSynthesizerConfig.placerConfig.method,
185204
"deepening_factor"_a =
186205
defaultConfig.layoutSynthesizerConfig.placerConfig.deepeningFactor,
187206
"deepening_value"_a =
@@ -192,6 +211,9 @@ PYBIND11_MODULE(MQT_QMAP_MODULE_NAME, m, py::mod_gil_not_used()) {
192211
defaultConfig.layoutSynthesizerConfig.placerConfig.reuseLevel,
193212
"max_nodes"_a =
194213
defaultConfig.layoutSynthesizerConfig.placerConfig.maxNodes,
214+
"trials"_a = defaultConfig.layoutSynthesizerConfig.placerConfig.trials,
215+
"queue_capacity"_a =
216+
defaultConfig.layoutSynthesizerConfig.placerConfig.queueCapacity,
195217
"routing_method"_a =
196218
defaultConfig.layoutSynthesizerConfig.routerConfig.method,
197219
"prefer_split"_a =

include/na/zoned/Compiler.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "ir/QuantumComputation.hpp"
1616
#include "ir/operations/Operation.hpp"
1717
#include "layout_synthesizer/PlaceAndRouteSynthesizer.hpp"
18-
#include "layout_synthesizer/placer/AStarPlacer.hpp"
18+
#include "layout_synthesizer/placer/HeuristicPlacer.hpp"
1919
#include "layout_synthesizer/placer/VertexMatchingPlacer.hpp"
2020
#include "layout_synthesizer/router/IndependentSetRouter.hpp"
2121
#include "na/NAComputation.hpp"
@@ -269,7 +269,7 @@ class RoutingAgnosticCompiler final
269269
};
270270

271271
class RoutingAwareSynthesizer
272-
: public PlaceAndRouteSynthesizer<RoutingAwareSynthesizer, AStarPlacer,
272+
: public PlaceAndRouteSynthesizer<RoutingAwareSynthesizer, HeuristicPlacer,
273273
IndependentSetRouter> {
274274
public:
275275
RoutingAwareSynthesizer(const Architecture& architecture,

0 commit comments

Comments
 (0)