Skip to content

Conversation

@multiphaseCFD
Copy link
Member

@multiphaseCFD multiphaseCFD commented Nov 10, 2025

Before submitting

Please complete the following checklist when submitting a PR:

  • All new features must include a unit test.
    If you've fixed a bug or added code that should be tested, add a test to the
    test directory!

  • All new functions and code must be clearly commented and documented.
    If you do make documentation changes, make sure that the docs build and
    render correctly by running make docs.

  • Ensure that the test suite passes, by running make test.

  • Add a new entry to the doc/releases/changelog-dev.md file, summarizing the
    change, and including a link back to the PR.

  • The PennyLane source code conforms to
    PEP8 standards.
    We check all of our code against Pylint.
    To lint modified files, simply pip install pylint, and then
    run pylint pennylane/path/to/file.py.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


Context:

[sc-103563]

The MBQC transform has been outlined in the subroutines in the convert_to_mbqc_formalism pass. This would reduce the number of lines in the IR if the circuit is unrolled.

A few other improvements/considerations:

  • Reduced the number of arith.ConstantOp used in defining the measurements.
  • The visibility of subroutines are set as private to work better with the symbol-dce pass defined in the catalyst pipeline. Note that current pass inserts subroutines for all gates in the MBQC gate set. This could be redundant if not all gates are applied in a given circuit. However, there is no need to worry about that since the symbol-dce pass would eliminate the unreferenced subroutine given that its visibility is private.
  • Note that those subroutines are attached with an attribute mbqc_transform. This attribute is used to skip the convert_to_mbqc_formalism transform for the subroutine (There are "Hadamard" gates in the subroutine, which we don't want to replace it with a subroutine call).
  • Note that IfOp in the subroutines could be hitted by the convert_to_mbqc_formalism transform. No need to worry for now as there are no gates in the MBQC gate set there.
  • Note that the order of parameters for the subroutine is aligned with the corresponding qml.operation.

Description of the Change:

Benefits:

Take the ncas = 10 (or 21 qubits) XAS circuit ( stateprep ignored), the number of lines of circuit.mlir is 26158, compared to 92185 for the master branch. The number of lines of _llvm.ir.ll is 213173, compared to 420280 for the master branch.

Possible Drawbacks:

Related GitHub Issues:

@multiphaseCFD multiphaseCFD changed the title Outline MBQC transform [WIP][Unified Compiler] Outline MBQC transform Nov 11, 2025
@multiphaseCFD multiphaseCFD marked this pull request as ready for review November 12, 2025 16:38
@multiphaseCFD multiphaseCFD changed the title [WIP][Unified Compiler] Outline MBQC transform [Unified Compiler] Outline MBQC transform Nov 12, 2025
@codecov
Copy link

codecov bot commented Nov 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.42%. Comparing base (015eb15) to head (2d62ffc).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8619      +/-   ##
==========================================
- Coverage   99.43%   99.42%   -0.01%     
==========================================
  Files         587      587              
  Lines       61967    61967              
==========================================
- Hits        61615    61613       -2     
- Misses        352      354       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@multiphaseCFD multiphaseCFD requested review from a team and sengthai November 12, 2025 17:00
@multiphaseCFD multiphaseCFD changed the title [Unified Compiler] Outline MBQC transform [FTQC][Unified Compiler] Outline MBQC transform Nov 12, 2025
Copy link
Contributor

@joeycarter joeycarter left a comment

Choose a reason for hiding this comment

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

This looks great, thanks @multiphaseCFD! 💯

I don't have much to add, just a few minor things.

Copy link
Member

@mlxd mlxd left a comment

Choose a reason for hiding this comment

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

Nice one @multiphaseCFD
Just wondering if we should merge this PR or #8632 first?

Happy to approve based on the answer.

Copy link
Contributor

@lillian542 lillian542 left a comment

Choose a reason for hiding this comment

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

Thanks, Shuli, this looks great! As well as the reduction in how many lines of IR we’re producing, it also feel his also makes both the IR and the xDSL pass source code easier to read.

I left a couple minor comments, nothing blocking. You may want to coordinate with Sengthai about his PR, I think one of you will have to solve merge conflicts 😅

@multiphaseCFD multiphaseCFD added this pull request to the merge queue Nov 13, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 13, 2025
@multiphaseCFD multiphaseCFD added this pull request to the merge queue Nov 13, 2025
Merged via the queue into master with commit bc4ea08 Nov 13, 2025
55 checks passed
@multiphaseCFD multiphaseCFD deleted the shuli/outline_mbqc_transform branch November 13, 2025 21:35
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.

5 participants