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 new get_control_flow_name_mapping function #13472

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

Conversation

ElePT
Copy link
Contributor

@ElePT ElePT commented Nov 21, 2024

Summary

Addresses #13468 by exposing the mapping done in generate_preset_pass_manager as a public function for convenience.

Details and comments

@ElePT ElePT requested a review from a team as a code owner November 21, 2024 11:07
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core

@ElePT ElePT linked an issue Nov 21, 2024 that may be closed by this pull request
@ElePT ElePT added this to the 2.0.0 milestone Nov 21, 2024
@ElePT ElePT added the Changelog: New Feature Include in the "Added" section of the changelog label Nov 21, 2024
@coveralls
Copy link

coveralls commented Nov 21, 2024

Pull Request Test Coverage Report for Build 11976548054

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 7 of 7 (100.0%) changed or added relevant lines in 3 files are covered.
  • 29 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.03%) to 88.919%

Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/two_qubit_decompose.rs 1 92.13%
crates/qasm2/src/lex.rs 4 91.48%
crates/qasm2/src/parse.rs 24 96.23%
Totals Coverage Status
Change from base Build 11944955850: -0.03%
Covered Lines: 79391
Relevant Lines: 89285

💛 - Coveralls

@wshanks
Copy link
Contributor

wshanks commented Nov 22, 2024

The way this is implemented matches how it has been used so I think it is good. One point that we should note at least is that the standard gate version of this function returns a mapping to gate instances while the control flow function here returns a mapping to classes. The gates version gets away with this by using Parameters to fill in the gate parameters, but I don't think there are reasonable equivalents for the conditions and bodies of the conditionals (could use size 1 registers and empty circuits but it seems weird).

By the way, you can also replace this case:

qiskit_control_flow_mapping = {
"if_else": IfElseOp,
"while_loop": WhileLoopOp,
"for_loop": ForLoopOp,
"switch_case": SwitchCaseOp,
}

@ElePT ElePT requested a review from jyu00 as a code owner November 22, 2024 16:39
@ElePT
Copy link
Contributor Author

ElePT commented Nov 22, 2024

Thanks @wshanks! I applied your suggestion in 5434583. you're right, the function doesn't match the gate version exactly, but I also didn't find any reasonable way to instantiate the gates, and tried to avoid making the parallelism in the docs for that reason. There is a risk that users might still associate them but well... we could always highlight the difference in documentation if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Equivalent to get_standard_gate_name_mapping for control-flow ops
5 participants