we made the strange observation that the evaluation of the output in form of the dimod.SampleSet takes a long time to evaluate especially in comparison to the actual sampling step. Here is a minimal code example

import networkx as nx
import dimod

K_7 = nx.complete_graph(7)
bqm = dimod.generators.random.ran_r(1, K_7)

start = time.time()
hybrid_solver = LeapHybridSampler(solver = None, connection_close = False, token = TOKEN)
print('\nDuration init hybrid sampler', time.time() - start)

start = time.time()
sample_set = hybrid_solver.sample(bqm, time_limit=TIME_LIMIT_CLASSIC_SOLVER)
print('\nDuration get sample', time.time() - start)

start_time = time.time()
print('\n Duration print sample set', time.time() - start_time)

with the following output

Duration init hybrid sampler 2.8732540607452393

Duration get sample 2.669390916824341
   0  1  2  3  4  5  6 energy num_oc.
0 -1 +1 +1 -1 -1 +1 +1   -9.0       1
['SPIN', 1 rows, 1 samples, 7 variables]

 Duration print sample set 13.532737016677856

This means that the evaluation of the print statement right after the sampling of the hybrid solver is done, takes a long time to evaluate, much longer than the actual init and sampling step. We further made the observation, that if I print the sample set in another cell after waiting for roughly 13 seconds, the print statement is almost immediately evaluated. I also switched 'connection_close' from True to False and vice versa but nothing changed.

This makes me guess that there is still some sort of connection of the hybrid sampler to the backend ongoing which first needs to be closed before the sample set can be evaluated/printed locally.

Any ideas on how to fix this?

Thanks in advance and best regards,


EDIT: The question was answered in the dwave community forum: https://support.dwavesys.com/hc/en-us/community/posts/4403113729943-Output-of-LeapHybrid-takes-long-to-evaluate?page=1#community_comment_4403163648279

The reason is that the processing happens asynchronously.

  • 2
    $\begingroup$ Hi @Simon and welcome :) Nice to see that you got the answer to your question. Self-answering is a possibility on this website and is a good way to answer a question. In your case, I think the best solution is to copy-paste your edit (the answer) into an answer, and to accept it as an answer. It might help people having the exact same issue. $\endgroup$ Jun 24 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.