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

🎨 Refactor NAComputation with concrete base classes for every operation and ouput new .naviz format #846

Merged
merged 40 commits into from
Mar 6, 2025

Conversation

ystade
Copy link
Collaborator

@ystade ystade commented Mar 3, 2025

Description

The tool mqt-naviz purposefully introduces a new textual format that allows to execute operations at a specific time stamp. The current output format of NA computation is not really compatible even though mqt-naviz supports a legacy feature to read in this old format with some caveats.

This issue triggered a wider refactoring of the NAComputation. Its entire structure is refactored. Most importantly, concrete Operation have their own class representation inheriting from some super class. At the end, all operations inherit from the class Op. As part of the refactoring, there is a straight forward way to test whether an operation is of some particular type and then it can be casted to this type.

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.

@ystade ystade added enhancement New feature or request usability Anything related to usability refactor Anything related to code refactoring c++ Anything related to C++ code labels Mar 3, 2025
@ystade ystade self-assigned this Mar 3, 2025
@ystade ystade force-pushed the refactor-na-computation branch from ebe8ff1 to ba95268 Compare March 3, 2025 07:57
@burgholzer burgholzer changed the title 🚸 Adapt Output Format of NA Computation to mqt-naviz' format 🚸 Adapt Output Format of NA Computation to mqt-naviz format Mar 3, 2025
@ystade ystade requested a review from burgholzer March 3, 2025 15:45
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 @ystade for creating this PR.
These are really some great improvements to the usability of the NA components of MQT Core.
As this kind of sets a precedent for changes we might also want to apply to the qc::Operation and qc::QuantumComputation hierarchy. I went through the code with some extra scrutiny.
You will find most of that in the inline comments.
Some of these are really up for discussion, but I think it is worth having that discussion.

I have two more general points:

  • Please update the PR title to better reflect the changes in this PR. This is fundamentally refactoring how we handle NA computations and not simply updating an output format. Probably also worth to update the PR description
  • Since a couple PRs back, we also have C++ documentation as part of our docs. As such, it would be really great to also have proper C++ documentation for all newly added C++ code. In times of LLM-assistance, I hope this should be moderately easy.

Many thanks for your work on this 🙏🏼

@ystade ystade force-pushed the refactor-na-computation branch from 7c681ce to 4edea4a Compare March 5, 2025 13:48
@ystade ystade requested a review from burgholzer March 5, 2025 14:01
@ystade
Copy link
Collaborator Author

ystade commented Mar 5, 2025

@burgholzer The tests should run through now and all your feedback should be integrated to the best of my knowledge.

@burgholzer
Copy link
Member

Great! Many thanks for addressing this so quickly 🙏🏼
I will have a look later today.

@ystade
Copy link
Collaborator Author

ystade commented Mar 5, 2025

@burgholzer There is (at least) one issue remaining. I used the convention to append a _ to members to avoid name shadowing as suggsted. This conflicts with the naming convention. What do we want to do about it?

@burgholzer
Copy link
Member

@burgholzer There is (at least) one issue remaining. I used the convention to append a _ to members to avoid name shadowing as suggsted. This conflicts with the naming convention. What do we want to do about it?

Hm. Probably the cleanest solution would be to adjust the clang-tidy config so that this is not a violation anymore.
In order to not create dozens of warnings for the remainder of MQT Core, one could use a regex where the trailing underscore is optional.

@ystade
Copy link
Collaborator Author

ystade commented Mar 5, 2025

@burgholzer There is (at least) one issue remaining. I used the convention to append a _ to members to avoid name shadowing as suggsted. This conflicts with the naming convention. What do we want to do about it?

Hm. Probably the cleanest solution would be to adjust the clang-tidy config so that this is not a violation anymore. In order to not create dozens of warnings for the remainder of MQT Core, one could use a regex where the trailing underscore is optional.

Apparently, there is a specific key for that option. See the changes from the last commit.

@burgholzer
Copy link
Member

Apparently, there is a specific key for that option. See the changes from the last commit.

I am pretty sure that is not what we want, as this enforces the trailing underscore. And I am also pretty sure you do not have the time resources to go through all of MQT Core and change that.

@ystade ystade changed the title 🚸 Adapt Output Format of NA Computation to mqt-naviz format 🎨 Refactor NAComputation with concrete base classes for every operation and ouput new .naviz format Mar 5, 2025
burgholzer and others added 8 commits March 5, 2025 16:06
…lation (#849)

## Description

This pull request adds support for handling empty quantum and classical
registers during the translation process from Qiskit to MQT. This update
ensures proper translation and eliminates any potential errors caused by
empty registers.

This has come up while working on
cda-tum/mqt-ddsim#336

## Checklist:

- [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>
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>
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 working through all the comments.
This is a really clean PR. I like that very much 😌
I just put on some finishing touches in the last couple of commits. Specifically:

  • removed two redundant files that were left over from before the last iteration
  • added @file docstrings to all new files. (important for getting proper doxygen output)
  • completed some missing docstrings
  • shortened some existing ones where a one-line brief was sufficient
  • adjusted the spacing in headers so that the files don't look so cluttered.
  • applied some left-over suggestions in the NA computation.

Once CI is green, I will go ahead and merge this.
I'll also create a new 3.0 Beta release so that it becomes easier to directly rely on this in QMAP.

@burgholzer burgholzer merged commit f1f2de4 into main Mar 6, 2025
31 checks passed
@burgholzer burgholzer deleted the refactor-na-computation branch March 6, 2025 23:25
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 enhancement New feature or request refactor Anything related to code refactoring usability Anything related to usability
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants