Layout is bijective dict only, transpile accomodates list and dict #2157
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2032
The Layout class now only has a constructor from dict, and this dict must be bijective.
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]
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).