Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #445 +/- ##
==========================================
- Coverage 88.29% 88.00% -0.29%
==========================================
Files 44 46 +2
Lines 6533 6721 +188
==========================================
+ Hits 5768 5915 +147
- Misses 765 806 +41 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
graphix/circ_ext/extraction.py
Outdated
| for edge in combinations(c_set, 2): | ||
| negative_sign ^= edge in og.graph.edges() |
There was a problem hiding this comment.
The following code is a bit simpler and faster if the graph is sparse (but slower if the graph is dense; however, it would be much faster in any case if we used rustworkx!):
| for edge in combinations(c_set, 2): | |
| negative_sign ^= edge in og.graph.edges() | |
| negative_sign ^= graph.subgraph(c_set).number_of_edges() % 2 == 1 |
There was a problem hiding this comment.
Nice, thanks. Done in f99c285. Do you suggest moving to rustworks (adding this to the backlog)?
|
Hi @thierry-martinez, thanks for the review. I addressed all your comments, the corresponding modifications in the stim plugin are in commit matulni/graphix-stim-compiler@843601c. I think it's ready for another round! |
This PR introduces functionality to perform the circuit extraction algorithm presented in Ref. [1] which allows to extract a circuit without ancillas from a strongly deterministic pattern.
Context
The main result of the paper is a procedure to perform the transformation
where$U_{\mathcal{P}}$ is the isometry implemented by the pattern $\mathcal{P}$ (a unitary when the pattern has the same number of inputs and outputs), $C$ is a Clifford map, and $V(\mathbf{\theta})$ is an ordered product of Pauli exponentials.
The structure of the extraction process reads as follows:
flowchart LR n0["Pattern"] n1["OpenGraph"] n2("Focused PauliFlow") subgraph s1["ExtractionResult"] s10("PauliExponentialDAG") s11("CliffordMap") end %% Junction node to merge arrows j1(( )) n3("Graphix circuit") n0 --> n1 n1 --> n2 n2 --> s10 n2 --> s11 %% Merging into the junction s10 --> j1 s11 --> j1 j1 --> n3 %% Styling the junction to be small style j1 fill:#000,stroke-width:0px,width:10pxThe transformation$O(N^3)$ Pauli-flow extraction algorithm in Ref. [2] always returns focused Pauli flows, contrary to the $O(N^5)$ version in Ref. [1] which requires an additional post-processing to focus the correction function.
Pattern->OpenGraph->Focused PauliFlowalready exists in the current implementation of Graphix. TheExtractionResultis the output of the algorithm which is denoted "PdDAG" in [1]. In particular:PauliExponentialDAGis a mapping between measured nodes in the open graph and Pauli exponentials, and a partial order between the measured node (the flow's partial order). Pauli exponentials are a pair of anAngle(the node's measurement angle) and aPauliStringacting on the output nodes of the open graph. The corresponding Pauli string is obtained from the focused flow's correction function.Clifford Mapdescribes a linear transformation between the space of input qubits and the space of output qubits. It is encoded as a map from the Pauli-group generators (The$Z$ -map is also obtained from the focused flow's correction function. The $X$ -map is obtained from the focused flow's correction function of the extended open graph (see Def. C.3 in [1]).
Summary of changes
Added the following to
graphix.flow.core.PauliFlow:is_focused: (method) Verifies if a Pauli flow is focused according to definition 4.3 in Ref. [1].extract_circuit: (method) Returns aExtractionResultobject.pauli_strings: (cached_property) Associates a Pauli string to every corrected node in the flow's correction function.Added new module
graphix.circ_ext.extractionFocused PauliFlow->ExtractionResult.ExtractionResultPauliStringPauliExponentialPauliExponentialDAGCliffordMapAdded new module
graphix.circ_ext.compilationExtractionResult->Graphix circuit.PauliExponentialDAG->Graphix circuitis done with the naive "star" construction (see [3]).CliffordMap->Graphix circuitrelies onstimand currently only supports unitaries (i.e., patterns with the same number of inputa and outputs). To avoid introducing a dependency onstim, theStimCliffordPassis implemented in the external plugingraphix-stim-compiler. This compilation pass together with the tooling introduced in this PR allow to do a round-trip conversion circuit -> MBQC pattern -> circuit.We note that all the transformations in the figure work with parametric objects as well.
References
[1] Simmons, 2021, arXiv:2109.05654.
[2] Mitosek and Backens, 2024, arXiv:2410.23439.
[3] https://quantumcomputing.stackexchange.com/questions/5567/circuit-construction-for-hamiltonian-simulation/11373#11373