Skip to content

Commit

Permalink
Clarify/expand code of "Flow refining" docs (#260)
Browse files Browse the repository at this point in the history
* Clarify/expand code of "Flow refining" docs

Close #142.

* Fix docs ref
  • Loading branch information
randomir authored Dec 13, 2021
1 parent 310b47d commit b9bf5d8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion docs/intro/using.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ with large numbers of variables.
process all the subproblems in parallel and merge the returned samples. Here the
:class:`~hybrid.decomposers.EnergyImpactDecomposer` is iterated until it raises a
:meth:`~hybrid.exceptions.EndOfStream` exception when it reaches 15% of the variables,
and then all the 50-variable subproblems are submitted to the D-Wave system.
and then all the 50-variable subproblems are submitted to the D-Wave system in parallel.
Subsamples returned by the QPU are disjoint in variables, so we can easily reduce them
all to a single subsample, which is then merged with the input sample using
:class:`~hybrid.composers.SplatComposer`:

.. code-block:: python
Expand All @@ -151,6 +154,12 @@ with large numbers of variables.
hybrid.EnergyImpactDecomposer(size=50, rolling_history=0.15)
)
# Helper function to merge subsamples in place
def merge_substates(_, substates):
a, b = substates
return a.updated(subsamples=hybrid.hstack_samplesets(a.subsamples, b.subsamples))
# Map QPU sampling over all subproblems, then reduce subsamples by merging in place
subsampler = hybrid.Map(
hybrid.QPUSubproblemAutoEmbeddingSampler()
) | hybrid.Reduce(
Expand Down

0 comments on commit b9bf5d8

Please sign in to comment.