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

Fix some VS Code format problems #8

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions 01-exploring-pegasus.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@
"source": [
"## Minor-Embedding: Mapping Problems to Qubits\n",
"\n",
"<div class=\"alert alert-warning\" role=\"alert\" style=\"margin: 10px\">Note: If you already understand how problems are mapped to the D-Wave system, please skip ahead to the next text cell by clicking the **Run** button.</div>\n",
"> **Note:** If you already understand how problems are mapped to the D-Wave system, please skip ahead to the \n",
" next text cell by clicking the **Run** button.\n",
" \n",
"D-Wave systems solve binary quadratic models (BQMs): the [Ising model](https://en.wikipedia.org/wiki/Ising_model) traditionally used in statistical mechanics and its computer-science equivalent, the quadratic unconstrained binary optimization ([QUBO](https://en.wikipedia.org/wiki/Quadratic_unconstrained_binary_optimization)) problem. Given $N$ variables $x_1,...,x_N$, where each variable $x_i$ can have binary values $0$ or $1$, the system finds assignments of values that minimize the QUBO,\n",
"\n",
"$\\sum_i^N q_ix_i + \\sum_{i<j}^N q_{i,j}x_i x_j$,\n",
"\n",
"where $q_i$ and $q_{i,j}$ are configurable (linear and quadratic) coefficients. \n",
"\n",
"Such [objective functions](https://docs.ocean.dwavesys.com/en/stable/concepts) can be represented by graphs. A graph comprises a collection of nodes, representing variables, and edges representing the connections between them. For example, a Boolean AND, $z \\Leftrightarrow x_1 \\wedge x_2$, expressed in [QUBO formulation](https://docs.dwavesys.com/docs/latest/c_handbook_3.html) as, \n",
"Such [objective functions](https://docs.ocean.dwavesys.com/en/stable/concepts) can be represented by graphs. A graph comprises a collection of nodes, representing variables, and edges representing the connections between them. For example, a Boolean AND, $z \\Leftrightarrow x_1 \\wedge x_2$, expressed in [QUBO formulation](https://docs.dwavesys.com/docs/latest/handbook_reformulating.html) as, \n",
"\n",
"$x_1 x_2 - 2(x_1+x_2)z +3z$, \n",
"\n",
Expand Down Expand Up @@ -157,7 +158,8 @@
"\n",
"To demonstrate the benefits of the Pegasus topology, the following subsections compare its performance with that of the Chimera. This is done by generating and embedding many random graphs that are representative of problems of sizes commensurate with the size of a DW-2000Q QPU. \n",
"\n",
"<div class=\"alert alert-warning\" role=\"alert\" style=\"margin: 10px\">The demonstrations of this section do not submit problems to a D-Wave system for solution, and so are not associated with a cost for QPU usage time.</div>\n",
"<style>.alert-info {color: #0399A9; background: #B2EBF3; border: 2px solid #4FD1E1; }</style>\n",
"<div class=\"alert alert-info\" role=\"alert\" style=\"margin: 10px\">The demonstrations of this section do <b>not</b> submit problems to a D-Wave system for solution, and so are <b>not</b> associated with a cost for QPU usage time.</div>\n",
"\n",
"The next three code cells import three functions used throughout this section. You can see (and modify) the code for these functions by selecting Jupyter File Explorer View from the Online Learning page.\n",
"\n",
Expand Down Expand Up @@ -205,7 +207,9 @@
"source": [
"The second function, `try_embedding`, uses one of Ocean's embedding tools to find a minor-embedding for a given problem. You can configure the number or attempts this heuristic algorithm makes, `tries`, and a timeout value for those attempts, `timeout`. \n",
"\n",
"<div class=\"alert alert-warning\" role=\"alert\" style=\"margin: 10px\">You can also update the code (located in the <code>helpers</code> folder for this notebook) to configure additional embedding parameters, described here: <a href=\\\"https://docs.ocean.dwavesys.com/en/stable/docs_minorminer/source/sdk_index.html\\\">minorminer</a>.</div>\n",
"> **NOTE:** You can also update the code (located in the `helpers` folder for this notebook) to configure \n",
" additional embedding parameters, described here: [minorminer](https://docs.ocean.dwavesys.com/en/stable/docs_minorminer/source/sdk_index.html)\n",
"\n",
"Run it on the graph you generated in the previous code cell:"
]
},
Expand All @@ -231,7 +235,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The `try_embedding` function returns for both QPU topologies the longest chain it needed for the embedding. As mentioned above, for a group of qubits to act as a chain, you need to strongly couple them so that they tend to return a single value for the variable the chain represents. In this context \"strong\" is relative to values used for the problem's quadratic interactions, which are also represented by coupling strengths. Because coupling values have a finite range, relatively strong, long chains can come at the [cost](https://docs.dwavesys.com/docs/latest/c_handbook_6.html) of a smaller range of coupling strengths for representing the problem's quadratic interactions. \n",
"The `try_embedding` function returns for both QPU topologies the longest chain it needed for the embedding. As mentioned above, for a group of qubits to act as a chain, you need to strongly couple them so that they tend to return a single value for the variable the chain represents. In this context \"strong\" is relative to values used for the problem's quadratic interactions, which are also represented by coupling strengths. Because coupling values have a finite range, relatively strong, long chains can come at the [cost](https://docs.dwavesys.com/docs/latest/handbook_embedding.html) of a smaller range of coupling strengths for representing the problem's quadratic interactions. \n",
"\n",
"The last of the three functions,`embedding_loop`, runs the two previous ones and saves some of the parameters and results in a [pandas](https://pandas.pydata.org/pandas-docs/stable/index.html) data structure for convenient analysis."
]
Expand Down Expand Up @@ -284,9 +288,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<style>.alert-danger { color: #C4453E; background: #F7CFD3; border: 2px solid #E29C9B; }</style> \n",
"<div class=\"alert alert-danger\" role=\"alert\" style=\"margin: 10px\"><p><b>Important</b>: Loops that run multiple attempts at embeddings on multiple graphs, some of them big, can take minutes to execute. To reduce runtimes, the code cells below run by default on quarter-sized, C8 and P8, graphs. You can run on the full-sized C16 and P16 graphs by setting the flag <code>fast_run=False</code> in the code cells below.</p></div>\n",
"\n",
"<div class=\"alert alert-warning\" role=\"alert\" style=\"margin: 10px\"><p>Note: In this and similar code cells below, you can shorten the runtime by setting a lower value to the <code>problems</code> parameter, which represents the number of graphs of each size, and/or modifying the loop variable, <code>nodes</code>, to fewer and smaller values.</p><p>You can also modify the <code>embedding_timeout</code> and <code>embedding_tries</code> parameters used to configure the <a href=\\\"https://docs.ocean.dwavesys.com/en/stable/docs_minorminer/source/sdk_index.html\\\">minorminer</a> embedding heuristic.</p></div>"
"> **Note:** In this and similar code cells below, you can shorten the runtime by setting a lower value to the \n",
" `problems` parameter, which represents the number of graphs of each size, and/or modifying the loop variable, \n",
" `nodes`, to fewer and smaller values. You can also modify the `embedding_timeout` and `embedding_tries` parameters\n",
" used to configure the\n",
" [minorminer](https://docs.ocean.dwavesys.com/en/stable/docs_minorminer/source/sdk_index.html) embedding heuristic."
]
},
{
Expand Down Expand Up @@ -515,7 +524,9 @@
"<img src=\"images/embedding_clique_k3_2vars.png\" width=500x/>\n",
"\n",
"\n",
"<div class=\"alert alert-warning\" role=\"alert\" style=\"margin: 10px\">Note that if your problems are represented by sparse graphs, using a clique embedding can be (1) wasteful of qubits, needlessly limiting the size of problem you can embed and (2) result in longer chains and possibly lower-quality solutions.</div>"
"> **Note:** If your problems are represented by sparse graphs, using a clique embedding can be (1) wasteful of \n",
" qubits, needlessly limiting the size of problem you can embed and (2) result in longer chains and possibly \n",
" lower-quality solutions."
]
},
{
Expand All @@ -528,7 +539,9 @@
"QPU architecture is described in more detail in the [documentation](https://docs.dwavesys.com/docs/latest/c_gs_4.html) and below; for now it's sufficient to know that the Chimera topology's structure is a grid of unit cells, each with four horizontal qubits connected to four vertical qubits via couplers. Graphs that can be split into two sets of vertices, with all vertices of one set connected to all vertices of the second, are known as *bicliques* or complete bipartite graphs; a Chimera unit cell is a $K_{4,4}$ [biclique](https://en.wikipedia.org/wiki/Complete_bipartite_graph). Unit cells are tiled vertically and horizontally with adjacent qubits connected, creating a lattice of sparsely connected qubits.\n",
"\n",
"The figure below shows a C3 $3x3$ lattice of Chimera unit cells.\n",
"\n",
"<img src=\"images/chimera.png\" width=300x/>\n",
"\n",
"If repeated structures of a problem can be embedded in a unit cell, you might then be able to duplicate that across unit cells and interconnect these in a very efficient overall embedding. "
]
},
Expand Down