Skip to content

♻️ Removal of boost dependency from synthesis and simulation part of library #240

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

Merged
merged 28 commits into from
May 15, 2025

Conversation

TooMuchDakka
Copy link
Collaborator

@TooMuchDakka TooMuchDakka commented May 10, 2025

Description

This PR removes parts of the boost dependency from the synthesis and simulation part of the library

Towards #27

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.

TooMuchDakka and others added 17 commits May 7, 2025 22:37
…hat are also considered for all added gates of a circuit
…ntainer if they did not exist in the aggregate prior to the local scope
…er used in toggling operations of helper line.
…naming scheme of other objects of mqt.syrec python library. Updated python library documentation
@TooMuchDakka TooMuchDakka changed the title Boost replacement Removal of boost dependency from synthesis and simulation part of library May 10, 2025
Copy link

codecov bot commented May 10, 2025

@TooMuchDakka
Copy link
Collaborator Author

TooMuchDakka commented May 10, 2025

  • Checking whether the refactoring of the synthesis and simulation code was functionally correct (after the code was reviewed) was tested by running the currently existing synthesis and simulation tests. However, the synthesis tests only compare the number of gates, quantum and transistor costs of the synthesized circuit against a given json config which could lead to false-negatives in either this or future refactorings.
  • All gates generated during the synthesis of the statements of a syrec::Module will have an annotation denoting the line number of the associated statement. Assuming the following example:
1.  module decrement(inout a(4))
2.     --= a
3.
4.  module main(inout a(4), in b(4))
5.    if (a > b) then
6.      call decrement(a) // HERE
7.    else
8.      ++= a
9.   fi (a > b)

Call-/UncallStatements are synthesized by inlining the statements of the called module, here the decrement operation would be inlined in line 6. Currently the gates generated for the inlined statements will have the line number of the original statement annotated (e.g. line 2 for the inlined decrement operation) but one could also annotate the inline line number instead. However, when the called module contains more than a single statement, the inlined statement line number would now overlap with the line numbers of the statements following the call. One solution could be to annotate additional information to the inlined statement like the following:

Line number: 6
Inlined module: decrement
Relative line number in inlined module: 1

@TooMuchDakka TooMuchDakka marked this pull request as ready for review May 14, 2025 21:17
…ntrol lines no longer being filtered by deregistered control lines in propagation scopes
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.

Many thanks for the contribution here! This is much appreciated.

I skimmed through all of the changes, and they look reasonable to me.
Considering the volume of testing, I believe we should merge this and address any issues as soon as we identify them.

@burgholzer burgholzer added refactor Refactoring of the code base code quality Chages regarding code quality labels May 15, 2025
@burgholzer burgholzer merged commit 25c00fd into munich-quantum-toolkit:main May 15, 2025
17 checks passed
@burgholzer burgholzer changed the title Removal of boost dependency from synthesis and simulation part of library ♻️ Removal of boost dependency from synthesis and simulation part of library May 15, 2025
@burgholzer burgholzer added the major Changes warranting a major version bump label May 15, 2025
@TooMuchDakka TooMuchDakka deleted the boost-replacement branch May 15, 2025 19:29
burgholzer pushed a commit that referenced this pull request Jul 3, 2025
…ger throws index-out-of-range error (#281)

## Description

Prio to the first refactoring of the synthesis algorithm components for
the transition to MQT Core (see issue #29) the check for repeating qubit
indices in the operands of an expression via
`SyrecSynthesis::checkRepeats()` did contain the following check:

```cpp
    bool SyrecSynthesis::checkRepeats() {
        std::vector checkLhsVec(...);
        std::vector checkRhsVec(...);
        ...

        for (auto const& i: checkLhsVec) {
            for (auto const& j: checkRhsVec) {
                if (i == j) {
                    ...
                    return true;
                }
            }
        }
        return false;
    }
```

And was refactoring in #240 to which refactored introduced the invalid
assumption that the `checkLhsVec` and `checkRhsVec` containers have the
same size which is not the case in an expression of the form `(a ^ (b ^
c))` (`checkLhsVec.size()` = 2, `checkRhsVec.size()` = 1) and will lead
to an index-out-of-range access in said expression.

```cpp
    bool SyrecSynthesis::checkRepeats() {
        std::vector checkLhsVec(...);
        std::vector checkRhsVec(...);
        bool foundRepeat = false;
        ...
        for (std::size_t i = 0; i < checkLhsVec.size() && !foundRepeat; ++i) {
            foundRepeat = checkLhsVec[i] == checkRhsVec[i];
        }
        ...
        return foundRepeat;
    }
```

This PR fixes the index-out-of-range access.

Fixes #280 

## 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.
- [ ] 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.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Chages regarding code quality major Changes warranting a major version bump refactor Refactoring of the code base
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants