Skip to content

Commit ba4d08f

Browse files
ystadeburgholzerpre-commit-ci[bot]
authored
Integrate Neutral Atom State Preparation (#500)
## Description It adds a new functionality to generate minimal schedules for preparing logical arrays on the neutral atom architecture. ## Checklist: - [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: burgholzer <[email protected]> Co-authored-by: burgholzer <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 1da2736 commit ba4d08f

28 files changed

+2334
-151
lines changed

cmake/ExternalDependencies.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,21 @@ if(BUILD_MQT_QMAP_BINDINGS)
104104
endif()
105105
endif()
106106

107+
# Add YAML-CPP as a dependency.
108+
set(YAML_VERSION
109+
0.8.0
110+
CACHE STRING "YAML-CPP version")
111+
set(YAML_URL https://github.com/jbeder/yaml-cpp/archive/refs/tags/${YAML_VERSION}.tar.gz)
112+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
113+
FetchContent_Declare(yaml-cpp URL ${YAML_URL} FIND_PACKAGE_ARGS ${YAML_VERSION})
114+
list(APPEND FETCH_PACKAGES yaml-cpp)
115+
else()
116+
find_package(yaml-cpp ${YAML_VERSION} QUIET)
117+
if(NOT yaml-cpp_FOUND)
118+
FetchContent_Declare(yaml-cpp URL ${YAML_URL})
119+
list(APPEND FETCH_PACKAGES yaml-cpp)
120+
endif()
121+
endif()
122+
107123
# Make all declared dependencies available.
108124
FetchContent_MakeAvailable(${FETCH_PACKAGES})

include/na/Architecture.hpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
//
2-
// This file is part of the MQT QMAP library released under the MIT license.
3-
// See README.md or go to https://github.com/cda-tum/mqt-qmap for more
4-
// information.
5-
//
6-
71
#pragma once
82

9-
#include "Configuration.hpp"
103
#include "Definitions.hpp"
4+
#include "na/Configuration.hpp"
115
#include "na/NADefinitions.hpp"
126

137
#include <algorithm>
@@ -231,6 +225,7 @@ class Architecture {
231225
[[nodiscard]] auto isAllowedGlobally(const FullOpType& t,
232226
const Zone& zone) const -> bool;
233227
[[nodiscard]] auto getNrowsInZone(const Zone& z) const -> Index;
228+
[[nodiscard]] auto getNColsInZone(const Zone& z) const -> Index;
234229
[[nodiscard]] auto getSitesInRow(const Zone& z, const Index& row) const
235230
-> std::vector<Index>;
236231
[[nodiscard]] auto getNearestXLeft(const Number& x, const Zone& z,

include/na/Configuration.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
//
2-
// This file is part of the MQT QMAP library released under the MIT license.
3-
// See README.md or go to https://github.com/cda-tum/mqt-qmap for more
4-
// information.
5-
//
6-
71
#pragma once
82

93
#include <algorithm>
@@ -14,6 +8,7 @@
148
#include <stdexcept>
159
#include <string>
1610
#include <unordered_map>
11+
1712
namespace na {
1813

1914
enum class NAMappingMethod : std::uint8_t {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
#pragma once
88

9-
#include "Architecture.hpp"
10-
#include "Configuration.hpp"
119
#include "Definitions.hpp"
1210
#include "ir/QuantumComputation.hpp"
1311
#include "ir/operations/Operation.hpp"
12+
#include "na/Architecture.hpp"
13+
#include "na/Configuration.hpp"
1414
#include "na/NAComputation.hpp"
1515
#include "na/NADefinitions.hpp"
1616

include/na/nasp/CodeGenerator.hpp

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#pragma once
2+
3+
#include "Solver.hpp"
4+
#include "ir/QuantumComputation.hpp"
5+
#include "na/NAComputation.hpp"
6+
#include "na/NADefinitions.hpp"
7+
8+
#include <cstdint>
9+
10+
namespace na {
11+
using namespace qc;
12+
13+
class CodeGenerator {
14+
private:
15+
/**
16+
* @brief Calculate the coordinates of a point in the 2D grid from its
17+
* discrete coordinates.
18+
*
19+
* @details The parameters specify the measures that were used for the
20+
* abstraction of the 2D grid. In the abstraction the 2D plane is divided into
21+
* interaction sites. Each site is identified by a discrete coordinate. The
22+
* exact (discrete) position of an atom in a site is given by the discrete
23+
* offset from the sites' origin.
24+
*
25+
* @param q A qubit that contains the discrete coordinates of the interaction
26+
* site together with the discrete offset.
27+
* @param maxHOffset The maximal possible horizontal offset of an atom in a
28+
* site. This value determines the width of a site in x-direction.
29+
* @param maxVOffset The maximal possible vertical offset of an atom in a
30+
* site. This value determines the height of a site in y-direction.
31+
* @param minEntanglingY The minimal y-coordinate of the entangling zone. All
32+
* discrete y-coordinates smaller than this value are considered to be in the
33+
* top storage zone. If this value is 0, there is no top storage zone.
34+
* @param maxEntanglingY The maximal y-coordinate of the entangling zone. All
35+
* discrete y-coordinates greater than this value are considered to be in the
36+
* bottom storage zone.
37+
* @param minAtomDist The minimal distance between two atoms in the 2D grid,
38+
* i.e., between the discrete sites in one interaction site.
39+
* @param noInteractionRadius The radius of atoms in order to avoid
40+
* interactions. This is used as the minimal distance between two atoms in two
41+
* different interaction sites.
42+
* @param zoneDist The distance between the top storage zone and the
43+
* entangling zone and between the entangling zone and the bottom storage
44+
* zone. This distance already includes the minimal distance between two atoms
45+
* and the no interaction radius, i.e., it is the minimal distance between two
46+
* atoms in different zones.
47+
* @return The coordinates of the point in the 2D grid.
48+
*/
49+
static auto coordFromDiscrete(NASolver::Result::Qubit q, int64_t maxHOffset,
50+
int64_t maxVOffset, int64_t minEntanglingY,
51+
int64_t maxEntanglingY, int64_t minAtomDist,
52+
int64_t noInteractionRadius, int64_t zoneDist)
53+
-> Point;
54+
55+
public:
56+
/**
57+
* @brief Generate a NAComputation from a QuantumComputation and a NASolver
58+
* result.
59+
*
60+
* @details The function generates a NAComputation from a QuantumComputation
61+
* and a NASolver result. The solver works with an abstraction of the 2D grid.
62+
* In the abstraction the 2D plane is divided into
63+
* interaction sites. Each site is identified by a discrete coordinate. The
64+
* exact (discrete) position of an atom in a site is given by the discrete
65+
* offset from the sites' origin. This function calculates the exact position
66+
* of each qubit in the 2D grid from the discrete coordinates and offsets. For
67+
* the calculation, the measures used for the abstraction are required.
68+
*
69+
* @warning This function expects a QuantumComputation that was used as input
70+
* for the NASolver. Additionally, this function assumes the quantum circuit
71+
* represented by the QuantumComputation to be of the following form:
72+
* First, all qubits are initialized in the |+> state by applying a Hadamard
73+
* gate to each qubit. Then, a set of entangling gates (CZ) is applied to the
74+
* qubits. Finally, hadamard gates are applied to some qubits. Unfortunately,
75+
* the function cannot deal with arbitrary quantum circuits as the NASolver
76+
* cannot do either.
77+
*
78+
* @param input The QuantumComputation that was used as input for the
79+
* NASolver.
80+
* @param result The result of the NASolver.
81+
* @param maxHOffset The maximal possible horizontal offset of an atom in a
82+
* site. This value determines the width of a site in x-direction.
83+
* @param maxVOffset The maximal possible vertical offset of an atom in a
84+
* site. This value determines the height of a site in y-direction.
85+
* @param minEntanglingY The minimal y-coordinate of the entangling zone. All
86+
* discrete y-coordinates smaller than this value are considered to be in the
87+
* top storage zone. If this value is 0, there is no top storage zone.
88+
* @param maxEntanglingY The maximal y-coordinate of the entangling zone. All
89+
* discrete y-coordinates greater than this value are considered to be in the
90+
* bottom storage zone.
91+
* @param minAtomDist The minimal distance between two atoms in the 2D grid,
92+
* i.e., between the discrete sites in one interaction site.
93+
* @param noInteractionRadius The radius of atoms in order to avoid
94+
* interactions. This is used as the minimal distance between two atoms in two
95+
* different interaction sites.
96+
* @param zoneDist The distance between the top storage zone and the
97+
* entangling zone and between the entangling zone and the bottom storage
98+
* zone. This distance already includes the minimal distance between two atoms
99+
* and the no interaction radius, i.e., it is the minimal distance between two
100+
* atoms in different zones.
101+
* @return The generated NAComputation.
102+
*/
103+
[[nodiscard]] static auto
104+
generate(const QuantumComputation& input, const NASolver::Result& result,
105+
uint16_t maxHOffset, uint16_t maxVOffset, uint16_t minEntanglingY,
106+
uint16_t maxEntanglingY, uint16_t minAtomDist = 1,
107+
uint16_t noInteractionRadius = 10, uint16_t zoneDist = 24)
108+
-> NAComputation;
109+
};
110+
} // namespace na

0 commit comments

Comments
 (0)