Skip to content

Commit e5c96f2

Browse files
authored
⚡ Improve handling of dedicated subgraphs in exact mapper (#308)
## Description This tiny PR improves the performance when a dedicated subgraph of an architecture is specified. This was only incompletely handled, which led to very inefficient computations (e.g., the SWAP limit was still computed from the whole architecture). This PR just reduces the architecture to the subgraph as part of the mapping. ## 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 related to it. - [x] I have added appropriate tests and documentation. - [x] I have made sure that all CI jobs on GitHub pass. - [x] The pull request introduces no new warnings and follows the project's style guidelines. Signed-off-by: Lukas Burgholzer <lukas.burgholzer@jku.at>
1 parent a2ff1a8 commit e5c96f2

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/exact/ExactMapper.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ void ExactMapper::map(const Configuration& settings) {
5656
return;
5757
}
5858

59-
// 2) For all possibilities k (=m over n) to pick n qubits from m physical
60-
// qubits
61-
std::vector<std::uint16_t> qubitRange{};
59+
// 2a) If only a subgraph should be considered, reduce the architecture.
6260
if (!config.subgraph.empty()) {
6361
const auto subgraphQubits = config.subgraph.size();
6462
if (subgraphQubits < qc.getNqubits()) {
@@ -76,20 +74,23 @@ void ExactMapper::map(const Configuration& settings) {
7674
std::cerr << "The subgraph is not connected." << std::endl;
7775
return;
7876
}
79-
qubitRange = Architecture::getQubitList(reducedCouplingMap);
80-
} else {
81-
qubitRange.clear();
82-
auto qubitSet = architecture.getQubitSet();
83-
qubitRange.reserve(qubitSet.size());
84-
std::copy(qubitSet.begin(), qubitSet.end(), std::back_inserter(qubitRange));
77+
78+
architecture.setCouplingMap(reducedCouplingMap);
8579
}
80+
81+
// 2b) If configured to use subsets, collect all k (=m over n) possibilities
82+
// to pick n qubits from m device qubits. Otherwise, consider all qubits.
83+
std::vector<std::uint16_t> qubitRange =
84+
Architecture::getQubitList(architecture.getCouplingMap());
85+
8686
std::vector<QubitChoice> allPossibleQubitChoices{};
8787
if (config.useSubsets) {
8888
allPossibleQubitChoices = architecture.getAllConnectedSubsets(
8989
static_cast<std::uint16_t>(qc.getNqubits()));
9090
} else {
9191
allPossibleQubitChoices.emplace_back(qubitRange.begin(), qubitRange.end());
9292
}
93+
9394
// 3) determine exact mapping for this qubit choice
9495
std::vector<Swaps> swaps(reducedLayerIndices.size(), Swaps{});
9596
mappingSwaps.reserve(reducedLayerIndices.size());

0 commit comments

Comments
 (0)