graphix icon indicating copy to clipboard operation
graphix copied to clipboard

Refactoring the transpiler for a more principled implementation

Open thierry-martinez opened this issue 1 year ago • 2 comments

In the seminal paper The Measurement Calculus (Danos, Kashefi, Panangaden, 2007), the transpilation from circuits to MBQC patterns leverages the universality of 𝔍(α) and ∧Z. For instance, the rotation gate Ry(α) is decomposable as Ry(α) = e^{-iα/2} 𝔍(0) 𝔍(π/2) 𝔍(α) 𝔍(-π/2). By using the decomposition 𝔍(α) = X_j^{s_i} M_i^{-α} E_{ij} N_j, we can systematically derive the following pattern for Ry(α).

X_5^{s_4} M_4^0 E_{45} N_5 X_4^{s_3} M_3^{-π/2} E_{34} N_4 X_3^{s_2} M_2^{-α} E_{23} N_3 X_2^{s_1} M_1^{π/2} E_{12} N_2

This pattern can then be standardized and optimized for space efficiency among other criteria. After standardization, the pattern correction sets are always consistent with a flow and a gflow (as computed by gflow.flow_from_pattern), which is not the case for the patterns currently generated by the transpiler. See the following discussion:

  • https://github.com/TeamGraphix/graphix/pull/119#issuecomment-1971104090

We propose to simplify the transpile.py implementation by structuring the transpilation process into three distinct phases:

  1. Transpile the circuit into a sequence of 𝔍(α) and ∧Z;

  2. Convert the sequence of 𝔍(α) and ∧Z into a pattern, using the systematic decomposition

    • 𝔍(α) = X_j^{s_i} M_i^{-α} E_{ij} N_j
    • ∧Z = E_{ij};
  3. Optimize the pattern according to the desired criteria (standardization, optimization for space, etc.).

We hope the resulting implementation will be easier to follow, closer to the literature, and more straightforward to verify. Decomposing the transpiling and optimization phases can be useful for the user to check the translation, to visualize the flow with consistent pattern corrections and to customize the optimization criteria.

thierry-martinez avatar May 07 '24 11:05 thierry-martinez

Hey, I'd like to become a contributor of the quantum computing community. Can I help you guys work on this? This would be my first time working on an open source project. I have programming experience, and I'm familiar with quantum concepts. I have also built simple quantum circuits before. Let me know what you think. In the meantime, I'm going to read that paper.

lreynax24 avatar May 12 '24 15:05 lreynax24

Hey, I'd like to become a contributor of the quantum computing community. Can I help you guys work on this? This would be my first time working on an open source project. I have programming experience, and I'm familiar with quantum concepts. I have also built simple quantum circuits before. Let me know what you think. In the meantime, I'm going to read that paper.

Hi! thanks for your interest. It would be best to review contribution guide, and this page has good information about contributing to open source quantum projects.

Just to clarify regarding the unitaryhack - we cannot guarantee this issue be part of it ('bountied') until the hack starts, so I recommend waiting until 29th of May.

shinich1 avatar May 16 '24 20:05 shinich1