-
Couldn't load subscription status.
- Fork 706
default.tensor can preprocess with graph based decomposition system
#8253
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
+144
−0
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
This commit refactors the preprocess.decompose function to improve its integration with the new graph-based decomposition system and adds support for device-specific parameters. Key Changes: - Enhanced decompose() function to accept device_wires and target_gates parameters - Improved work wire calculation using set operations: len(set(device_wires) - set(tape.wires)) - Removed redundant num_available_work_wires and graph_solution parameters (computed internally) - Added preprocess_decompose_plxpr_to_plxpr function for PLXPR integration - Updated function signature and internal logic for better parameter handling Testing: - Added comprehensive test coverage for new device_wires and target_gates functionality - Added parametrized tests for work wire calculation with various edge cases - Added fixtures for graph decomposition backward compatibility testing - Used spy-based testing for safe parameter verification without mocking core functionality Code Quality: - Added __all__ export list for proper module interface definition - Fixed pylint warnings and ensured CI/CD compatibility - Improved exception handling with explicit re-raising patterns - Enhanced imports and dependencies for graph-based decomposition Backward Compatibility: - Maintained full backward compatibility for existing decompose() calls - Legacy behavior preserved when device_wires/target_gates not provided - Comprehensive fixture-based testing ensures both old and new modes work correctly
Co-authored-by: Christina Lee <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #8253 +/- ##
==========================================
- Coverage 99.39% 99.39% -0.01%
==========================================
Files 558 558
Lines 57781 57781
==========================================
- Hits 57432 57431 -1
- Misses 349 350 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
JerryChen97
commented
Sep 12, 2025
albi3ro
reviewed
Sep 12, 2025
albi3ro
reviewed
Sep 12, 2025
albi3ro
reviewed
Sep 12, 2025
|
NQ part has been spawn at #8260 |
default.tensor can preprocess with graph based decomposition system
JerryChen97
commented
Sep 17, 2025
PietropaoloFrisoni
approved these changes
Sep 17, 2025
JerryChen97
commented
Sep 17, 2025
astralcai
approved these changes
Sep 18, 2025
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.
Context:
Previously, the
default.tensordevice did not integrate with the new graph-based decomposition system introduced in PennyLane. This system allows for more intelligent circuit compilation by selecting the best decomposition strategy based on available hardware resources (e.g., choosing a gate implementation that doesn't require extra "work" wires if the device has none to spare). This PR updates the device's preprocessing pipeline to leverage this new, more efficient decomposition logic.Description of the Change:
default_tensor.pyto correctly configure and include the graph decomposition transform in its preprocessing pipeline. This involves passing necessary device information, likedevice_wiresandtarget_gates, to thedecomposefunction.TestPreprocessingTransforms, to validate the structure and behavior of the updated preprocessing pipeline. These tests ensure that:decomposetransform is correctly included in the pipeline.device_wiresandtarget_gates.@pytest.mark.usefixtures("enable_and_disable_graph_decomp")fixture, ensuring they run with both the old and new decomposition methods for backward compatibility and robustness.Benefits:
Possible Drawbacks:
Related GitHub Issues:
[sc-97955] [sc-97952]