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

Layout is bijective dict only, transpile accomodates list and dict #2157

Merged
merged 6 commits into from
Apr 22, 2019

Conversation

ajavadia
Copy link
Member

@ajavadia ajavadia commented Apr 19, 2019

Summary

Fixes #2032

  1. The Layout class now only has a constructor from dict, and this dict must be bijective.

  2. For user convenience, transpile() accepts this dict in addition to a list (so the following scenarios are supported):

a) running a single qubit experiment on qubit 19
i. virtual2physical dict
{qr[0]: 19}
ii. physical2virtual dict
{19: qr[0]}
iii. v2p list
[None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, qr[0]]
iv. p2v list
[19]

b) Bell pair on 2 qubits out of 5
i. v2p dict
{qr[0]: 0, qr[1]: 3}
ii. p2v dict
{0: qr[0], 3: qr[1]}
iii. v2p list
[qr[0], None, None, qr[1], None]
iv. p2v list
[0, 3]

  1. Previously non-bijectivity was (ab)used for ancilla allocation: first create a bunch of None entries in the Layout, then allocate ancilla for those. I have changed the two passes that did this.
    We now have:
  • FullAncillaAllocation, a pass that examines a DAG, a layout and a coupling_map, to see whether there are free physical qubits. If so, it allocates all those physical qubits as ancillas, AND updates the layout with new (physical, virtual) pairs.
  • ExtendWithAncilla, a pass that examines a DAG and a layout, and if the layout contains entries that are not in the DAG, updates the dag accordingly (adds new virtual qubits to the circuit, to act as ancilla).

@ajavadia ajavadia force-pushed the layout-constructor branch from dd09c65 to 5ae9e86 Compare April 22, 2019 04:40
@ajavadia ajavadia added the API affects user-facing API change label Apr 22, 2019
@1ucian0 1ucian0 merged commit 0f1a771 into Qiskit:master Apr 22, 2019
lia-approves pushed a commit to edasgupta/qiskit-terra that referenced this pull request Jul 30, 2019
…iskit#2157)

* update Layout constructor methods

* allow transpile to take list and dict and Layout as initial_layout

* update pickles

* changelog

* switch to FullAncillaAllocation and EnlargeWithAncilla passes

* update layout docstring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API affects user-facing API change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Layout documentation needs to be updated
2 participants