Skip to content
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

Integrate Neutral Atom State Preparation #500

Merged
merged 75 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
1ee2b5e
🚸 Add method getNcolsInZone()
ystade Jul 25, 2024
0ef4b73
Merge branch 'main' into wip-smt-na
ystade Aug 5, 2024
1a150df
⬆️ Set mqt-core dependency
ystade Aug 5, 2024
39e85c3
🎨 Move NALAC into subdir and add NASP (NA-State-Prep)
ystade Aug 5, 2024
485b651
🐛 Fix incosistency
ystade Aug 5, 2024
00d24e8
🩹 do not recurse on sources and headers in `mqt-qmap-na` target
burgholzer Aug 5, 2024
1684717
🚸 disambiguate variable names for headers and sources of various targets
burgholzer Aug 5, 2024
a5d8fed
➖ do not explicitly link against `nlohmann_json` which is linked publ…
burgholzer Aug 5, 2024
78b7347
♻️ do not use headers from `sys/`
burgholzer Aug 5, 2024
cbd0e51
🔥 remove unrelated header include
burgholzer Aug 5, 2024
36357e2
🐛 Remove RECURSE from GLOB_RECURSE
ystade Aug 5, 2024
452b933
🎨 Remove RECURSE from remaining glob patterns
ystade Aug 5, 2024
475b566
🎨 Clean-up new test
ystade Aug 5, 2024
127ae92
🎨 Setting types to std::xxx types
ystade Aug 5, 2024
bc1ee2d
🎨 pre-commit fixes
pre-commit-ci[bot] Aug 5, 2024
ceb3577
✏️ Fix typos in comments
ystade Aug 5, 2024
0a9bd01
🐛 Include missing header
ystade Aug 6, 2024
e2957f4
🎨 pre-commit fixes
pre-commit-ci[bot] Aug 6, 2024
a068799
💚 Add missing header
ystade Aug 6, 2024
b2d8d3a
🎨 pre-commit fixes
pre-commit-ci[bot] Aug 6, 2024
a56d5e9
✅ Add test for solver
ystade Aug 6, 2024
0db4f60
✅ Add test for optimizer that times out
ystade Aug 6, 2024
0dd0e7e
🎨 pre-commit fixes
pre-commit-ci[bot] Aug 6, 2024
2ef4a24
✅ Add test for SolverFactory
ystade Aug 6, 2024
f91026f
🔥 Remove Optimizer from branch
ystade Aug 6, 2024
7a29174
🎨 pre-commit fixes
pre-commit-ci[bot] Aug 6, 2024
fb85907
✅ Add another test for solver
ystade Aug 6, 2024
7e80705
⬆️ Update MQT core
ystade Aug 6, 2024
fdd219f
🐛 Fix bug in test
ystade Aug 6, 2024
4a585b5
✅ Add test for SolverFactory
ystade Aug 6, 2024
c78843e
✅ Add test for CodeGenerator
ystade Aug 6, 2024
af770bb
🎨 pre-commit fixes
pre-commit-ci[bot] Aug 6, 2024
d6c56e0
Merge branch 'main' into wip-smt-na
ystade Aug 6, 2024
f98c677
🐛 Call new function in MQT core
ystade Aug 6, 2024
ed44e21
⬆️ Update MQT core
ystade Aug 6, 2024
0cb6d2a
✅ Add test for YAML in- and output
ystade Aug 6, 2024
4b23e51
💚 Add missing headers
ystade Aug 6, 2024
a7273e4
💚 Fix type warnings
ystade Aug 6, 2024
a2db2a9
💚 Fix linter warnings
ystade Aug 6, 2024
595159f
🎨 pre-commit fixes
pre-commit-ci[bot] Aug 6, 2024
a8002ae
🐛 Add missing header
ystade Aug 6, 2024
36fa8e6
🎨 pre-commit fixes
pre-commit-ci[bot] Aug 6, 2024
7a5f821
🐛 Fix bug in test
ystade Aug 6, 2024
1f00a0b
🎨 pre-commit fixes
pre-commit-ci[bot] Aug 6, 2024
0479e8a
💚 Fix linter warnings regarding header
ystade Aug 6, 2024
a398484
💚 Suppress header warning
ystade Aug 6, 2024
3d3ce80
💚 Fix linter warnings
ystade Aug 6, 2024
5757022
⬆️ Update MQT Core
ystade Aug 9, 2024
e4af7af
Merge remote-tracking branch 'origin/main' into wip-smt-na
ystade Aug 9, 2024
b24d188
Merge remote-tracking branch 'origin/main' into wip-smt-na
ystade Sep 17, 2024
ccfd6d0
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 17, 2024
1858450
🐛 Fix bugs after merge, esp. missing headers
ystade Sep 18, 2024
c3253bc
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 18, 2024
16b866c
🐛 Adopt header paths
ystade Sep 18, 2024
6251eb8
🐛 Remove superfluous headers
ystade Sep 19, 2024
42c9a53
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 19, 2024
5312aa8
Merge remote-tracking branch 'origin/main' into wip-smt-na
ystade Nov 13, 2024
379c5ba
🎨 pre-commit fixes
pre-commit-ci[bot] Nov 13, 2024
8f5a3d6
💡 Add docstrings
ystade Nov 14, 2024
90c31f0
🚧 WIP add docs and replace classes with structs
ystade Nov 14, 2024
b067c29
🚧 Refactoring in progress (Segfault)
ystade Nov 14, 2024
28bac5a
🩹 fix context handling
burgholzer Nov 14, 2024
388e9c5
🎨 Outsource test circuits
ystade Nov 15, 2024
6f39610
🎨 Prettify size type
ystade Nov 15, 2024
a007e9a
🎨 Improve int types
ystade Nov 15, 2024
8095595
🎨 Merge to solve function and add docstrings
ystade Nov 15, 2024
3740c7e
🐛 Fix bugs related to signature change and add clarification comment
ystade Nov 15, 2024
0ea231a
📝 Add calrifying comment
ystade Nov 15, 2024
7b034ca
🐛 Remove unnecessary header
ystade Nov 15, 2024
1cdad04
🩹 Add forgotten header
ystade Nov 15, 2024
d00fbad
💚 Fix header and types
ystade Nov 15, 2024
df85316
💚 Address clang tidy warnings
ystade Nov 15, 2024
f3a6807
💚 Add missing header
ystade Nov 15, 2024
ec387b1
Merge branch 'main' into wip-smt-na
ystade Nov 16, 2024
f264546
Merge branch 'main' into wip-smt-na
burgholzer Nov 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion cmake/ExternalDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ endif()
# cmake-format: off
set(MQT_CORE_VERSION 2.5.2
CACHE STRING "MQT Core version")
set(MQT_CORE_REV "7a9a20269462360d2c2a951647eb6fbf4e3094e2"
set(MQT_CORE_REV "dcd8ac50b00d9ffef9de37d22775b12548a01871"
CACHE STRING "MQT Core identifier (tag, branch or commit hash)")
set(MQT_CORE_REPO_OWNER "cda-tum"
CACHE STRING "MQT Core repository owner (change when using a fork)")
Expand Down Expand Up @@ -104,5 +104,21 @@ if(BUILD_MQT_QMAP_BINDINGS)
endif()
endif()

# Add YAML-CPP as a dependency.
set(YAML_VERSION
0.8.0
CACHE STRING "YAML-CPP version")
set(YAML_URL https://github.com/jbeder/yaml-cpp/archive/refs/tags/${YAML_VERSION}.tar.gz)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
FetchContent_Declare(yaml-cpp URL ${YAML_URL} FIND_PACKAGE_ARGS ${YAML_VERSION})
list(APPEND FETCH_PACKAGES yaml-cpp)
else()
find_package(yaml-cpp ${YAML_VERSION} QUIET)
if(NOT yaml-cpp_FOUND)
FetchContent_Declare(yaml-cpp URL ${YAML_URL})
list(APPEND FETCH_PACKAGES yaml-cpp)
endif()
endif()

# Make all declared dependencies available.
FetchContent_MakeAvailable(${FETCH_PACKAGES})
1 change: 1 addition & 0 deletions include/na/Architecture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ class Architecture {
[[nodiscard]] auto isAllowedGlobally(const FullOpType& t,
const Zone& zone) const -> bool;
[[nodiscard]] auto getNrowsInZone(const Zone& z) const -> Index;
[[nodiscard]] auto getNColsInZone(const Zone& z) const -> Index;
[[nodiscard]] auto
getSitesInRow(const Zone& z, const Index& row) const -> std::vector<Index>;
[[nodiscard]] auto getNearestXLeft(const Number& x, const Zone& z,
Expand Down
2 changes: 1 addition & 1 deletion include/na/NAMapper.hpp → include/na/nalac/NAMapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#pragma once

#include "../Configuration.hpp"
#include "Architecture.hpp"
#include "Configuration.hpp"
#include "Definitions.hpp"
#include "QuantumComputation.hpp"
#include "na/NAComputation.hpp"
Expand Down
29 changes: 29 additions & 0 deletions include/na/nasp/CodeGenerator.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include "QuantumComputation.hpp"
#include "Solver.hpp"
#include "na/NAComputation.hpp"
#include "na/NADefinitions.hpp"

#include <cstddef>

Check warning on line 8 in include/na/nasp/CodeGenerator.hpp

View workflow job for this annotation

GitHub Actions / 🇨‌ Lint / 🚨 Lint

include/na/nasp/CodeGenerator.hpp:8:1 [misc-include-cleaner]

included header cstddef is not used directly
#include <cstdint>

namespace na {
using namespace qc;

class CodeGenerator {
private:
static auto coordFromDiscrete(std::int32_t x, std::int32_t y, std::int32_t h,
std::int32_t v, std::int32_t maxHOffset,
std::int32_t maxVOffset,
std::int32_t minEntanglingY,
std::int32_t maxEntanglingY) -> Point;

public:
[[nodiscard]] static auto
generate(const QuantumComputation& input, const NASolver::Result& result,
std::uint16_t maxHOffset, std::uint16_t maxVOffset,
std::uint16_t minEntanglingY,
std::uint16_t maxEntanglingY) -> NAComputation;
};
} // namespace na
90 changes: 90 additions & 0 deletions include/na/nasp/Optimizer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#pragma once

#include "Solver.hpp"

#include <chrono>
#include <cstddef>
#include <functional>
#include <optional>
#include <stdexcept>
#include <unordered_map>

namespace na {

class Optimizer {
public:
using ObjectiveFunction = std::function<NASolver::Result(std::size_t)>;

private:
struct OptimizerProcess {
std::size_t arg = 0;
int readPipeFd = 0;
};

std::chrono::minutes timeout = std::chrono::minutes::zero();
std::size_t maxNSubProcs = 1;
std::size_t initialValue = 0;
std::size_t maxValue = 0;
ObjectiveFunction objective = nullptr;
std::optional<NASolver::Result> extremum = std::nullopt;
bool quiet = true;

// auxiliary variables for minimize
std::optional<std::uint16_t> maxUnsat = std::nullopt;

Check warning on line 33 in include/na/nasp/Optimizer.hpp

View workflow job for this annotation

GitHub Actions / 🇨‌ Lint / 🚨 Lint

include/na/nasp/Optimizer.hpp:33:22 [misc-include-cleaner]

no header providing "std::uint16_t" is directly included
std::optional<std::uint16_t> minSat = std::nullopt;
std::unordered_map<pid_t, OptimizerProcess> processData;

Check warning on line 35 in include/na/nasp/Optimizer.hpp

View workflow job for this annotation

GitHub Actions / 🇨‌ Lint / 🚨 Lint

include/na/nasp/Optimizer.hpp:35:22 [misc-include-cleaner]

no header providing "pid_t" is directly included

[[nodiscard]] auto getNSubProcsRunning() const -> std::size_t {
return processData.size();
}

[[nodiscard]] auto isSubProcRunning() const -> bool {
return !processData.empty();
}

auto forkChildProcess(std::uint16_t arg,
std::chrono::seconds childTimeout) -> void;

auto waitForChildProcess() -> void;

auto killAllChildProcesses() -> void;

public:
[[nodiscard]] auto getExtremum() const -> NASolver::Result {
if (!extremum.has_value()) {
throw std::runtime_error("No extremum found.");
}
return extremum.value();
}

[[nodiscard]] auto getExtremumOpt() const -> std::optional<NASolver::Result> {
return extremum;
}

auto setTimeout(const std::chrono::minutes newTimeout) -> void {
timeout = newTimeout;
}

auto setMaxNSubProcs(const std::uint16_t newMaxNSubProcs) -> void {
maxNSubProcs = newMaxNSubProcs;
}

auto setInitialValue(const std::uint16_t newInitialValue) -> void {
initialValue = newInitialValue;
}

auto setMaxValue(const std::uint16_t newMaxValue) -> void {
maxValue = newMaxValue;
}

auto setQuiet(const bool newQuiet) -> void { quiet = newQuiet; }

auto setObjectiveFunction(
const std::function<NASolver::Result(std::uint16_t)>& newObjective)
-> void {
objective = newObjective;
}

auto minimize() -> void;
};
} // namespace na
Loading
Loading