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

🚸♻️ convenience methods and updates for DD functionality #674

Merged
merged 25 commits into from
Nov 28, 2024

Conversation

burgholzer
Copy link
Member

@burgholzer burgholzer commented Aug 19, 2024

Description

This pull request includes several changes aimed at improving code efficiency and readability across the DD package.

Utility (functions):

  • Introduced new utility functions in Operations.hpp for applying unitary operations, measurements, resets, and classically controlled operations on quantum states.
  • DD routines for state preparation now automatically increase the respective refcount, so this does not have to be done manually anymore.
  • The classic-controlled Operation class now exposes its comparison kind to the QuantumComputation class and to Python.

Code simplification:

  • Simplified the getDD function by removing redundant checks and improving the handling of permutations.
  • A sample method was introduced as a shortcut for simply sampling from the output distribution of a circuit.
  • Several tests were simplified and streamlined.

These changes collectively enhance the maintainability and performance of the codebase.
They will require changes in consuming libraries. Especially mqt-ddsim, mqt-qcec, and mqt-ddvis. However, these changes should simplify the overall code in these libraries.

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.

@burgholzer burgholzer self-assigned this Aug 19, 2024
@burgholzer burgholzer added enhancement New feature or request usability Anything related to usability DD Anything related to the DD package c++ Anything related to C++ code labels Aug 19, 2024
Copy link

codecov bot commented Aug 19, 2024

Codecov Report

Attention: Patch coverage is 96.42857% with 6 lines in your changes missing coverage. Please review.

Project coverage is 92.1%. Comparing base (3a28015) to head (0418edc).
Report is 165 commits behind head on main.

Files with missing lines Patch % Lines
include/mqt-core/dd/Operations.hpp 93.2% 4 Missing ⚠️
include/mqt-core/dd/Package.hpp 97.7% 1 Missing ⚠️
src/dd/Simulation.cpp 98.0% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main    #674     +/-   ##
=======================================
- Coverage   92.1%   92.1%   -0.1%     
=======================================
  Files        125     125             
  Lines      13775   13791     +16     
  Branches    2160    2164      +4     
=======================================
+ Hits       12690   12703     +13     
- Misses      1085    1088      +3     
Flag Coverage Δ
cpp 91.8% <96.4%> (-0.1%) ⬇️
python 99.7% <ø> (ø)
Files with missing lines Coverage Δ
include/mqt-core/dd/Simulation.hpp 100.0% <100.0%> (ø)
include/mqt-core/ir/QuantumComputation.hpp 91.9% <ø> (ø)
...-core/ir/operations/ClassicControlledOperation.hpp 96.7% <100.0%> (+<0.1%) ⬆️
src/algorithms/QFT.cpp 100.0% <100.0%> (ø)
src/algorithms/QPE.cpp 100.0% <100.0%> (ø)
src/dd/FunctionalityConstruction.cpp 90.6% <100.0%> (-0.3%) ⬇️
include/mqt-core/dd/Package.hpp 96.9% <97.7%> (-0.2%) ⬇️
src/dd/Simulation.cpp 95.8% <98.0%> (-0.7%) ⬇️
include/mqt-core/dd/Operations.hpp 90.1% <93.2%> (+1.5%) ⬆️

Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Renamed the `simulate` function to `sample` for consistency and clarity. Implemented virtual SWAP gate execution by altering qubit permutations directly. Updated function signatures and internal logic for applying unitary, measurement, and reset operations, supporting the new SWAP handling. Removed redundant permutation management in function calls and streamlined permutation updates.

Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
@burgholzer burgholzer changed the title ♻️ methods for applying operations to DDs 🚸♻️ convenience methods and updates for DD functionality Nov 28, 2024
@burgholzer burgholzer added the minor Minor version update label Nov 28, 2024
@burgholzer burgholzer merged commit 6733f78 into main Nov 28, 2024
28 checks passed
@burgholzer burgholzer deleted the dd-improvements branch November 28, 2024 00:22
burgholzer added a commit that referenced this pull request Nov 28, 2024
## Description

This is a direct follow-up to #674 and adds one more convenience routine
that avoids users having to perform reference counting on their own.

## Checklist:

<!---
This checklist serves as a reminder of a couple of things that ensure
your pull request will be merged swiftly.
-->

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

Signed-off-by: burgholzer <burgholzer@me.com>
burgholzer added a commit to cda-tum/mqt-qcec that referenced this pull request Jan 8, 2025
## Description

This PR updates the MQT Core version used in QCEC to the latest version.
This includes changes from cda-tum/mqt-core#674 and
cda-tum/mqt-core#764.
SWAP eliding is now performed explicitly in QCEC instead of implicitly
in the `getDD` method of MQT Core.
Furthermore, states generated by the DD package now have their ref count
increased by default, which required subtle changes to the ref counting
scheme.

## Checklist:

<!---
This checklist serves as a reminder of a couple of things that ensure
your pull request will be merged swiftly.
-->

- [x] The pull request only contains commits that are related to it.
- [x] I have added appropriate tests and documentation.
- [x] I have made sure that all CI jobs on GitHub pass.
- [x] The pull request introduces no new warnings and follows the
project's style guidelines.
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 minor Minor version update usability Anything related to usability
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant