Add methods XZCorrections to CausalFlow and GFlow#505
Open
matulni wants to merge 8 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #505 +/- ##
==========================================
- Coverage 89.65% 89.58% -0.07%
==========================================
Files 48 48
Lines 7015 7001 -14
==========================================
- Hits 6289 6272 -17
- Misses 726 729 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
thierry-martinez
approved these changes
May 12, 2026
Collaborator
thierry-martinez
left a comment
There was a problem hiding this comment.
LGTM! Just one minor remark.
Comment on lines
+1509
to
+1514
| xz_corrections = self.extract_xzcorrections() | ||
| try: | ||
| flow = pattern_std.extract_causal_flow() | ||
| except FlowError: | ||
| flow = xz_corrections.downcast_bloch().to_causal_flow() | ||
| except (FlowError, TypeError): | ||
| try: | ||
| flow = pattern_std.extract_gflow() | ||
| flow = xz_corrections.downcast_bloch().to_gflow() |
Collaborator
There was a problem hiding this comment.
downcast_bloch could be called just one time.
Contributor
Author
There was a problem hiding this comment.
Thanks for the quick review!
Suggestion implemented in 0ddcb03
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
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.
This commit introduces two new methods
XZCorrections.to_causal_flowandXZCorrections.to_gflowwhich subsumeStandardizedPattern.extract_causal_flowandStandardizedPattern.extract_gflow. The latter are removed.Methods
Pattern.extract_causal_flowandPattern.extract_gflownow proceed by extracting the xz-corrections and performing the conversion to flow of these objects.The flow extraction routines becomes significantly clearer, and the API is now closer to MBQC theory. The performance regression is negligible: on a open graph with 5188 nodes (extracted from a random circuit), pattern to gflow conversion takes 0.029s after the new commit vs 0.027s before. For comparison, extracting the gflow on the underlying open graph with the$O(N^3)$ algorithm takes 1.731s
Additionally, to comply with mypy new methods
XZCorrections.to_blochandXZCorrections.downcast_blochare added.These changes help making issue #432 more concrete.