This repository has been archived by the owner on Dec 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from tyi1025/4-benchmark-suite-setup
4 benchmark suite setup
- Loading branch information
Showing
20 changed files
with
422 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
|
||
#include "Task.hpp" | ||
|
||
#include <nlohmann/json.hpp> | ||
#include <type_traits> | ||
|
||
using json = nlohmann::json; | ||
|
||
template <class T> class Executor { | ||
static_assert(std::is_base_of_v<Task, T>); | ||
|
||
public: | ||
virtual ~Executor() = default; | ||
|
||
virtual json execute(const T& task) = 0; | ||
|
||
[[nodiscard]] virtual std::string getIdentifier() const = 0; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
class Task { | ||
public: | ||
virtual ~Task() = default; | ||
|
||
[[nodiscard]] virtual std::string getIdentifier() const = 0; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
#include "Executor.hpp" | ||
#include "tasks/VerificationTask.hpp" | ||
|
||
class AlternatingVerificationExecutor : public Executor<VerificationTask> { | ||
public: | ||
json execute(const VerificationTask& task) override; | ||
|
||
[[nodiscard]] std::string getIdentifier() const override { | ||
return "alternating_verification"; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
#include "Executor.hpp" | ||
#include "tasks/SimulationTask.hpp" | ||
|
||
class CircuitSimulatorExecutor : public Executor<SimulationTask> { | ||
public: | ||
json execute(const SimulationTask& task) override; | ||
|
||
[[nodiscard]] std::string getIdentifier() const override { | ||
return "circuit_simulator"; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include "Task.hpp" | ||
|
||
#include <memory> | ||
|
||
namespace qc { | ||
class QuantumComputation; | ||
} | ||
|
||
class SimulationTask : public Task { | ||
public: | ||
explicit SimulationTask() = default; | ||
explicit SimulationTask(std::unique_ptr<qc::QuantumComputation> circ); | ||
|
||
[[nodiscard]] std::string getIdentifier() const override; | ||
|
||
[[nodiscard]] const std::unique_ptr<qc::QuantumComputation>& getQc() const { | ||
return qc; | ||
}; | ||
|
||
protected: | ||
std::unique_ptr<qc::QuantumComputation> qc; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
#include "Task.hpp" | ||
|
||
#include <memory> | ||
|
||
namespace qc { | ||
class QuantumComputation; | ||
} | ||
|
||
class VerificationTask : public Task { | ||
public: | ||
explicit VerificationTask() = default; | ||
VerificationTask(std::unique_ptr<qc::QuantumComputation> circ1, | ||
std::unique_ptr<qc::QuantumComputation> circ2); | ||
|
||
[[nodiscard]] std::string getIdentifier() const override; | ||
|
||
[[nodiscard]] const std::unique_ptr<qc::QuantumComputation>& getQc1() const { | ||
return qc1; | ||
}; | ||
|
||
[[nodiscard]] const std::unique_ptr<qc::QuantumComputation>& getQc2() const { | ||
return qc2; | ||
}; | ||
|
||
protected: | ||
std::unique_ptr<qc::QuantumComputation> qc1; | ||
std::unique_ptr<qc::QuantumComputation> qc2; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "executors/AlternatingVerificationExecutor.hpp" | ||
|
||
#include "EquivalenceCheckingManager.hpp" | ||
|
||
json AlternatingVerificationExecutor::execute(const VerificationTask& task) { | ||
json result; | ||
auto const constructionStart = std::chrono::steady_clock::now(); | ||
|
||
auto equivalenceCheckingManager = | ||
std::make_unique<ec::EquivalenceCheckingManager>(*task.getQc1(), | ||
*task.getQc2()); | ||
equivalenceCheckingManager->disableAllCheckers(); | ||
equivalenceCheckingManager->setAlternatingChecker(true); | ||
|
||
auto const executionStart = std::chrono::steady_clock::now(); | ||
|
||
equivalenceCheckingManager->run(); | ||
result["check_results"] = equivalenceCheckingManager->getResults().json(); | ||
// Add memory usage | ||
auto const executionStop = std::chrono::steady_clock::now(); | ||
auto const constructionTime = | ||
std::chrono::duration_cast<std::chrono::microseconds>(executionStart - | ||
constructionStart); | ||
auto const execTime = std::chrono::duration_cast<std::chrono::microseconds>( | ||
executionStop - executionStart); | ||
result["construction_time"] = constructionTime.count(); | ||
result["execution_time"] = execTime.count(); | ||
|
||
result["executor"] = getIdentifier(); | ||
result["task"] = task.getIdentifier(); | ||
|
||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "executors/CircuitSimulatorExecutor.hpp" | ||
|
||
#include "CircuitSimulator.hpp" | ||
|
||
json CircuitSimulatorExecutor::execute(const SimulationTask& task) { | ||
json result; | ||
auto const constructionStart = std::chrono::steady_clock::now(); | ||
|
||
auto qc = std::make_unique<qc::QuantumComputation>(task.getQc()->clone()); | ||
auto circuitSimulator = std::make_unique<CircuitSimulator<>>(std::move(qc)); | ||
|
||
auto const executionStart = std::chrono::steady_clock::now(); | ||
|
||
result["measurement_results"] = circuitSimulator->simulate(1024U); | ||
// Add memory usage | ||
|
||
auto const executionStop = std::chrono::steady_clock::now(); | ||
auto const constructionTime = | ||
std::chrono::duration_cast<std::chrono::microseconds>(executionStart - | ||
constructionStart); | ||
auto const execTime = std::chrono::duration_cast<std::chrono::microseconds>( | ||
executionStop - executionStart); | ||
result["construction_time"] = constructionTime.count(); | ||
result["execution_time"] = execTime.count(); | ||
|
||
result["executor"] = getIdentifier(); | ||
result["task"] = task.getIdentifier(); | ||
|
||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "tasks/SimulationTask.hpp" | ||
|
||
#include "QuantumComputation.hpp" | ||
|
||
SimulationTask::SimulationTask(std::unique_ptr<qc::QuantumComputation> circ) | ||
: qc(std::move(circ)) {} | ||
|
||
std::string SimulationTask::getIdentifier() const { | ||
return "sim_" + qc->getName(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "tasks/VerificationTask.hpp" | ||
|
||
#include "QuantumComputation.hpp" | ||
|
||
VerificationTask::VerificationTask( | ||
std::unique_ptr<qc::QuantumComputation> circ1, | ||
std::unique_ptr<qc::QuantumComputation> circ2) | ||
: qc1(std::move(circ1)), qc2(std::move(circ2)) {} | ||
|
||
std::string VerificationTask::getIdentifier() const { | ||
return "ver_" + qc1->getName() + "_" + qc2->getName(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[ | ||
{ | ||
"description": "two_qubit_circuit_with_two_x_gates", | ||
"circuit": "OPENQASM 2.0;include \"qelib1.inc\";qreg q[2];x q[0];x q[1];\n" | ||
}, | ||
{ | ||
"description": "two_qubit_circuit_with_h_z_controlled_x_swap", | ||
"circuit": "OPENQASM 2.0;include \"qelib1.inc\";qreg q[2];cx q[0], q[1];h q[0];z q[0];h q[0];swap q[0], q[1];\n" | ||
} | ||
] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.