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

✨ Partial equivalence checking #375

Merged
merged 42 commits into from
Mar 18, 2024

Conversation

reb-ddm
Copy link
Contributor

@reb-ddm reb-ddm commented Mar 15, 2024

Description

Added a flag checkPartialEquivalence in order to decide whether to check for total equivalence or for partial equivalence. Two circuits are partially equivalent if, for each possible initial input state, they have the same probability for each measurement outcome. Therefore the state of not measured qubits (= garbage qubits), or phases are ignored.

The Construction Checker and the Simulation Checker implement this by reducing the contribution of garbage qubits in the matrix/vector representation of the circuit. Additionally, all weights in the DD representation are set to their magnitude, such that different phases don't influence the result.

The Alternating Checker implements it by checking that the resulting matrix representation is equal to a diagonal matrix, modulo garbage qubits (instead of checking that it is equal to the identity matrix).

For more information, there is documentation in the file PartialEquivalence.ipynb.

An additional feature are the automatically generated benchmarks for partial equivalence. The function generatePartiallyEquivalentCircuits generates pairs of circuits which are partially equivalent, following the method described in the paper Partial Equivalence Checking of Quantum Circuits in Section VI. B.

Fixes issue #155

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.

Copy link

codecov bot commented Mar 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.4%. Comparing base (a46794a) to head (faf7d2e).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main    #375     +/-   ##
=======================================
+ Coverage   96.2%   96.4%   +0.1%     
=======================================
  Files         34      34             
  Lines       1753    1763     +10     
  Branches     215     217      +2     
=======================================
+ Hits        1688    1701     +13     
+ Misses        65      62      -3     
Flag Coverage Δ
cpp 96.2% <100.0%> (+0.2%) ⬆️
python 97.2% <100.0%> (+<0.1%) ⬆️
Files Coverage Δ
include/Configuration.hpp 96.4% <100.0%> (+<0.1%) ⬆️
include/EquivalenceCheckingManager.hpp 100.0% <100.0%> (ø)
include/checker/dd/TaskManager.hpp 98.4% <100.0%> (ø)
src/EquivalenceCheckingManager.cpp 94.3% <100.0%> (+<0.1%) ⬆️
src/checker/dd/DDAlternatingChecker.cpp 92.0% <100.0%> (+0.2%) ⬆️
src/checker/dd/DDEquivalenceChecker.cpp 92.8% <100.0%> (+0.9%) ⬆️
src/mqt/qcec/configuration.py 100.0% <100.0%> (ø)

... and 1 file with indirect coverage changes

@reb-ddm reb-ddm marked this pull request as ready for review March 17, 2024 10:34
@burgholzer burgholzer added feature New feature or request c++ Anything related to C++ code minor Part of a minor release labels Mar 18, 2024
@burgholzer burgholzer linked an issue Mar 18, 2024 that may be closed by this pull request
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
Copy link
Member

Hey @reb-ddm 👋🏼

Many thanks for all the work here! I took the liberty to rework some bits and pieces, but overall this is looking great and ready to merge. Once CI is all-green here, I'll start by merging the mqt-core PR and changing back the submodule pointers from the fork to the main repository. After that, this should be good to go 🎉

Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Copy link
Member

@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.

Really nice how little change was required here to enable support for partial equivalence checking! 🎉
This is now also ready to merge ✅

The C++ linter (unfortunately) fails on all PRs from forks due to missing permissions. But this can be safely ignored.
I'll admin-merge once all checks have run through.

@burgholzer burgholzer merged commit 4b5f383 into cda-tum:main Mar 18, 2024
35 of 37 checks passed
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 feature New feature or request minor Part of a minor release
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

✨ Support for Equivalent Measurement Outcome
2 participants