cda-tum / mqt-core

MQT Core - The Backbone of the Munich Quantum Toolkit
https://mqt.readthedocs.io/projects/core
MIT License
62 stars 31 forks source link

:sparkles: Add `customGate` flag and optimizer functionality to flatten only custom gates #651

Closed DRovara closed 4 months ago

DRovara commented 4 months ago

Description

This pull request adds the customGate flag to the CompoundOperation class. This flag is set for CompoundOperations that were constructed from custom gate calls.

The pull request also provides new functionality to the flattenOperations optimizer. Now, a second parameter can be used to indicate that only custom gates should be flattened. It makes sense to put this functionality here as outside of the CircuitOptimizer class, certain protected members cannot be accessed anymore.

Checklist:

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.6%. Comparing base (3ce5689) to head (6c76ad1). Report is 144 commits behind head on main.

Files with missing lines Patch % Lines
src/operations/CompoundOperation.cpp 83.3% 1 Missing :warning:
Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/cda-tum/mqt-core/pull/651/graphs/tree.svg?width=650&height=150&src=pr&token=MqstsRKdqp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cda-tum)](https://app.codecov.io/gh/cda-tum/mqt-core/pull/651?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cda-tum) ```diff @@ Coverage Diff @@ ## main #651 +/- ## ======================================= - Coverage 91.6% 91.6% -0.1% ======================================= Files 148 148 Lines 14755 14759 +4 Branches 2369 2370 +1 ======================================= + Hits 13522 13525 +3 - Misses 1233 1234 +1 ``` | [Flag](https://app.codecov.io/gh/cda-tum/mqt-core/pull/651/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cda-tum) | Coverage Δ | | |---|---|---| | [cpp](https://app.codecov.io/gh/cda-tum/mqt-core/pull/651/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cda-tum) | `91.3% <90.9%> (-0.1%)` | :arrow_down: | | [python](https://app.codecov.io/gh/cda-tum/mqt-core/pull/651/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cda-tum) | `99.7% <ø> (ø)` | | | [Files with missing lines](https://app.codecov.io/gh/cda-tum/mqt-core/pull/651?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cda-tum) | Coverage Δ | | |---|---|---| | [include/mqt-core/operations/CompoundOperation.hpp](https://app.codecov.io/gh/cda-tum/mqt-core/pull/651?src=pr&el=tree&filepath=include%2Fmqt-core%2Foperations%2FCompoundOperation.hpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cda-tum#diff-aW5jbHVkZS9tcXQtY29yZS9vcGVyYXRpb25zL0NvbXBvdW5kT3BlcmF0aW9uLmhwcA==) | `100.0% <ø> (ø)` | | | [src/CircuitOptimizer.cpp](https://app.codecov.io/gh/cda-tum/mqt-core/pull/651?src=pr&el=tree&filepath=src%2FCircuitOptimizer.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cda-tum#diff-c3JjL0NpcmN1aXRPcHRpbWl6ZXIuY3Bw) | `88.9% <100.0%> (+<0.1%)` | :arrow_up: | | [src/parsers/QASM3Parser.cpp](https://app.codecov.io/gh/cda-tum/mqt-core/pull/651?src=pr&el=tree&filepath=src%2Fparsers%2FQASM3Parser.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cda-tum#diff-c3JjL3BhcnNlcnMvUUFTTTNQYXJzZXIuY3Bw) | `90.5% <100.0%> (ø)` | | | [src/operations/CompoundOperation.cpp](https://app.codecov.io/gh/cda-tum/mqt-core/pull/651?src=pr&el=tree&filepath=src%2Foperations%2FCompoundOperation.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cda-tum#diff-c3JjL29wZXJhdGlvbnMvQ29tcG91bmRPcGVyYXRpb24uY3Bw) | `85.9% <83.3%> (-0.6%)` | :arrow_down: |