Skip to content

Add DAGCircuit method to replace block of nodes with another set of nodes#9863

Open
ewinston wants to merge 1 commit intoQiskit:mainfrom
ewinston:replace_block_with_block
Open

Add DAGCircuit method to replace block of nodes with another set of nodes#9863
ewinston wants to merge 1 commit intoQiskit:mainfrom
ewinston:replace_block_with_block

Conversation

@ewinston
Copy link
Copy Markdown
Contributor

Summary

When optimizing circuits one often knows a transformation of a subcircuit into a more desirable form. If the initial subcircuit is listed as a set of nodes of a DAGCircuit this can be replaced by another set of nodes.

Details and comments

This works by using DAGCirucit.replace_block_with_op and then DAGCircuit.substitute_node_with_dag to apply the transformation.

@ewinston ewinston requested a review from a team as a code owner March 28, 2023 15:52
@qiskit-bot
Copy link
Copy Markdown
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 the following people are requested to review this:

  • @Qiskit/terra-core

@mtreinish
Copy link
Copy Markdown
Member

mtreinish commented Mar 28, 2023

I did push up a PR to rustworkx to add a native method for doing this based on our earlier discussion: Qiskit/rustworkx#823 when that is merged and in a rustworkx release we can update the internals of this DAGCircuit method to use it.

@ewinston
Copy link
Copy Markdown
Contributor Author

Thanks @mtreinish! I didn't see that. I can update the PR after it merges.

@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 4545100440

  • 25 of 26 (96.15%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.02%) to 85.358%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/dagcircuit/dagcircuit.py 25 26 96.15%
Totals Coverage Status
Change from base Build 4544978078: -0.02%
Covered Lines: 67133
Relevant Lines: 78649

💛 - Coveralls

@mtreinish mtreinish added Changelog: Added Add an "Added" entry in the GitHub Release changelog. mod: transpiler Issues and PRs related to Transpiler labels Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog: Added Add an "Added" entry in the GitHub Release changelog. mod: transpiler Issues and PRs related to Transpiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants