Factoring Overview Minor Embedding Sample

I am working through the example code for the factoring overview. It's super interesting and informative but I had a question about the minor embedding portion of the example here:


When the D‑Wave quantum computer solves a problem, it uses quantum phenomena such as superposition and tunneling to explore all possible solutions simultaneously and find a set of the best ones. Because the sampled solution is probabilistic, returned solutions may differ between runs. Typically, when submitting a problem to the system, we ask for many samples, not just one. This way, we see multiple “best” answers and reduce the probability of settling on a suboptimal answer.

In the code below, num_reads should provide enough samples to make it likely a valid answer is among them.


import dimod
from helpers.embedding import embeddings

# Set a pre-calculated minor-embeding
embedding = embeddings[sampler.solver.id]
bqm_embedded = dimod.embed_bqm(bqm, embedding, target_adjacency, 3.0)

# Confirm mapping of variables from a0, b0, etc to indexed qubits
print("Variable a0 in embedded BQM: ", 'a0' in bqm_embedded)
print("First five nodes in QPU graph: ", sampler.structure.nodelist[:5])

---- (appologies for the plaintext code, I don't know how to embed code snippets here)

I expected the output to be something like:

Variable a0 in embedded BQM:  True
First five nodes in QPU graph:  [a0, b0, a1, b1, a2]

or something like that. Instead what was returned was:

Variable a0 in embedded BQM:  False
First five nodes in QPU graph:  [0, 1, 2, 3, 4]

I feel like this is incorrect, since it seems like from the descriptive text the mapping failed.

I was wondering why this didn't work as described, and if it is what I am not understanding about the accompanying descriptions.




  • The two important variables here are "embedding" and "bqm_embedded." The first variable is the one that contains "a0." If you print "embedding," it will show this entry in the data structure:

    'a0': [1871, 1879, 1887, 1895, 1888, 1760, 1632, 1864, 1638, 1630]

    The "bqm_embedded" variable contains the biases and weights for the physical qubits; "a0" is does not appear in "bqm_embedded." My guess is that the notebook author meant to test for "a0" membership in "embedding."

    One tip I can offer is to insert your own print statements in the code to get a better feel for what is in the different data structures. But then, I am and old school use-print-for-debugging guy.  ;-)

    Regarding code formatting - use the "Paragraph styles" drop-down in the textarea toolbar (upper left corner) and select "CODE" for the paragraph style.

    Let me know if this helps.

    Comment actions Permalink
  • Oh I see!

    That makes perfect sense thanks.

    So embedding describes which physical qubits are associated with which variables, and bqm_embedded is the BQM translated and mapped to fit the chip architecture.

    Thanks for the clarification!

    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post