Skip to content

Conversation

Takishima
Copy link
Collaborator

This supersedes #324.

This implementation of a mapper for arbitrary graphs relies on storing the gates in a directed acyclic graph and then generating the swap operations in order to maximise the number of 2-qubit gates that can be applied simultaneously, while ensuring a minimal number of swaps.

Example of a use-case:

import networkx as nx
from projectq.cengines import GraphMapper

# Example of a 3x3 grid graph
mygraph = nx.Graph()
# Add horizontal edges
mygraph.add_edges_from((0, 1), (1, 2),  (3, 4), (4, 5),  (6, 7), (7, 8))
# Add vertical edges
mygraph.add_edges_from((0, 3), (3, 6),   (1, 4), (4, 7),  (2, 5), (5, 8))

mapper = GraphMapper(graph=mygraph)

# use as any other mapper

_graphmapper.py: minor updates
This new implementation is largely based on the SABRE algorithm [1].
Essentially, use cost functions to plan the next list of SWAP operations.

[1] https://arxiv.org/abs/1809.02573v2
TODO: rename the class and its associated file
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.

1 participant