-
Notifications
You must be signed in to change notification settings - Fork 0
Truncation logic refactoring #128
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…yx into truncation-refactoring
…yx into truncation-refactoring
giodefelice
approved these changes
Aug 28, 2025
mateuszkupper
added a commit
that referenced
this pull request
Aug 28, 2025
Adds a class `BasisTransition` for specifying output vectors of boxes with amplitudes, and a method `truncation_specification` for specifying the underlying truncated array of custom boxes.
mateuszkupper
added a commit
that referenced
this pull request
Aug 28, 2025
Adds a class `BasisTransition` for specifying output vectors of boxes with amplitudes, and a method `truncation_specification` for specifying the underlying truncated array of custom boxes.
mateuszkupper
added a commit
that referenced
this pull request
Aug 28, 2025
Adds a class `BasisTransition` for specifying output vectors of boxes with amplitudes, and a method `truncation_specification` for specifying the underlying truncated array of custom boxes.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Instead of specifying a
truncationmethod returning atensor.Boxfor all optyx (core) diagrams, a generictruncationmethod is given foroptyx.core.diagrams.Boxwhich uses_truncation_specificationwhich specifies the mapping between input basis vectors to output basis vectors. Only such_truncation_specificationmethod needs to be implemented for all boxes inheriting fromoptyx.core.diagrams.Box.Example for W (white triangle):
Example for Add:
For each input vector (a tuple with a photon number config), we return an output basis vector (photon number configs) with corresponding value which then can be used to construct an array for a tensor. This is done through a named tuple
BasisTransitionwith paramsoutandamp.Not all current boxes implement this method. For some,
truncationis overridden directly (especially when we can give a more efficient implementation) - like for ZBox.This PR simplifies the truncation logic by moving the common tensor/array building code into a shared method.