From e6f261168cbd90d49bf06c57f4cc72ec5fcc9d2c Mon Sep 17 00:00:00 2001 From: Radomir Stevanovic Date: Thu, 5 Jun 2025 14:27:14 -0700 Subject: [PATCH 1/4] Add `ParallelEmbeddingComposite` to docs --- docs/composites.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/composites.rst b/docs/composites.rst index 7290d473..08b721ee 100644 --- a/docs/composites.rst +++ b/docs/composites.rst @@ -202,6 +202,13 @@ Methods LazyFixedEmbeddingComposite.sample_ising LazyFixedEmbeddingComposite.sample_qubo + +ParallelEmbeddingComposite +-------------------------- + +.. autoclass:: ParallelEmbeddingComposite + + TilingComposite --------------- From a0ed02962cdd5a5967fcaf9aa447abee2f3beb51 Mon Sep 17 00:00:00 2001 From: Radomir Stevanovic Date: Thu, 5 Jun 2025 14:30:38 -0700 Subject: [PATCH 2/4] Run additional parallel embedding composite test unconditionally --- tests/test_parallel_embedding_composite.py | 25 ++++++++++------------ 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/tests/test_parallel_embedding_composite.py b/tests/test_parallel_embedding_composite.py index 1af3cb43..05b99587 100644 --- a/tests/test_parallel_embedding_composite.py +++ b/tests/test_parallel_embedding_composite.py @@ -144,20 +144,17 @@ def test_composite_propagation(self): "T_family": mock_sampler0.properties["topology"]["type"], "T_kwargs": {"m": mock_sampler0.properties["topology"]["shape"][0]}, } - try: - sampler = ParallelEmbeddingComposite( - mock_sampler, - source=source, - embedder=embedder, - embedder_kwargs=embedder_kwargs, - ) - sampleset = sampler.sample_ising({}, J, num_reads=1) - self.assertGreater( - len(sampleset), 1 - ) # Equal to the number of parallel embeddings - except: - print('Test is skipped for now, relies on incomplete pull request:' - 'https://github.com/jackraymond/minorminer/tree/parallel_embeddings') + sampler = ParallelEmbeddingComposite( + mock_sampler, + source=source, + embedder=embedder, + embedder_kwargs=embedder_kwargs, + ) + sampleset = sampler.sample_ising({}, J, num_reads=1) + self.assertGreater( + len(sampleset), 1 + ) # Equal to the number of parallel embeddings + class TestTiling(unittest.TestCase): """Testing for purposes of TilingComposite deprecation. See also testing of From cb75244e2f783e4e56a6091ee071dbce843be844 Mon Sep 17 00:00:00 2001 From: Radomir Stevanovic Date: Thu, 5 Jun 2025 15:08:35 -0700 Subject: [PATCH 3/4] Deprecate `TilingComposite` --- dwave/system/composites/tiling.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dwave/system/composites/tiling.py b/dwave/system/composites/tiling.py index 05430304..6a7cf6b6 100644 --- a/dwave/system/composites/tiling.py +++ b/dwave/system/composites/tiling.py @@ -27,6 +27,8 @@ for explanations of technical terms in descriptions of Ocean tools. """ +import warnings + import dimod import dwave_networkx as dnx @@ -43,6 +45,12 @@ class TilingComposite(dimod.Composite, dimod.Structured, dimod.Sampler): graph of dimensions ``sub_m``, ``sub_n``, ``t``, or minor-embeddable to such a graph. + .. deprecated:: 1.32.0 + Tiling is generalized in :class:`dwave.system.ParallelEmbeddingComposite` + to handle bigger and non-Chimera source graphs on any structured graph + supported by :class:`dwave.system.DWaveSampler` (including Zephyr). + ``TilingComposite`` will be removed in dwave-system 2.0. + Notation *PN* referes to a Pegasus graph consisting of a 3x(N-1)x(N-1) grid of cells, where each unit cell is a bipartite graph with shore of size t, supplemented with odd couplers (see ``nice_coordinate`` definition in @@ -120,6 +128,13 @@ class TilingComposite(dimod.Composite, dimod.Structured, dimod.Sampler): def __init__(self, sampler, sub_m, sub_n, t=4): + warnings.warn( + "'TilingComposite' has been deprecated since dwave-system 1.32.0, " + "and will be removed in 2.0. " + "Use 'ParallelEmbeddingComposite' for greater flexibility instead.", + DeprecationWarning, stacklevel=2 + ) + self.parameters = sampler.parameters.copy() self.properties = properties = {'child_properties': sampler.properties} From 7ce4305b7f718f2889934ee38e016ebac627b7fb Mon Sep 17 00:00:00 2001 From: Radomir Stevanovic Date: Thu, 5 Jun 2025 15:51:49 -0700 Subject: [PATCH 4/4] Apply suggestions from the code review Fix docs refs in TilingComposite deprecation note Fix doctest Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com> --- dwave/system/composites/parallel_embeddings.py | 2 +- dwave/system/composites/tiling.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dwave/system/composites/parallel_embeddings.py b/dwave/system/composites/parallel_embeddings.py index 5b1e353f..e09596ff 100644 --- a/dwave/system/composites/parallel_embeddings.py +++ b/dwave/system/composites/parallel_embeddings.py @@ -109,7 +109,7 @@ class ParallelEmbeddingComposite(dimod.Composite, dimod.Structured, dimod.Sample >>> from dwave.system import DWaveSampler >>> from dwave.system import ParallelEmbeddingComposite >>> from networkx import from_edgelist - >>> embedder_kwargs = {'max_num_embs': None} # Without this, only 1 embedding will be sought + >>> embedder_kwargs = {'max_num_emb': None} # Without this, only 1 embedding will be sought >>> source = from_edgelist([('a', 'b')]) >>> qpu = DWaveSampler() >>> sampler = ParallelEmbeddingComposite(qpu, source=source, embedder_kwargs=embedder_kwargs) diff --git a/dwave/system/composites/tiling.py b/dwave/system/composites/tiling.py index 6a7cf6b6..5b547a40 100644 --- a/dwave/system/composites/tiling.py +++ b/dwave/system/composites/tiling.py @@ -46,10 +46,11 @@ class TilingComposite(dimod.Composite, dimod.Structured, dimod.Sampler): such a graph. .. deprecated:: 1.32.0 - Tiling is generalized in :class:`dwave.system.ParallelEmbeddingComposite` + Tiling is generalized in + :class:`~dwave.system.composites.ParallelEmbeddingComposite` to handle bigger and non-Chimera source graphs on any structured graph - supported by :class:`dwave.system.DWaveSampler` (including Zephyr). - ``TilingComposite`` will be removed in dwave-system 2.0. + supported by :class:`~dwave.system.samplers.DWaveSampler` (including + Zephyr). ``TilingComposite`` will be removed in dwave-system 2.0. Notation *PN* referes to a Pegasus graph consisting of a 3x(N-1)x(N-1) grid of cells, where each unit cell is a bipartite graph with shore of size t,