-
Notifications
You must be signed in to change notification settings - Fork 64
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
Allow sampling by id from DWaveSampler, LeapHybridSampler, LeapHybridDQMSampler #397
Comments
This can be done currently via the cloud-client interface. Something like import dimod
from dwave.system import LeapHybridSampler
sampler = LeapHybridSampler()
bqm = dimod.BQM('SPIN')
kwargs = dict(time_limit=sampler.min_time_limit(bqm))
bqm_id = sampler.solver.upload_bqm(bqm.to_file()).result()
ss1 = sampler.solver.sample_bqm(bqm_id, **kwargs).sampleset
ss2 = sampler.solver.sample_bqm(bqm_id, **kwargs).sampleset
print(ss1)
print(ss2) edit: this was fixed based on @randomir 's comments below |
Actually, we first need to implement #398, i.e. dwavesystems/dwave-cloud-client#466. |
I am not sure I understand, the snippet I provided works for me for both BQM and CQM, I haven't tested for the QPU. Agree that the bigger feature needs work in several places. |
I'm not sure how it can work, because |
Because I didn't actually resolve to see the error 😳 , my mistake. I'll fix and update, one sec |
Or if you realize you want to re-submit a hybrid problem long after the initial sampling, you can do: # get problem id, either from Leap Dashboard, or your previous sampling
problem_id = '...'
# or: problem_id = sampleset.info['problem_id']
# or: problem_id = sampleset.wait_id()
# get problem info
from dwave.cloud.api import Problems
problems = Problems.from_config()
info = problems.get_problem_info(problem_id)
# initialize the relevant solver, e.g. CQM
from dwave.system import LeapHybridCQMSampler
sampler = LeapHybridCQMSampler()
# re-submit the original problem
sampleset = sampler.solver.sample_cqm(info.data.data, **info.params).sampleset |
We could either accept ids in the
.sample
method,or be more explicit
My preference is for the latter, since the former might lead users to do things like
which isn't well defined.
The text was updated successfully, but these errors were encountered: