Skip to main content


In the context of optimization, embedding refers to the process of mapping a binary quadratic model (BQM) or an Ising model onto the physical qubits of a processor, such as those provided by D-Wave or Hitachi systems.

This is necessary because the structure of the problem graph (source graph) often does not directly match the hardware graph (target graph) of the quantum processing unit (QPU).

Embedding ensures that each variable in the problem is represented by a chain of qubits, which collectively act as a single logical variable.


The following solvers support embedding:

Minor Miner

We use the MinorMiner algorithm to find embeddings for problems on the platform. This algorithm is a heuristic method that attempts to find an embedding that minimizes the number of chains and the chain lengths.


import strangeworks as sw
from strangeworks_optimization import StrangeworksOptimizer
from strangeworks_optimization_models.parameter_models import EmbeddingParameterModel, DwaveSamplerParameterModel
from dimod import BinaryQuadraticModel


linear = {1: -2, 2: -2, 3: -3, 4: -3, 5: -2}
quadratic = {(1, 2): 2, (1, 3): 2, (2, 4): 2, (3, 4): 2, (3, 5): 2, (4, 5): 2}
model = BinaryQuadraticModel(linear, quadratic, "BINARY")

embedding = EmbeddingParameterModel(

options = DwaveSamplerParameterModel(embedding_parameters=embedding)
solver = "dwave.Advantage2_prototype2.3"
so = StrangeworksOptimizer(model=model,
sw_job =


max_no_improvementintNoneMaximum number of failed iterations to improve the current solution. Each iteration attempts to find an embedding for each variable such that it is adjacent to all its neighbours.
random_seedintNoneSeed for the random number generator. If set to None, the seed is initialized using os.random().
timeoutintNoneMaximum time (in seconds) before the algorithm gives up.
max_betafloatNoneQubits are assigned weight based on a formula (beta^n) where n is the number of chains containing that qubit. This value should be greater than 1. If None, max_beta is effectively infinite.
triesintNoneNumber of restart attempts before the algorithm stops. A typical restart takes between 1 and 60 seconds.
inner_roundsintNoneMaximum number of iterations between restart attempts. If None, inner_rounds is effectively infinite.
chainlength_patienceintNoneMaximum number of failed iterations to improve chain lengths in the current solution.
max_fillintNoneRestricts the number of chains that can simultaneously incorporate the same qubit during the search. Values above 63 are treated as 63. If None, max_fill is effectively infinite.
threadsintNoneMaximum number of threads to use. Parallelization is only advantageous where the expected degree of variables is significantly greater than the number of threads.
return_overlapboolNoneDetermines the function’s return value. If True, a 2-tuple is returned with the embedding and a boolean representing the embedding validity. If False, only an embedding is returned.
skip_initializationboolNoneSkips the initialization pass if the chains passed through initial_chains and fixed_chains are semi-valid.
verboseintNoneLevel of output verbosity. Ranges from 0 (quiet) to 4 (detailed debugging).
interactiveboolNoneIf True, the verbose output will be printed to stdout/stderr and keyboard interrupts will stop the embedding process, returning the current state to the user.
initial_chainsdictNoneInitial chains to be inserted into an embedding before fixed_chains are placed.
fixed_chainsdictNoneFixed chains that are inserted into an embedding before the initialization pass and do not change during the algorithm.
restrict_chainsdictNoneEnsures that each chain is a subset of restrict_chains throughout the algorithm.
suspend_chainsdictNoneA metafeature implemented in the Python interface. Each entry is an iterable of iterables representing the target node labels.