Skip to content

Improve MCMT synthesis for XGate base gate #14754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

patelvyom
Copy link
Contributor

@patelvyom patelvyom commented Jul 18, 2025

This PR optimises the synthesis of multi-controlled multi-target (MCMT) gates when the base_gate is XGate(). The current implementation uses a generic V-chain construction, which is suboptimal for this case. We replace it with a more efficient decomposition:

A comparison plot is included below, showing that the proposed method achieves savings of hundreds to thousands of CX gates, depending on the circuit size. Here, MCMTX is the proposed decomposition.

image

Tagging @ShellyGarion and @alexanderivrii based on past discussions around MCX gates.

@patelvyom patelvyom requested a review from a team as a code owner July 18, 2025 04:45
@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jul 18, 2025
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the following people are relevant to this code:

  • @Cryoris
  • @Qiskit/terra-core
  • @ajavadia

@coveralls
Copy link

coveralls commented Jul 18, 2025

Pull Request Test Coverage Report for Build 16501202274

Details

  • 26 of 27 (96.3%) changed or added relevant lines in 3 files are covered.
  • 15 unchanged lines in 4 files lost coverage.
  • Overall coverage increased (+0.009%) to 87.76%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/transpiler/passes/synthesis/hls_plugins.py 10 11 90.91%
Files with Coverage Reduction New Missed Lines %
crates/circuit/src/symbol_expr.rs 1 73.94%
crates/qasm2/src/expr.rs 1 93.63%
crates/qasm2/src/parse.rs 6 97.56%
crates/qasm2/src/lex.rs 7 92.01%
Totals Coverage Status
Change from base Build 16481559458: 0.009%
Covered Lines: 81520
Relevant Lines: 92890

💛 - Coveralls

Copy link
Member

@ShellyGarion ShellyGarion left a comment

Choose a reason for hiding this comment

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

Thank you @patelvyom for another high-quality and important contribution to qiskit!
I wonder if there is some specific use-case of MCMT-X gate?
I also have a few comments on the docs and the tests. Release notes are also needed.

@patelvyom
Copy link
Contributor Author

Re: Uses of MCMTX gate:

  • The primary motivation is in its use in a controlled version of classical-quantum adder (I plan to add a PR soon).
  • I will add a PR for new fixed adder gate (that has Clifford + T decomposition). There exists an efficient controlled version of this adder that uses the MCMTX gate. This should improve gate counts in Improve Clifford+T synthesis for MultiplierGate #14682.

Copy link
Member

@ShellyGarion ShellyGarion left a comment

Choose a reason for hiding this comment

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

LGTM. I think that there are only some lint and indentation errors to fix.
Thanks!

Copy link
Member

@ShellyGarion ShellyGarion left a comment

Choose a reason for hiding this comment

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

I have a few minor comments on the docs. Other than that, I think it's ready to go :)

Copy link
Member

@ShellyGarion ShellyGarion left a comment

Choose a reason for hiding this comment

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

@patelvyom - thanks for another nice contribution to qiskit! I hope that it will also be useful for other arithmetic circuits.

@Cryoris - do you have any further comments?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community PR PRs from contributors that are not 'members' of the Qiskit repo synthesis
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants