SolverFailureError: quadratic must be a sequence of length 93

I'm running into an issue where I suddenly start seeing solver failures halfway through running a jupyter notebook. I'm calling the solver inside a loop, and it runs successfully 38 times and then always fails on the 39th time, with the error 'SolverFailureError: quadratic must be a sequence of length 93.' 

I'm having difficulty diagnosing the problem, given that the binary quadratic model is of the same size and structure as it was in the previous 38 runs so there's no reason the embedding should suddenly stop working. Nothing seems obviously different about the 39th run. 

Does anyone know what this error message might mean?

0

Comments

2 comments
  • Hello,

    Sorry you are having trouble with your code. Let's try to get you back up and running.

    Are you able to share a minimal code example that reproduces the behaviour? 
    Also can you please share the whole stack trace to help better understand the error?
    Thanks for reaching out!

    0
    Comment actions Permalink
  • Thank you very much! I can't really share a minimal code example, because as noted, this only happens in one very specific context (on the 39th run of a specific loop of code) and I don't know what is causing it. But please find below the stack trace, in case that helps! 

    SolverFailureError                        Traceback (most recent call last)
    Cell In [15], line 21
         19 print(i)
         20 newdata = data.iloc[ : , i*639 : (i + 1)*639]
    ---> 21 weightsxx, boxx, bhxx = dostuff(newdata, epsilon, weights[0][ i*639 : (i + 1)*639,i*16 : (i + 1)*16], bo[0][   i*639 : (i + 1)*639], bh[0][   i*16 : (i + 1)*16], 50)
         22 weightslist.append(weightsxx)
         23 bolist.append(boxx)
    
    Cell In [5], line 85, in dostuff(data, epsilon, ww, boo, bhh, num)
         82 sampler2 = FixedEmbeddingComposite(sampler,
         83     embedding=emb)
         84 sampleset = sampler2.sample(bqm, num_reads=500)
    ---> 85 res = findav(sampleset.record) 
         86 print(res)
         87 res0 += res[0:len(data.columns)] 
    
    File ~/env/lib/python3.9/site-packages/dimod/sampleset.py:1121, in SampleSet.record(self)
       1105 @property
       1106 def record(self):
       1107     """:obj:`numpy.recarray` containing the samples, energies, number of occurences, and other sample data.
       1108 
       1109     Examples:
       (...)
       1119 
       1120     """
    -> 1121     self.resolve()
       1122     return self._record
    
    File ~/env/lib/python3.9/site-packages/dimod/sampleset.py:1470, in SampleSet.resolve(self)
       1468 # if it doesn't have the attribute then it is already resolved
       1469 if hasattr(self, '_future'):
    -> 1470     samples = self._result_hook(self._future)
       1471     self.__init__(samples.record, samples.variables, samples.info, samples.vartype)
       1472     del self._future
    
    File ~/env/lib/python3.9/site-packages/dwave/system/composites/embedding.py:284, in EmbeddingComposite.sample.<locals>.async_unembed(response)
        279 def async_unembed(response):
        280     # unembed the sampleset aysnchronously.
        282     warninghandler.chain_break(response, embedding)
    --> 284     sampleset = unembed_sampleset(response, embedding, source_bqm=bqm,
        285                                   chain_break_method=chain_break_method,
        286                                   chain_break_fraction=chain_break_fraction,
        287                                   return_embedding=return_embedding)
        289     if return_embedding:
        290         sampleset.info['embedding_context'].update(
        291             embedding_parameters=embedding_parameters,
        292             chain_strength=embedding.chain_strength)
    
    File ~/env/lib/python3.9/site-packages/dwave/embedding/transforms.py:626, in unembed_sampleset(target_sampleset, embedding, source_bqm, chain_break_method, chain_break_fraction, return_embedding)
        623 except KeyError:
        624     raise ValueError("given bqm does not match the embedding")
    --> 626 record = target_sampleset.record
        628 unembedded, idxs = chain_break_method(target_sampleset, chains)
        630 reserved = {'sample', 'energy'}
    
    File ~/env/lib/python3.9/site-packages/dimod/sampleset.py:1121, in SampleSet.record(self)
       1105 @property
       1106 def record(self):
       1107     """:obj:`numpy.recarray` containing the samples, energies, number of occurences, and other sample data.
       1108 
       1109     Examples:
       (...)
       1119 
       1120     """
    -> 1121     self.resolve()
       1122     return self._record
    
    File ~/env/lib/python3.9/site-packages/dimod/sampleset.py:1470, in SampleSet.resolve(self)
       1468 # if it doesn't have the attribute then it is already resolved
       1469 if hasattr(self, '_future'):
    -> 1470     samples = self._result_hook(self._future)
       1471     self.__init__(samples.record, samples.variables, samples.info, samples.vartype)
       1472     del self._future
    
    File ~/env/lib/python3.9/site-packages/dwave/system/samplers/dwave_sampler.py:422, in DWaveSampler.sample.<locals>._hook(computation)
        420 except (SolverError, InvalidAPIResponseError) as exc:
        421     if not self.failover:
    --> 422         raise exc
        423     if isinstance(exc, SolverAuthenticationError):
        424         raise exc
    
    File ~/env/lib/python3.9/site-packages/dwave/system/samplers/dwave_sampler.py:409, in DWaveSampler.sample.<locals>._hook(computation)
        406     return sampleset
        408 try:
    --> 409     return resolve(computation)
        411 except (ProblemUploadError, RequestTimeout, PollingTimeout) as exc:
        412     if not self.failover:
    
    File ~/env/lib/python3.9/site-packages/dwave/system/samplers/dwave_sampler.py:399, in DWaveSampler.sample.<locals>._hook.<locals>.resolve(computation)
        397 def resolve(computation):
        398     sampleset = computation.sampleset
    --> 399     sampleset.resolve()
        401     if warninghandler is not None:
        402         warninghandler.too_few_samples(sampleset)
    
    File ~/env/lib/python3.9/site-packages/dimod/sampleset.py:1470, in SampleSet.resolve(self)
       1468 # if it doesn't have the attribute then it is already resolved
       1469 if hasattr(self, '_future'):
    -> 1470     samples = self._result_hook(self._future)
       1471     self.__init__(samples.record, samples.variables, samples.info, samples.vartype)
       1472     del self._future
    
    File ~/env/lib/python3.9/site-packages/dwave/cloud/computation.py:823, in Future.sampleset.<locals>.<lambda>(f)
        818 except ImportError:
        819     raise RuntimeError("Can't construct SampleSet without dimod. "
        820                        "Re-install the library with 'bqm' support.")
        822 self._sampleset = sampleset = dimod.SampleSet.from_future(
    --> 823     self, lambda f: f.wait_sampleset())
        825 # propagate id to sampleset as well
        826 # note: this requires dimod>=0.8.21 (before that version SampleSet
        827 # had slots set which prevented dynamic addition of attributes).
        828 sampleset.wait_id = self.wait_id
    
    File ~/env/lib/python3.9/site-packages/dwave/cloud/computation.py:755, in Future.wait_sampleset(self)
        752 """Blocking sampleset getter."""
        754 # blocking result get
    --> 755 result = self._load_result()
        757 # common problem info: id/label
        758 problem_info = dict(problem_id=self.id)
    
    File ~/env/lib/python3.9/site-packages/dwave/cloud/computation.py:893, in Future._load_result(self)
        891 # Check for other error conditions
        892 if self._exception is not None:
    --> 893     raise self._exception
        895 # If someone else took care of this while we were waiting
        896 if self._result is not None:
    
    File ~/env/lib/python3.9/site-packages/dwave/cloud/client/base.py:1460, in Client._handle_problem_status(self, message, future)
       1458             raise SolverOfflineError(errmsg)
       1459         else:
    -> 1460             raise SolverFailureError(errmsg)
       1462 except Exception as exc:
       1463     # If there were any unhandled errors we need to release the
       1464     # lock in the future, otherwise deadlock occurs.
       1465     future._set_exception(exc)
    
    SolverFailureError: quadratic must be a sequence of length 93

     

    0
    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post