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

LayoutTransformation when coupling_map=None #5281

Merged
merged 8 commits into from
Nov 25, 2020

Conversation

1ucian0
Copy link
Member

@1ucian0 1ucian0 commented Oct 23, 2020

LayoutTransformation raise an exception when coupling_map=None. Routing methods consider a fully connected topology when coupling_map=None. Extending that to this pass.

Additionally, it moves away from deprecated dag.compose(..., edge_map=...)

@1ucian0 1ucian0 requested a review from a team as a code owner October 23, 2020 03:15
Copy link
Member

@kdk kdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, this is the first case where the fact that coupling_map=None implies a fully connected topology is encoded into the behavior of a pass. Normally, it's encoded by the construction of the PassManager by omitting any layout or routing steps. Is there a case where that's not sufficient for LayoutTransformation (or are there other passes that should be similarly updated)?

@1ucian0
Copy link
Member Author

1ucian0 commented Nov 24, 2020

As far as I know, this is the first case where the fact that coupling_map=None implies a fully connected topology is encoded into the behavior of a pass. Normally, it's encoded by the construction of the PassManager by omitting any layout or routing steps.

Kinda. The PassManager skips embedding fully if no coupling map. That something we want to change here: #5346

Is there a case where that's not sufficient for LayoutTransformation (or are there other passes that should be similarly updated)?

In #5280 when #5346

@kdk kdk added the automerge label Nov 25, 2020
@mergify mergify bot merged commit aa472c8 into Qiskit:master Nov 25, 2020
@1ucian0 1ucian0 deleted the LayoutTransformation_cp_none branch November 26, 2020 00:19
mtreinish added a commit to mtreinish/qiskit-core that referenced this pull request Nov 30, 2020
In Qiskit#5281 the layout transformation pass was updated to handle the case
where the coupling map was not defined. In those cases for the purposes
of the layout transformation it treats the coupling map as being fully
connected. So it creates a new full coupling map to use for the token
swapper. However, it neglects that the token swapper expects an
undirected graph and was passing in a directed graph. This didn't matter
too much for the networkx based coupling map object because networkx can
handle directed or undirected in the same function. But, for retworkx
directed graphs and undirected graphs are different types an can't be
used interchangeably. This commit fixes this issue in that pass.
mergify bot added a commit that referenced this pull request Dec 4, 2020
* WIP: Use retworkx for CouplingMap

This commit migrates Terra's CouplingMap class to us retworkx internally
instead of networkx providing >10x speed improvement for CouplingMap
operations.

Requires:

Qiskit/rustworkx#157
Qiskit/rustworkx#156
Qiskit/rustworkx#144
Qiskit/rustworkx#143
Qiskit/rustworkx#147
Qiskit/rustworkx#158
Qiskit/rustworkx#162
Qiskit/rustworkx#161

all be applied to the retworkx version installed.

* DNM: Install retworkx from source

* DNM: Add retworkx custom branch to travis

* Fix draw() copy paste error

* Fix typo

* DNK: Add source retworkx to docs build

* Fix lint

* Use graph_distance_matrix instead of floyd warshall

* DNM also add retworkx from source for image test job

* Use Gnm random function from retworkx in token swapper tests

* Remove nx import from token swapper tests

* Fix lint

* Remove install from git from CI config since retworkx 0.6.0 is released

* Fix api call

* Use retworkx generators where possible for constructors

* Remvoe source install from travis config

* Bump version in setup.py too

* Use extend_from_edge_list for from_full

* Update qiskit/transpiler/coupling.py

* Use edge_list() return and has_edge() in sabre

In Qiskit/rustworkx#204 the return type of the edge_list() method will be
returned as a custom sequence type the defer the type conversion from rust
to python. So casting to a list no longer will be a no-op after that point
so this commit removes the cast. At the same time in the sabre swap pass
one of the bottlenecks at large qubit counts is traversing that edge
list looking for edges, this updates that to use the has_edge() method
which should be faster than a full list traversal every iteration.

* Fix issue in layout_transformation pass

In #5281 the layout transformation pass was updated to handle the case
where the coupling map was not defined. In those cases for the purposes
of the layout transformation it treats the coupling map as being fully
connected. So it creates a new full coupling map to use for the token
swapper. However, it neglects that the token swapper expects an
undirected graph and was passing in a directed graph. This didn't matter
too much for the networkx based coupling map object because networkx can
handle directed or undirected in the same function. But, for retworkx
directed graphs and undirected graphs are different types an can't be
used interchangeably. This commit fixes this issue in that pass.

* Update qiskit/transpiler/passes/routing/algorithms/token_swapper.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Fix Lint

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Kevin Krsulich <kevin.krsulich@ibm.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants