Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make lower-level utilities available to third-party frameworks #401

Open
speller26 opened this issue May 13, 2021 · 4 comments
Open

Make lower-level utilities available to third-party frameworks #401

speller26 opened this issue May 13, 2021 · 4 comments

Comments

@speller26
Copy link

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.

@arcondello
Copy link
Member

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 Expose reformatted parameters dwave-cloud-client#465

@speller26
Copy link
Author

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)?

@arcondello
Copy link
Member

Yes, it should subclass both, like the DWaveSampler.

@randomir
Copy link
Member

randomir commented Jun 2, 2021

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

Something like:

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants