DWaveSampler returns done() prematurely
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
Research direction
Reproduce the asynchronous example using DWaveSampler.sample, dimod.SampleSet.from_future, and the contrasting EmbeddingComposite case. Trace how done() and info are resolved, then add a regression test showing that done() does not precede job completion; the reported behavior should be corrected without changing the documented workflow.
Written by the indexing model from the issue text.
Description
Description
Jobs submitted asynchronously to a DWaveSampler à la the example in the from_future documentation may return done() == True before they're actually done.
To Reproduce
Consider the following code:
#! /usr/bin/env python
import dimod
from concurrent.futures import ThreadPoolExecutor
from dwave.system import DWaveSampler, EmbeddingComposite
import time
# Ensure some jobs.
njobs = 5
#sampler = EmbeddingComposite(DWaveSampler())
sampler = DWaveSampler()
bqm = dimod.BinaryQuadraticModel.from_ising({}, {(0, 4): -1})
executor = ThreadPoolExecutor()
futures = []
samplesets = []
for i in range(njobs):
futures.append(executor.submit(sampler.sample, bqm, num_reads=1000, annealing_time=2000))
samplesets.append(dimod.SampleSet.from_future(futures[i]))
executor.shutdown(wait=False)
# Report when they're finished.
print("Enqueued %d job(s)" % njobs)
start_time = time.time()
while not all([ss.done() for ss in samplesets]):
pass
print("Done is claimed after %d second(s)" % (time.time() - start_time))
start_time = time.time()
info = []
for i in range(njobs):
info.append(samplesets[i].info)
print("Have info after %d more second(s)" % (time.time() - start_time))
Run it with sampler = DWaveSampler() as written. Then comment out that line, uncomment the sampler = EmbeddingComposite(DWaveSampler()) line, and run it again.
Expected behavior
With sampler = EmbeddingComposite(DWaveSampler()), most of the time is attributed to waiting for all the jobs to finish, as expected:
./premature.py
Enqueued 5 job(s)
Done is claimed after 14 second(s)
Have info after 0 more second(s)
However, with sampler = DWaveSampler(), most of the time is attributed to accessing info, which implies to me that the future is returning done() == True before the job is actually done, and tickling info is forcing the wait for completion:
./premature.py
Enqueued 5 job(s)
Done is claimed after 0 second(s)
Have info after 13 more second(s)
Environment:
- OS: Ubuntu 19.10
- Python version: 3.8.2
- Dominant language
- Python
- Stars
- 100
- Forks
- 70
- Avg merge
- 9h 33m
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dwavesystems/dwave-system
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
dwavesystems/dwave-system#617 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
dwavesystems/dwave-system#509 · 1 reaction ·
-
maximum_pseudolikelihood bootstrap implementation is incorrectPossibly taken @manavbabel claimed this 67 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 78/100
dwavesystems/dwave-system#614 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
dwavesystems/dwave-system#613 · 2 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
dwavesystems/dwave-system#597 · 1 comment ·
All issues in dwavesystems/dwave-system
Similar issues
-
docs(contributing): the two things that silently block a PRPossibly taken A pull request linked to this issue is open or already merged. Openavailable documentation good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 95/100
Nixitov/Riptide-Native#944 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
JTHCode/secretguard#24 ·
Maintainers usually reply within 1 day
-
area: middleware documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 ·
Maintainers usually reply within 1 day