-
Notifications
You must be signed in to change notification settings - Fork 0
Gather DDSIM benchmarks #12
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## main #12 +/- ##
========================================
Coverage 100.0% 100.0%
========================================
Files 12 28 +16
Lines 106 607 +501
Branches 0 4 +4
========================================
+ Hits 106 607 +501
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just did a quick review of the changes here. There are still a couple aspects that definitely need improvement or are missing at the moment. I hope the comments help to get closer towards the goal.
I would assume some of the comments here also directly apply to the other PR. So please also consider them there as applicable.
CACHE BOOL "" FORCE) | ||
|
||
# store path to googletest in variable | ||
set(GTEST_PATH "extern/ddsim/extern/qfr/extern/dd_package/extern/googletest") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that the googletest path is subject to change once you rebase the QFR (now MQT Core) PR and the DSSIM/QCEC PRs. Then this becomes: extern/ddsim/extern/mqt-core/extern/googletest
option(BUILD_DD_EVAL_BENCHMARKS "Also build benchmarks for DDEval project") | ||
if(BUILD_DD_EVAL_BENCHMARKS) | ||
enable_testing() | ||
include(GoogleTest) | ||
add_subdirectory(benchmarks) | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want the cpp-linter to work properly, you also have to set that option in the corresponding CI workflow (.github/workflows/cpp-linter.yaml
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This executor can just be combined with the other hybrid executor and the simulation type can be specified as an option.
This avoids quite some code duplication.
|
||
auto qc = std::make_unique<qc::QuantumComputation>(task.getQc()->clone()); | ||
auto hybridSimulator = std::make_unique<HybridSchrodingerFeynmanSimulator<>>( | ||
std::move(qc), ApproximationInfo{}, 23, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract the magic seed number as a global constant somewhere so that it can be used everywhere and is just defined in a single place.
auto const constructionStart = std::chrono::steady_clock::now(); | ||
|
||
auto qc = std::make_unique<qc::QuantumComputation>(task.getQc()->clone()); | ||
auto circuitSimulator = | ||
std::make_unique<StochasticNoiseSimulator<>>(std::move(qc), 1, 1, 23); | ||
|
||
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of this code throughout these files is repetitive and it should be possible to reduce that code duplication quite considerably.
All of these methods measure the time some construction method takes and the time taken by some execution function. Each of these can be wrapped as a function that takes a function as one of its arguments.
Should remove quite a lot of lines of code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1e86792
Could you take a look at this commit and see if this way of refactoring is good? If so I'll do it for the rest of the executor classes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good, I think!
It should be possible to move the construction of the circuit to the base class though.
Since the SimulationExecutor is a template class. You will most likely have to define that in the header and make sure that you have the proper includes for all the classes that are used.
test/test_simexec_berstein.cpp
Outdated
// Gives "C++ exception with description "Unsupported non-unitary functionality | ||
// 'Rst '." thrown in the test body." when run in dynamic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dynamic versions of the algorithms are only supported by the regular circuit simulator.
Still worth testing them there. And that should also be made easier by the separation by executors.
// Other executors excluded because 128 qubits still have under 1s execution | ||
// time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still run these algorithms for all executors to make sure they still work.
test/test_simexec_simple.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this file kind of redundant now that there are dedicated test files for the algorithms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just commenting on this file, but everything here holds for the other files as well:
Similar to the test, I would split the benchmarks per executor and not by algorithm.
Furthermore, the benchmarks should really test a broad range of qubits, from really small to really large to cover the whole range of circuit sizes and complexity.
It's not enough to just benchmark a handful of circuits here.
Last but not least, this is missing quite some algorithms that are directly available in our libraries. There should be a parity between the algorithms tested in this repo and the algorithms used for benchmarking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be clear you mean that I should run the same algorithms both for test and benchmark with the only difference being benchmark being more thorough (more tests with different numbers of qubits), right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. The tests can just cover certain instances of each benchmark, while the benchmarks should cover a broad range.
test/test_simexec_berstein.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just commenting this here since there is not really a better place for that: these test are missing quite some algorithms that are directly available.
This includes the QPE algorithm in its exact and inexact variant, the dynamic versions of the algorithms, the QFT (potentially with non-zero input state), the W-State.
## Description Implement WState from [this](https://github.com/cda-tum/mqt-bench/blob/main/src/mqt/bench/benchmarks/wstate.py) `mqt-bench` script in light of the DD benchmarking in [this PR](tyi1025/dd_eval#12). --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Lukas Burgholzer <[email protected]>
closes #5