-
Notifications
You must be signed in to change notification settings - Fork 29
Remove representation dependencies and refactor codebase #605
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
base: develop
Are you sure you want to change the base?
Conversation
…rt of a refactoring to simplify the representation handling in the codebase.
….py and utilities to work without representations module - Simplify import structure and remove representation dependencies
… all state classes (Coherent, DisplacedSqueezed, Ket, etc.) - Remove representation attribute usage and simplify initialization - Update imports to use direct module paths
… - Update all transformation classes (gates, amplifiers, etc.) - Remove representation attribute usage and simplify initialization - Update imports and base class structure
…es to remove representation dependencies - Fix imports and test assertions - Ensure all tests pass with the new structure
…sgate, interferometer, mzgate, and rgate - Remove any remaining representation dependencies
… dependencies - Update BSgate, Interferometer, MZgate, and Rgate to eliminate representation attributes and simplify initialization - Adjust imports and ensure consistency across transformation implementations.
…nsatz.from_function with direct ansatz creation to avoid lazy evaluation during JAX transformations - Use numpy arrays instead of math backend calls in vacuum_state_Abc to prevent tracer leaks - Fixes test_learning_two_mode_squeezing test failure
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #605 +/- ##
===========================================
- Coverage 91.51% 91.50% -0.02%
===========================================
Files 102 101 -1
Lines 5837 5863 +26
===========================================
+ Hits 5342 5365 +23
- Misses 495 498 +3
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
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.
To make it easier to focus on the changes relevant to this PR, it could be nice for all of the isort
changes to be handled elsewhere (perhaps in a preliminary PR).
@@ -1,8 +1,2 @@ | |||
The Fock-Bargmann and Fock Representations |
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.
The .rst file here should be removed
@@ -70,8 +70,8 @@ clean-docs: | |||
|
|||
.PHONY : format | |||
format: | |||
isort --py 312 --profile black -l 100 -p mrmustard/ tests/ $(ICHECK) | |||
black -t py310 -t py311 -t py312 -l 100 mrmustard/ tests/ $(CHECK) |
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.
Why is 312 being removed here?
@@ -12,15 +12,15 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
|
|||
"""Tests for the Representation class.""" | |||
"""Tests for the CircuitComponent class (formerly Representation).""" |
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.
Now that there isn't a Representation
class I think these tests should be ported to it's respective file
A = _vacuum_A_matrix(n_modes) | ||
b = _vacuum_B_vector(n_modes) | ||
c = math.astensor(1.0 + 0.0j) | ||
c = np.array(1.0 + 0.0j, dtype=np.complex128) |
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.
What was the issue here?
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.
jax had a tracer error, this way it went away
Co-authored-by: Anthony <[email protected]>
Co-authored-by: Anthony <[email protected]>
User description
This PR removes the representations module and refactors the entire codebase to eliminate representation dependencies, simplifying the architecture and improving maintainability. Key changes include: removal of representations.py module, refactoring of all state and transformation classes, fixing JAX tracer leaks, and updating all tests to work with the new structure.
PR Type
Enhancement
Description
• Remove representations module and refactor architecture
• Update all states and transformations to use ansatz/wires directly
• Fix JAX tracer leaks in vacuum state initialization
• Simplify circuit component structure and imports
Changes walkthrough 📝
17 files
Refactor CircuitComponent to use ansatz/wires directly
Remove representation dependencies from transformation base classes
Refactor Ket class to remove representation dependencies
Update gaussian states to use ansatz/wires directly
Refactor DM class to remove representation dependencies
Update BSgate to use ansatz/wires directly
Update Dgate to use ansatz/wires directly
Update DisplacedSqueezed to use ansatz/wires directly
Update PhaseNoise to use ansatz/wires directly
Update MZgate to use ansatz/wires directly
Update BtoQ to use ansatz/wires directly
Update QuadratureEigenstate to use ansatz/wires directly
Update Coherent state to use ansatz/wires directly
Update TraceOut to use ansatz/wires directly
Update TwoModeSqueezedVacuum to use ansatz/wires directly
Update S2gate to use ansatz/wires directly
Update SqueezedVacuum to use ansatz/wires directly
3 files
Update tests for new CircuitComponent structure
Update transformation tests for new structure
Update representation tests to use CircuitComponent
29 files