Skip to content

🐛 Fix of duplicate qubit label generation during synthesis #327

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

Open
wants to merge 38 commits into
base: main
Choose a base branch
from

Conversation

TooMuchDakka
Copy link
Collaborator

@TooMuchDakka TooMuchDakka commented Aug 6, 2025

Description

This PR introduces the following changes in both the C++ as well as the python library.
C++:

  • Internal qubit labels for ancillary qubits as well as the qubits of local variables of SyReC modules are generated using the pattern "__p<CURR_NUM_QUBITS_IN_QUANTUM_COMP>" with the "__p" currently not being configurable via the synthesis settings. The combinations of internal qubit label => user defined qubit label are stored in the syrec::AnnotatableQuantumComputation.
  • The inline stack of an ancillary/qubits of the local variables of a SyReC module are optional (activated via a flag in the syrec::Properties passed to the synthesis algorithms) generated and stored in the syrec::AnnotatableQuantumComputation (queriable via syrec::AnnotatableQuantumComputation::getInliningInformationOfQubit(...)), to provide debug information about the origin of the qubit to the user. This feature needs to be explicitly activated with the qubit label combination generation of the previous bullet point not being effected by this feature.
  • Three new data structures syrec::QubitInlineStack, syrec::QubitInliningStack::QubitInliningStackEntry and syrec::AnnotatableQuantumComputation::InlinedQubitInformation were added.
  • Two new constants MAIN_MODULE_IDENTIFIER_CONFIG_KEY and GENERATE_INLINE_DEBUG_INFORMATION_CONFIG_KEY in \include\algorithms\syrec_synthesis.hpp to improve the activation of synthesis features in syrec::Properties instead of relying on hard-coded strings in the source files.

Python:

  • An update to the python bindings to make the newly introduced data structures available
  • The two new string constants are made available as attributes of the python module but not documented in the reStructured Text files due to "warnings" being generated in the documentation because no 'doc string' can be provided for the attributes. This should be fixable in the future if .pyi files are used to document the python package, as is the case in the mqt-core project.
  • Two new PyQt6 widgets to update the synthesis settings and display the qubit inline information:
labelledEditorWidgets

The displayed qubit inline information when the feature is deactivated/activated is the following:
qubitInlineInfoDifferences

Inline information about a qubit can be selected in the syrec-editor by:

  • Selecting the label of an ancillary/local variable qubit of a module in the combobox
  • Click on the label of an ancillary/local variable qubit of a module in the circuit view

Fixes #278

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.

…optional creation of inline stack so that release builds can skip this potentially unneeded step in the synthesis process
…bly causes by std::unique_ptr default holder type created via python bindings
…be set when adding qubits for variables when 'feature' is not activated in synthesis settings.
…rovide information how information can be queried in GUI
…inal qubit label GUI elements are disabled if the value of the label is empty.
…bits when set cannot be a nullptr or empty since the inline stack should contain at least one entry (i.e. the main module of a SyReC program).
…of identifier of module and any of its parameters or local variables
…e hard-coded redundant definitions of qubit label prefix with a single unified "source of truth"
…ine information when said feature is activated in synthesis settings
…its generated during synthesis of module synthesis shared same inline stack instance instead of the latter creating a new copy on every call. Added tests for qubit inline information for N-dimensional variables.
… synthesis algorithms if qubit inline information should not be recorded
…that the qubit is clickable in the CircuitView and selectable in the qubit label combobox of the qubit inline information widget
Copy link

codecov bot commented Aug 6, 2025

@TooMuchDakka TooMuchDakka marked this pull request as ready for review August 7, 2025 11:09
@TooMuchDakka TooMuchDakka requested a review from burgholzer August 7, 2025 11:48
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.

Looks reasonable to me. Just a handful of minor comments.

Comment on lines 31 to 40
if(NOT TARGET ${MQT_SYREC_TARGET_NAME}-antlr-parser OR NOT TARGET
${MQT_SYREC_PARSER_TARGET_NAME}-synthesis)
add_library(${MQT_SYREC_TARGET_NAME}-utils INTERFACE)
target_include_directories(
${MQT_SYREC_TARGET_NAME}-utils
INTERFACE ${MQT_SYREC_INCLUDE_BUILD_DIR}/algorithms/synthesis/internal_qubit_label_builder.hpp)
target_link_libraries(${MQT_SYREC_TARGET_NAME}-utils INTERFACE MQT::ProjectWarnings
MQT::ProjectOptions)
add_library(MQT::SyReC-Utils ALIAS ${MQT_SYREC_TARGET_NAME}-utils)
endif()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am personally not the biggest fan of utils libraries as they tend to become a hot mess of unrelated functions.
This clearly belongs to the synthesis part of the syrec library. Why not add it to one of the existing targets?

Copy link
Collaborator Author

@TooMuchDakka TooMuchDakka Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A separate utility library might be overkill, now the header file of the library is only included in the synthesis as well as antlr-parser library, it is included in the latter to prevent having to link the synthesis library for a single header file, with the utilities library being removed from all other targets. @burgholzer Are these changes sufficient to resolve your comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Duplicate qubit label/s created during synthesis
2 participants