Skip to content

Commit

Permalink
Merge pull request #124 from JoelPasvolsky/refresh_embedding
Browse files Browse the repository at this point in the history
Update chimera
  • Loading branch information
arcondello committed Nov 23, 2018
2 parents 4d2a947 + c42bc0c commit 677ead5
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 35 deletions.
15 changes: 8 additions & 7 deletions docs/intro.rst
Expand Up @@ -86,13 +86,11 @@ information, see the :std:doc:`D-Wave System Documentation <sysdocs_gettingstart
Minor-Embedding
---------------

The D-Wave system is Chimera-structured.

The Chimera architecture comprises sets of connected unit cells, each with four
horizontal qubits connected to four vertical qubits via couplers (bipartite
connectivity). Unit cells are tiled vertically and horizontally with adjacent
qubits connected, creating a lattice of sparsely connected qubits. A unit cell
is typically rendered as either a cross or a column.
The D-Wave system is Chimera-structured. The Chimera architecture comprises sets of
connected unit cells, each with four horizontal qubits connected to four vertical qubits
via couplers (bipartite connectivity). Unit cells are tiled vertically and horizontally
with adjacent qubits connected, creating a lattice of sparsely connected qubits. A unit
cell is typically rendered as either a cross or a column.

.. figure:: _static/ChimeraUnitCell.png
:align: center
Expand All @@ -113,3 +111,6 @@ To solve an arbitrarily posed binary quadratic problem on a D-Wave system requir
called *minor embedding*, to a Chimera graph that represents the system's quantum processing unit.
This preprocessing can be done by a composed sampler consisting of the
:class:`~dwave.system.samplers.DWaveSampler()` and a composite that performs minor-embedding.

In addition to composites that handle minor-embedding, dwave-system provides the related
functionality described in :ref:`embedding`.
11 changes: 7 additions & 4 deletions docs/reference/embedding.rst
Expand Up @@ -4,13 +4,12 @@
Embedding
=========

.. automodule:: dwave.embedding

.. currentmodule:: dwave.embedding

MinorMiner
==========

:std:doc:`minorminer <minorminer:index>` is a heuristic tool for minor embedding: given a
minor and target graph, it tries to find a mapping that embeds the minor into the target.

.. autosummary::
:toctree: generated/

Expand All @@ -19,6 +18,10 @@ MinorMiner
Chimera
=======

Functionality for minor-embedding in :term:`Chimera`\ -structured target graphs.

.. currentmodule:: dwave.embedding

.. autosummary::
:toctree: generated/

Expand Down
61 changes: 37 additions & 24 deletions dwave/embedding/chimera.py
Expand Up @@ -24,13 +24,17 @@

@nx.utils.decorators.nodes_or_number(0)
def find_clique_embedding(k, m, n=None, t=None, target_edges=None):
"""Find an embedding for a clique.
"""Find an embedding for a clique in a Chimera graph.
Given a target :term:`Chimera` graph size, and a clique (fully connect graph),
attempts to find an embedding.
Args:
k (int/iterable):
If k is an integer, generates an embedding for a clique of size k labelled [0,k-1].
If k is an iterable, generates an embedding for a clique of size len(k) where k
provides the variable labels.
Clique to embed. If k is an integer, generates an embedding for a clique of size k
labelled [0,k-1].
If k is an iterable, generates an embedding for a clique of size len(k), where
iterable k is the variable labels.
m (int):
Number of rows in the Chimera lattice.
Expand All @@ -42,19 +46,22 @@ def find_clique_embedding(k, m, n=None, t=None, target_edges=None):
Size of the shore within each Chimera tile.
target_edges (iterable[edge]):
A list of edges in the target Chimera graph. Expects the nodes to be labelled as
A list of edges in the target Chimera graph. Nodes are labelled as
returned by :func:`~dwave_networkx.generators.chimera_graph`.
Returns:
dict: An embedding mapping a clique to the Chimera lattice.
Examples:
The first example finds an embedding for a :math:`K_4` complete graph in a single
Chimera unit cell. The second for an alphanumerically labeled :math:`K_3`
graph in 4 unit cells.
>>> from dwave.embedding.chimera import find_clique_embedding
...
>>> embedding = find_clique_embedding(3, m=2, n=2, t=4)
>>> embedding = find_clique_embedding(4, 1, 1)
>>> embedding # doctest: +SKIP
{0: [20, 16], 1: [21, 17], 2: [22, 18]}
{0: [4, 0], 1: [5, 1], 2: [6, 2], 3: [7, 3]}
>>> from dwave.embedding.chimera import find_clique_embedding
...
Expand All @@ -78,20 +85,23 @@ def find_clique_embedding(k, m, n=None, t=None, target_edges=None):
@nx.utils.decorators.nodes_or_number(0)
@nx.utils.decorators.nodes_or_number(1)
def find_biclique_embedding(a, b, m, n=None, t=None, target_edges=None):
"""Find an embedding for a biclique.
"""Find an embedding for a biclique in a Chimera graph.
Given a target :term:`Chimera` graph size, and a biclique (a bipartite graph where every
vertex in a set in connected to all vertices in the other set), attempts to find an embedding.
Args:
a (int/iterable):
If a is an integer, generates an embedding for a biclique with the left shore of size a
labelled [0,a-1].
Left shore of the biclique to embed. If a is an integer, generates an embedding
for a biclique with the left shore of size a labelled [0,a-1].
If a is an iterable, generates an embedding for a biclique with the left shore of size
len(a) where a provides the variable labels.
len(a), where iterable a is the variable labels.
b (int/iterable):
If b is an integer, generates an embedding for a biclique with the right shore of size b
labelled [0,b-1].
If b is an iterable, generates an embedding for a biclique with the right shore of size
len(b) where a provides the variable labels.
Right shore of the biclique to embed.If b is an integer, generates an embedding
for a biclique with the right shore of size b labelled [0,b-1].
If b is an iterable, generates an embedding for a biclique with the right shore of
size len(b), where iterable b provides the variable labels.
m (int):
Number of rows in the Chimera lattice.
Expand All @@ -103,7 +113,7 @@ def find_biclique_embedding(a, b, m, n=None, t=None, target_edges=None):
Size of the shore within each Chimera tile.
target_edges (iterable[edge]):
A list of edges in the target Chimera graph. Expects the nodes to be labelled as
A list of edges in the target Chimera graph. Nodes are labelled as
returned by :func:`~dwave_networkx.generators.chimera_graph`.
Returns:
Expand All @@ -114,14 +124,14 @@ def find_biclique_embedding(a, b, m, n=None, t=None, target_edges=None):
dict: An embedding mapping the right shore of the biclique to the Chimera lattice
Examples:
This example finds an embedding for an alphanumerically labeled biclique in a single
Chimera unit cell.
>>> from dwave.embedding.chimera import find_biclique_embedding
...
>>> left, right = find_biclique_embedding(3, 3, m=2, n=2, t=4)
>>> left # doctest: +SKIP
{0: [28], 1: [29], 2: [30]}
>>> right # doctest: +SKIP
{0: [24], 1: [25], 2: [26]}
>>> left, right = find_biclique_embedding(['a', 'b', 'c'], ['d', 'e'], 1, 1)
>>> print(left, right) # doctest: +SKIP
{'a': [4], 'b': [5], 'c': [6]} {'d': [0], 'e': [1]}
"""
_, anodes = a
Expand All @@ -138,11 +148,13 @@ def find_biclique_embedding(a, b, m, n=None, t=None, target_edges=None):


def find_grid_embedding(dim, m, n=None, t=4):
"""Find an embedding for a grid.
"""Find an embedding for a grid in a Chimera graph.
Given a target :term:`Chimera` graph size, and grid dimensions, attempts to find an embedding.
Args:
dim (iterable[int]):
The size of each grid dimension. Length can be between 1 and 3.
Sizes of each grid dimension. Length can be between 1 and 3.
m (int):
Number of rows in the Chimera lattice.
Expand All @@ -157,6 +169,7 @@ def find_grid_embedding(dim, m, n=None, t=4):
dict: An embedding mapping a grid to the Chimera lattice.
Examples:
This example finds an embedding for a 2x3 grid in a 12x12 lattice of Chimera unit cells.
>>> from dwave.embedding.chimera import find_grid_embedding
...
Expand Down Expand Up @@ -189,7 +202,7 @@ def _key(row, col, aisle): return row, col, aisle

rows, cols, aisles = dim
if rows > m or cols > n or aisles > t:
msg = ("the largest grid that can fit in a ({}, {}, {}) Chimera-lattice "
msg = ("the largest grid that find_grid_embedding can fit in a ({}, {}, {}) Chimera-lattice "
"is {}x{}x{}; given grid is {}x{}x{}").format(m, n, t, m, n, t, rows, cols, aisles)
raise ValueError(msg)

Expand Down
4 changes: 4 additions & 0 deletions dwave/embedding/polynomialembedder.py
Expand Up @@ -14,6 +14,10 @@
#
# ================================================================================================
"""
**This module is used as a private source file. It is subject to change and not
recommended for use at this time.**
This file implements a polynomial-time algorithm to find a maximum-sized
native clique embedding in an induced Chimera subgraph. It also provides
functionality to find maximum-sized native embeddings of complete bipartite
Expand Down

0 comments on commit 677ead5

Please sign in to comment.