Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Gather DDSIM benchmarks #12

Draft
wants to merge 30 commits into
base: main
Choose a base branch
from
Draft

Gather DDSIM benchmarks #12

wants to merge 30 commits into from

Conversation

tyi1025
Copy link
Owner

@tyi1025 tyi1025 commented Jun 14, 2023

closes #5

@tyi1025 tyi1025 self-assigned this Jun 14, 2023
@tyi1025 tyi1025 linked an issue Jun 14, 2023 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Jun 14, 2023

Codecov Report

Merging #12 (77a1505) into main (fd049a1) will not change coverage.
The diff coverage is 100.0%.

@@           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     
Files Changed Coverage Δ
include/Executor.hpp 100.0% <ø> (ø)
include/executors/CircuitSimulatorExecutor.hpp 100.0% <ø> (ø)
include/SimulationExecutor.hpp 100.0% <100.0%> (ø)
...nclude/executors/DeterministicNoiseSimExecutor.hpp 100.0% <100.0%> (ø)
include/executors/HybridSimulatorExecutor.hpp 100.0% <100.0%> (ø)
...ude/executors/StochasticNoiseSimulatorExecutor.hpp 100.0% <100.0%> (ø)
include/executors/UnitarySimulatorExecutor.hpp 100.0% <100.0%> (ø)
src/executors/CircuitSimulatorExecutor.cpp 100.0% <100.0%> (ø)
src/executors/DeterministicNoiseSimExecutor.cpp 100.0% <100.0%> (ø)
src/executors/HybridSimulatorExecutor.cpp 100.0% <100.0%> (ø)
... and 10 more

... and 1 file with indirect coverage changes

@tyi1025 tyi1025 added the enhancement New feature or request label Jul 14, 2023
Copy link
Collaborator

@burgholzer burgholzer left a 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")
Copy link
Collaborator

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

Comment on lines +38 to +43
option(BUILD_DD_EVAL_BENCHMARKS "Also build benchmarks for DDEval project")
if(BUILD_DD_EVAL_BENCHMARKS)
enable_testing()
include(GoogleTest)
add_subdirectory(benchmarks)
endif()
Copy link
Collaborator

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)

Copy link
Collaborator

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,
Copy link
Collaborator

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.

Comment on lines 7 to 28
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();
Copy link
Collaborator

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.

Copy link
Owner Author

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

Copy link
Collaborator

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.

Comment on lines 41 to 42
// Gives "C++ exception with description "Unsupported non-unitary functionality
// 'Rst '." thrown in the test body." when run in dynamic
Copy link
Collaborator

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.

Comment on lines +11 to +12
// Other executors excluded because 128 qubits still have under 1s execution
// time
Copy link
Collaborator

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.

Copy link
Collaborator

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?

Copy link
Collaborator

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.

Copy link
Owner Author

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?

Copy link
Collaborator

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.

Copy link
Collaborator

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.

burgholzer added a commit to cda-tum/mqt-core that referenced this pull request Aug 9, 2023
## 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]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🧪 Gather DDSIM benchmarks
2 participants