Unembed_problem and annealing time tuning

Hi,

 

I am wandering how to correctly submit an annealing job from Ocean Leap.
I was previously working on the DWAVE 2X machine where my code was :

qaresults = solve_ising(solver, h, j)

solve_ising() also let me tune the number of reads, annealing_time and answer_mode and returned a dictionary with keys "solutions", "energies", "num_occurences" and "timing", it was very convenient to use and I could do something like

qaresults = np.array(unembed_answers(qaresults["solutions], embeddings, 'vote', h, J)) to get the results I needed to compute energies.

 

I am now trying to "translate" my code from DWAVE 2X to DWAVE 2000Q. I am struggling with how to find an equivalent function to unembed_answers. Furthermore, I did not find how to tune the annealing time, it seems to me that I'm failing to do so because of how I embed my problem. My new code looks like this :

 #Connection to qa
dwave_sampler = DWaveSampler(solver={'qpu': True})    

#Tunning parameters
dwave_sampler.parameters["annealing_time"] = a_time    
dwave_sampler.parameters["num_reads"] = nreads
dwave_sampler.parameters["answer_mode"] = 'raw'

 #Embedding
sampler = EmbeddingComposite(dwave_sampler)   

 #Annealing
sampleset = sampler.sample_ising(h, J, chain_strength = strength_scale)   

As far as I understand, this returns a SampleSet object that I can unembed.

Am I getting this right or should I use a "manual" way to embed my problem such as dwave.embedding.embed_ising ?

 

Thanks for your help !!

Tim

 

 

0

Comments

6 comments
  • Hello,

    It's actually a lot simpler than even that!

    sampler = EmbeddingComposite(DWaveSampler(solver={'qpu': True}))
    sampleset = sampler.sample_ising(h, J, num_reads=1, chain_strength=2.2, annealing_time=2, answer_mode="raw")

    If you set up your config file with the following command, you can even exclude solver={'qpu': True}:

    dwave config create
    0
    Comment actions Permalink
  • Hello,

     

    Thanks a lots, it works fine know !

    Although, I do have another problem: it seems like my token is not recognized anymore and I can not access the qpu.

    client = Client.from_config(token='token')
    sampler = EmbeddingComposite(DWaveSampler(solver={'qpu' : True}))

    I get :

    dwave.cloud.exceptions.SolverAuthenticationError: Token not accepted for that action.
     
    This is very mysterious to me as this token worked just fine for a couple of jobs and just seems to have stopped being recognized as a valid one.
     
    I am not sure of what I should do.
     
     
    Once again, thank you very much for your help,
     
    Tim

     

    1
    Comment actions Permalink
  • Hello,

    It looks like a new token was created, which would have invalidated your old token.
    If you use your newest token by going to your leap homepage, and pressing the "Copy" button below "API Token", you can copy the token to your configuration.

    If you press on the little eye-shaped icon next to your obfuscated API Token on the same page, you can see that the token is different than the one currently in your config file.

    This is a bit of a curious one!
    I'm not sure what could have happened to create a new token, other than maybe accidentally pressing the "Reset" button, but this pops up a dialogue asking if you are sure you want to lose your current token.

    Sorry for the trouble!
    Please let us know if this resolves the problem and if you have any further issues.

    0
    Comment actions Permalink
  • Dear David,

     

    Thanks for your quick replies, I have try what you have suggested but it does not seems to work.

    I've did some tests, which the old token and tried with a new one (I've generated a new token and retried, but I still got the same error : dwave.cloud.exceptions.SolverAuthenticationError: Token not accepted for that action.)

    I do not understand why, maybe the token need some time to get activated..

    I am not sure if there is something else to change in the workspace or the code when I change the token.

     

    Thanks a lot for your help,

     

    Tim

    0
    Comment actions Permalink
  • did you try to ping to dwave to see what will be happened in your terminal? https://docs.ocean.dwavesys.com/en/stable/docs_cli.html#ping

    dwave ping 
    1
    Comment actions Permalink
  • Thank you for following up with this thread!

    That's a great suggestion! 

    We took the issue into a ticket to resolve, to make things a little faster.

    Unfortunately we forgot to debrief the thread so other users can benefit from the things we learned.

    We were able to resolve the issue by putting the token inline as a solver parameter like this:

    sampler = EmbeddingComposite(DWaveSampler(token="******************"))

    Hopefully someone with the same issue finds this helpful!

    1
    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post