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

It should be easier to modify pass managers. #2179

Closed
nonhermitian opened this issue Apr 23, 2019 · 1 comment · Fixed by #3004
Closed

It should be easier to modify pass managers. #2179

nonhermitian opened this issue Apr 23, 2019 · 1 comment · Fixed by #3004
Assignees
Labels
status: pending PR It has one or more PRs pending to solve this issue type: enhancement It's working, but needs polishing
Milestone

Comments

@nonhermitian
Copy link
Contributor

What is the expected enhancement?

Currently, if you want to use a default pass manager with only a single pass changed, e.g. for example the swap mapper changed, you need to go and create a whole new pass manager. It should be possible to simply replace one pass in a pass manger with another. Something like:

pm = default_pass_manager()
pm.replace(6, LookaheadSwap) # where 6 is the index of the pass in the pm

An index is used here since you could have multiple passes of the same type. It would also be nice to be able to slice a pm and get a new pm, e.g. pm2 = pm[:5] which would save people from having to rewrite things like this:

pass_manager = PassManager()
pass_manager.property_set['layout'] = initial_layout
pass_manager.append(Unroller(basis_gates))
pass_manager.append(TrivialLayout(coupling_map),
                        condition=lambda property_set: not property_set['layout'])
pass_manager.append(CheckMap(coupling_map))
pass_manager.append(DenseLayout(coupling_map),
                        condition=lambda property_set: not property_set['is_swap_mapped'])
pass_manager.append(FullAncillaAllocation(coupling_map))
pass_manager.append(EnlargeWithAncilla())
@jaygambetta
Copy link
Member

jaygambetta commented May 5, 2019

I agree.

I also think I should be able to draw a pass manager

pm.draw()

and it make a flow diagram of all the passes I have in my pass manager with the inputs going into them

@1ucian0 1ucian0 self-assigned this Jul 6, 2019
@1ucian0 1ucian0 added this to the 0.10 milestone Aug 9, 2019
@1ucian0 1ucian0 added the status: pending PR It has one or more PRs pending to solve this issue label Aug 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: pending PR It has one or more PRs pending to solve this issue type: enhancement It's working, but needs polishing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants