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

Transpiler pass for converting c_if to if_test #8601

Closed
jakelishman opened this issue Aug 23, 2022 · 0 comments · Fixed by #8764
Closed

Transpiler pass for converting c_if to if_test #8601

jakelishman opened this issue Aug 23, 2022 · 0 comments · Fixed by #8764
Assignees
Labels
type: feature request New feature or request

Comments

@jakelishman
Copy link
Member

What should we add?

As developers, we want to transition away from Instruction.condition (via the Instruction{,Set}.c_if methods) to remove unnecessary state from Instruction subclasses. Part of the backwards compatibility for this support can be a transpiler pass that converts instructions with non-None conditions to instances IfElseBlock.

This has two main benefits as a temporary measure:

  • we will have a path for converting old-style Instruction instances within the transpiler, without immediately needing to change the behaviour of Instruction.c_if, which is very hard to do within the deprecation policy.
  • the dynamic-circuits paths in the IBM provider prefer to have conditionals in this form, in order to more easily apply dynamic decoupling against blocks of instructions.

The first point is the justification for why this is useful to be in Terra (albeit not yet in the preset pass managers - the rest of the support for IfElseBlock is too shallow right now), and the second point is why we want this sooner rather than later.

Potential further work: complex conditionals (e.g. custom_gate.c_if()) are likely to be expanded by the basis translator into many conditional gates all with the same condition. Ideally these would be transformed by this pass before basis translation so that they all appear in the same IfElseBlock, but right now the support for the control-flow operations in the rest of the transpiler (especially routing) is still being worked on. One could have a separate classical optimisation pass that runs during optimisation that collects runs of conditionals on the same condition into a single IfElseBlock. This might be moving Terra too far in the direction of classical optimisation, however, and may be better suited for other libraries.

cc: @taalexander.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant