Skip to content

Synthesis of shift expressions with shift amount larger or equal to bitwidth of to be shift expression. #297

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

Conversation

TooMuchDakka
Copy link
Collaborator

@TooMuchDakka TooMuchDakka commented Jul 8, 2025

Description

With this PR the synthesis of a shift expression in which the defined shift amount is larger or equal to the bitwidth of the to be shifted expression (N) is "simplified" to the creation of N ancillary qubits (i.e. equal to an substitution of the shift expression with the constant 0) with the latter storing the result of the shift expression.

Fixes #258

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 3 commits July 8, 2025 16:36
…n the bitwidth of the to be shift expression (N) is equal to the creation of N ancillary qubits.
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

…uring synthesis and equal to the bitwidth of the to be shifted expression
Copy link

codecov bot commented Jul 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@TooMuchDakka TooMuchDakka added c++ Anything related to C++ code fix Changes fixing something that was not working labels Jul 8, 2025
@TooMuchDakka TooMuchDakka marked this pull request as ready for review July 8, 2025 15:43
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.

LGTM

@burgholzer burgholzer requested a review from Copilot July 19, 2025 09:44
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the synthesis of shift expressions by optimizing cases where the shift amount is greater than or equal to the bitwidth of the shifted expression. In such cases, the result is mathematically equivalent to zero, so the PR simplifies the synthesis to create N ancillary qubits (where N is the bitwidth) instead of performing the actual shift operation.

  • Fixes #258 by optimizing shift expressions with large shift amounts
  • Updates synthesis logic to return early when shift amount >= bitwidth
  • Improves parameter naming for better code clarity

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/unittests/simulation/test_synthesis_basic_operations.cpp Adds comprehensive test cases for shift expression synthesis edge cases
test/unittests/simulation/data/test_synthesis_of_basic_operations.json Provides test data for all new shift expression test cases
src/algorithms/synthesis/syrec_synthesis.cpp Implements the optimization logic and improves parameter naming
include/algorithms/synthesis/syrec_synthesis.hpp Updates function signatures with more descriptive parameter names

@TooMuchDakka TooMuchDakka merged commit 3f51f31 into munich-quantum-toolkit:main Jul 19, 2025
17 checks passed
@TooMuchDakka TooMuchDakka deleted the const-shift-amount branch July 19, 2025 17:46
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 fix Changes fixing something that was not working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Synthesis of right shift does not generate correct gate sequence
2 participants