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

♻️ Eliminate DD terminal nodes #381

Merged
merged 14 commits into from
Jul 22, 2023
Merged

♻️ Eliminate DD terminal nodes #381

merged 14 commits into from
Jul 22, 2023

Conversation

burgholzer
Copy link
Member

@burgholzer burgholzer commented Jul 15, 2023

Description

This PR completely eliminates the static DD node terminals and replaces them by using nullptr instead.
For one, this eliminates some global static variables.. Yay 😃
Furthermore, DD terminal nodes are no longer associated with the index -1. This allows changing the qubit index to an unsigned type and unlocks double the number of qubits (while also allowing to get rid of some static_casts).
Finally, analysis has shown that the DD node size does not increase when using 16 bits for the qubit index (due to alignment). Hence, the package now directly supports up to 65536 qubits 🥳.

Note that this, naturally, is a breaking change. Qubit indices are now unsigned and checks for a terminal node should now use the respective functions of the Node classes instead of relying the variable index to be -1.
Something to look out for: Any decreasing loops that used a Qubit index for iteration and relied on >=0 stopping conditions have to be revised since they now just wrap around at zero.

Checklist:

  • The pull request only contains commits that are related to it.
  • I have added appropriate tests and documentation.
  • I have made sure that all CI jobs on GitHub pass.
  • The pull request introduces no new warnings and follows the project's style guidelines.

Signed-off-by: Lukas Burgholzer <lukas.burgholzer@jku.at>
Signed-off-by: Lukas Burgholzer <lukas.burgholzer@jku.at>
Signed-off-by: Lukas Burgholzer <lukas.burgholzer@jku.at>
This commit completely eliminates the static DD node terminals and replaces them by using nullptr instead.
For one, this eliminates some global static variables. Furthermore, DD terminal nodes are no longer associated with the index -1. This allows changing the qubit index to an unsigned type and unlocks double the number of qubits.
Finally, analysis has shown that the DD node size does not increase when using 16 bits for the qubit index. Hence, the package now directly supports up to 65536 qubits.

Signed-off-by: Lukas Burgholzer <lukas.burgholzer@jku.at>
Signed-off-by: Lukas Burgholzer <lukas.burgholzer@jku.at>
@burgholzer burgholzer added enhancement New feature or request refactor Anything related to code refactoring DD Anything related to the DD package c++ Anything related to C++ code labels Jul 15, 2023
@burgholzer burgholzer added this to the DD Package Improvements milestone Jul 15, 2023
@burgholzer burgholzer self-assigned this Jul 15, 2023
Signed-off-by: Lukas Burgholzer <lukas.burgholzer@jku.at>
@codecov
Copy link

codecov bot commented Jul 15, 2023

Codecov Report

Merging #381 (6eb2b56) into main (b1c49b9) will increase coverage by 0.0%.
The diff coverage is 97.4%.

@@          Coverage Diff          @@
##            main    #381   +/-   ##
=====================================
  Coverage   89.0%   89.1%           
=====================================
  Files         97      97           
  Lines      11708   11713    +5     
  Branches    2098    2103    +5     
=====================================
+ Hits       10431   10437    +6     
+ Misses      1277    1276    -1     
Impacted Files Coverage Δ
include/dd/DDDefinitions.hpp 100.0% <ø> (ø)
include/dd/NoiseFunctionality.hpp 93.0% <92.1%> (ø)
src/dd/Simulation.cpp 97.3% <94.1%> (-0.1%) ⬇️
include/dd/Package.hpp 94.5% <97.8%> (+0.3%) ⬆️
include/dd/Export.hpp 94.8% <100.0%> (-1.0%) ⬇️
include/dd/Node.hpp 100.0% <100.0%> (ø)
include/dd/Operations.hpp 83.7% <100.0%> (-0.2%) ⬇️
include/dd/StochasticNoiseOperationTable.hpp 93.5% <100.0%> (ø)
include/dd/UniqueTable.hpp 98.0% <100.0%> (+0.9%) ⬆️
src/dd/Edge.cpp 88.0% <100.0%> (+0.2%) ⬆️
... and 3 more

... and 1 file with indirect coverage changes

include/dd/Package.hpp Fixed Show fixed Hide fixed
include/dd/Package.hpp Fixed Show fixed Hide fixed
include/dd/Package.hpp Fixed Show fixed Hide fixed
include/dd/Package.hpp Fixed Show fixed Hide fixed
Signed-off-by: Lukas Burgholzer <lukas.burgholzer@jku.at>
Signed-off-by: Lukas Burgholzer <lukas.burgholzer@jku.at>
Signed-off-by: Lukas Burgholzer <lukas.burgholzer@jku.at>
Signed-off-by: Lukas Burgholzer <lukas.burgholzer@jku.at>
include/dd/UniqueTable.hpp Outdated Show resolved Hide resolved
include/dd/UniqueTable.hpp Outdated Show resolved Hide resolved
include/dd/Package.hpp Outdated Show resolved Hide resolved
include/dd/Package.hpp Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

Cpp-Linter Report ✔️

No problems need attention.

Have any feedback or feature suggestions? Share it here.

@burgholzer burgholzer requested a review from hillmich July 17, 2023 08:44
Copy link
Member

@hillmich hillmich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this effort! The increase in available qubits is really nice.

You correctly point out that decrementing loops that check for >=0 require attention. Please wait a bit before merging so I can make this work correctly in the simulator :)

@hillmich
Copy link
Member

It took some effort, but the simulator works now :)

@burgholzer
Copy link
Member Author

It took some effort, but the simulator works now :)

Nice. Thanks for your work on that!
I'll probably merge today or tomorrow 😌

@burgholzer burgholzer merged commit fd23c95 into main Jul 22, 2023
48 checks passed
@burgholzer burgholzer deleted the eliminate-dd-terminal branch July 22, 2023 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Anything related to C++ code DD Anything related to the DD package enhancement New feature or request refactor Anything related to code refactoring
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants