dwave-system icon indicating copy to clipboard operation
dwave-system copied to clipboard

Make lower-level utilities available to third-party frameworks

Open speller26 opened this issue 4 years ago • 4 comments

Current Problem I want to use some of the the low-level utilities provided in dwave-cloud-client directly from a third-party sampler.

For example, I'd like to validate that my problem is compatible with a device's graph. This functionality is available in the DWaveSampler's underlying Client, but not directly from the sampler; I have to access the low-level Client. However, a third-party sampler does not have an underlying Client, so it becomes impossible to use this feature.

Proposed Solution Expose useful lower-level utilities through the Sampler interface.

speller26 avatar May 13 '21 05:05 speller26

I think there are two specific features we'd like to support:

  1. Graph validation. This can be done now with
all(v in sampler.adjacency for v in bqm.variables) and (u in sampler.adjacency[v] for u, v in bqm.quadratic)

if you have a StructuredSampler.

One solution might be to add a sampler.check_structure(bqm) method to the structured sampler ABC.

  1. Variable format massaging. See https://github.com/dwavesystems/dwave-cloud-client/issues/465

arcondello avatar May 27 '21 16:05 arcondello

When you say StructuredSampler, do you just mean that the Sampler implementation should subclass both Sampler and Structured (I don't see a StructuredSampler class; will that be added)?

speller26 avatar Jun 02 '21 21:06 speller26

Yes, it should subclass both, like the DWaveSampler.

arcondello avatar Jun 02 '21 22:06 arcondello

To @speller26's point, adding StructuredSampler with relevant utilities, and then subclassing it in DWaveSampler makes the most sense to me (see https://github.com/dwavesystems/dimod/pull/832#discussion_r644310027).

Something like:

# in dimod
class StructuredSampler(dimod.Structured, dimod.Sampler):
    def samples_from(self, bqm):
        ...

# in dwave-system
class DWaveSampler(dimod.StructuredSampler):
    ...

randomir avatar Jun 02 '21 22:06 randomir