Skip to content
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

Add ContractIdleWiresInControlFlow to default pipelines #13891

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

Conversation

jakelishman
Copy link
Member

Summary

This is cheap, and can be done both in the init stage (where it may help routing) and the the general optimisation loop (where it may allow chains of optimisations to collapse).

Details and comments

Built on top of #13779.

This transpiler pass removes data dependencies on idle qubits from
control-flow operations.  For example, given a circuit such as::

    from qiskit.circuit import QuantumCircuit

    qc = QuantumCircuit(1, 1)
    qc.x(0)
    with qc.if_test((qc.clbits[0], True)):
        qc.x(0)
        qc.x(0)
    qc.x(0)

the current optimisation passes will collapse the inner control-flow
block to the identity, but the qubit dependency will remain, preventing
the outer two X gates from being cancelled.  This pass removes the
now-spurious dependency, making it possible to detect and remove the two
X gates in a follow-up loop iteration.

As an accidental side-effect of their algorithms, the control-flow-aware
routing passes currently do this when they run.  This aims to move the
logic into a suitable place to run before routing (so the spurious
dependency never arises in routing in the first place) and in the
low-level optimisation stage.

The aim of this pass is also to centralise the logic, so when the
addition of the new `box` scope with different semantics around whether
a wire is truly idle in the box or not, the routers aren't accidentally
breaking them, and it's clearer when the modifications happen.
This is cheap, and can be done both in the `init` stage (where it may
help routing) and the the general optimisation loop (where it may allow
chains of optimisations to collapse).
@jakelishman jakelishman added the mod: transpiler Issues and PRs related to Transpiler label Feb 19, 2025
@jakelishman jakelishman added this to the 2.0.0 milestone Feb 19, 2025
@jakelishman jakelishman requested a review from a team as a code owner February 19, 2025 18:11
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core

@jakelishman jakelishman added the on hold Can not fix yet label Feb 19, 2025
@jakelishman jakelishman self-assigned this Feb 19, 2025
@coveralls
Copy link

Pull Request Test Coverage Report for Build 13419423905

Details

  • 49 of 49 (100.0%) changed or added relevant lines in 1 file are covered.
  • 15 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.003%) to 88.104%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 3 92.48%
crates/qasm2/src/parse.rs 12 97.15%
Totals Coverage Status
Change from base Build 13411473274: 0.003%
Covered Lines: 78394
Relevant Lines: 88979

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mod: transpiler Issues and PRs related to Transpiler on hold Can not fix yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants