-
Notifications
You must be signed in to change notification settings - Fork 10
Refactoring of synthesis of division and modulo operations #305
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
Refactoring of synthesis of division and modulo operations #305
Conversation
…ence algorithm. Added basic simulation tests to verify correct synthesis of refactored operations.
@@ -147,6 +147,16 @@ | |||
this->performTestExecutionForCircuitLoadedFromJson(RELATIVE_PATH_TO_TEST_CASE_DATA_JSON_FILE, this->getNameOfCurrentlyExecutedTest()); | |||
} | |||
|
|||
TYPED_TEST_P(BaseSimulationTestFixture, BinaryOperationDivision) { |
Check notice
Code scanning / CodeQL
Unused static variable Note test
this->performTestExecutionForCircuitLoadedFromJson(RELATIVE_PATH_TO_TEST_CASE_DATA_JSON_FILE, this->getNameOfCurrentlyExecutedTest()); | ||
} | ||
|
||
TYPED_TEST_P(BaseSimulationTestFixture, BinaryOperationModulo) { |
Check notice
Code scanning / CodeQL
Unused static variable Note test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this 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 refactors the synthesis of division and modulo operations by replacing the existing implementation with the restoring division algorithm from "Quantum Circuit Designs of Integer Division Optimizing T-count and T-depth". The changes address a mismatch between expected and actual output values in synthesized circuits.
- Updates division and modulo synthesis to use the restoring division algorithm with proper quotient and remainder calculations
- Modifies the SyrecSynthesis interface to require both quotient and remainder qubits for both operations
- Adds comprehensive test coverage for division and modulo operations with updated cost expectations
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
src/algorithms/synthesis/syrec_synthesis.cpp | Implements new restoring division algorithm for both division and modulo operations |
include/algorithms/synthesis/syrec_synthesis.hpp | Updates function signatures to include quotient and remainder parameters |
test/unittests/simulation/test_synthesis_basic_operations.cpp | Adds new test cases for division and modulo operations |
test/unittests/simulation/data/test_synthesis_of_basic_operations.json | Provides test data with expected input/output pairs for division and modulo |
test/configs/circuits_line_aware_synthesis.json | Updates expected circuit metrics for affected test circuits |
test/configs/circuits_cost_aware_synthesis.json | Updates expected circuit metrics for affected test circuits |
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
Description
The current implementation of the synthesis of the division and modulo operations did not create the correct gate sequence and lead to a missmatch between the expected and actual output values when simulating the synthesized circuits. With this PR the implementation of both operations is replaced with the restoring division algorithm defined in Quantum Circuit Designs of Integer Division Optimizing T-count and T-depth. This caused the following changes:
the quotient and remainder qubits need to be provided for both operations.
Note that the referenced paper also defines a non-restoring division algorithm that requires less transistors to synthesize. At the moment we are not sure whether any of the two division algorithms could be refactored to only require N ancillary qubits (to store the quotient in the division/remainder in the modulo operation) to synthesis.
Fixes #302
Checklist: