Skip to content

Comments

Implement qompiler#55

Merged
masa10-f merged 52 commits intomasterfrom
qompiler
Jun 25, 2025
Merged

Implement qompiler#55
masa10-f merged 52 commits intomasterfrom
qompiler

Conversation

@masa10-f
Copy link
Collaborator

@masa10-f masa10-f commented Jun 6, 2025

Before submitting, please check the following:

  • Make sure you have tests for the new code and that test passes (run pytest)
  • If applicable, add a line to the [unreleased] part of CHANGELOG.md, following keep-a-changelog.
  • Format added code by ruff
  • Type checking by mypy and pyright
  • Make sure the checks (github actions) pass.
  • Check that the docs compile without errors (run make html in ./docs/ - you may need to install dependency for sphinx docs, see docs/requirements.txt.)

Then, please fill in below:

Context (if applicable):

Description of the change:

Implemented

  • Pauli frame, tracking applied Pauli byproduct so that feedforward can be clearly managed.
  • Qompiler modules, which convert graph+flowlike into a pattern with Pauli frame

Chnaged

  • I have removed feedforward instructions from M, X, and Z commands. Now, it is completely managed in Pauli frame.

Related issue:

@masa10-f masa10-f mentioned this pull request May 12, 2025
@masa10-f masa10-f marked this pull request as ready for review June 24, 2025 16:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new “qompiler” module and Pauli frame tracking to compile graph-state circuits into MBQC patterns, refactors command objects, and updates documentation/configuration.

  • Add qompiler.py and pauli_frame.py to initialize and track Pauli frames during pattern compilation.
  • Extend Pattern to carry a PauliFrame and update qompile* routines accordingly.
  • Remove classical-bit control fields from M, X, and Z commands and update their __str__ representations; update docs, examples, and project config.

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/test_pattern.py Removed existing pattern tests—new tests needed for Pattern.pauli_frame and qompiler
pyproject.toml Added an “D” entry under examples; verify correctness
graphix_zx/qompiler.py New qompiler implementation; compiles graph states into Pattern
graphix_zx/pauli_frame.py New PauliFrame class to track byproduct corrections
graphix_zx/pattern.py Extended Pattern dataclass to include pauli_frame
graphix_zx/command.py Removed s_cbit/t_cbit fields from commands; updated __str__
graphix_zx/focus_flow.py Reversed topo_order in place
examples/pattern_generation.py New example showing qompile_from_flow usage
docs/source/*.rst Added/removed references for qompiler and pauli_frame modules
docs/requirements.txt Added matplotlib
Comments suppressed due to low confidence (5)

graphix_zx/command.py:69

  • Removing s_cbit/t_cbit from M, X, and Z commands is a breaking API change; consider updating the changelog and bumping the major version to signal this change to downstream users.
    """

graphix_zx/qompiler.py:196

  • This comment mentions removing local Clifford commands, but no such logic is present. Please either implement the removal or update/delete the comment to accurately reflect the current behavior.
    # NOTE: currently, we remove local Clifford commands

pyproject.toml:76

  • [nitpick] The entry "D" under examples/*.py looks incomplete or missing a file extension. Verify that this matches an actual example file or remove it to avoid confusion.
  "D",

graphix_zx/focus_flow.py:107

  • [nitpick] This in-place list.reverse() differs from the reversed() calls used in other modules. Consider unifying the approach for clarity and consistency across the codebase.
    topo_order.reverse()  # children first

@masa10-f masa10-f requested a review from EarlMilktea June 25, 2025 04:39
@d1ssk
Copy link
Collaborator

d1ssk commented Jun 25, 2025

Putting fault tolerance aside for now and focusing only on MBQC, I believe the branching between a2b_dag and a_flip (where a, b = x or z) is redundant. If we have four types of a2b_dag, then the measurement plane information is already encoded, so a single flip function should suffice, applying the flip operation to the target of any a2b_dag. Conversely, if we separate x_flip and z_flip, then the measurement plane is already being referenced when deciding which one to execute, so there's no need to have four versions of dag—two (for 2b_dag) should be enough.

@d1ssk
Copy link
Collaborator

d1ssk commented Jun 25, 2025

As shown in the example, when the gflow is passed directly as an argument to qompile, there can be nodes whose xflow acts on themselves. However, those are not being properly excluded from the X correction DAG.

@masa10-f
Copy link
Collaborator Author

@d1ssk

  1. DAGs in PauliFrame
    As we discussed today, the current implementation is insufficient for a fault-tolerant one, although it's enough for the feedforward in MBQC. I noticed that xflow and zflow with meas_flip method are sufficient in the conventional case, as in 488716b. Anyway, we should consider how to deal with decoder output in FT regime.

  2. self-loop in xflow
    In 18c98ae, I allowed self-loops both in xflow and zflow because the formal definition of generalized flow does so. In PauliFrame, self-loop is not a problem because it's not a physical operation. For consistency in runtime, I will flip the Pauli frame if the measurement outcome is -1, so that self-loop correction will cancel it out.

@masa10-f
Copy link
Collaborator Author

@d1ssk Could you quickly review again? If there's no problem, please approve this PR.

@d1ssk
Copy link
Collaborator

d1ssk commented Jun 25, 2025

Looks good!

@masa10-f masa10-f merged commit 7d24b10 into master Jun 25, 2025
20 checks passed
@masa10-f masa10-f deleted the qompiler branch June 25, 2025 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants