dwavesystems / dwave-system

An API for easily incorporating the D-Wave system as a sampler, either directly or through Leap's cloud-based hybrid samplers
https://docs.ocean.dwavesys.com/
Apache License 2.0
90 stars 64 forks source link

403 Forbidden on certain ising problem submissions #536

Open iamashwin99 opened 2 months ago

iamashwin99 commented 2 months ago

Description When submitting a simple ising problem such as :

from dwave.system import EmbeddingComposite, DWaveSampler
qpu = DWaveSampler(region='eu-central-1')
q0 = qpu.nodelist[1]
q1 =  next(iter(qpu.adjacency[q0]))
q0, q1  # The two chosen qubits
qpu.sample_ising({}, {(q0, q1): -1}, num_reads=738, annealing_time=1195.4)

on the latest versions of the dwave-system library, I get the following error:

Python 3.8.10 | packaged by conda-forge | (default, Sep 13 2021, 21:46:58) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> from dwave.system import EmbeddingComposite, DWaveSampler

q0 = qpu.nodelist[1]
q1 =  next(iter(qpu.adjacency[q0]))
q0, q1  # The two chosen qubits
qpu.sample_ising({}, {(q0, q1): -1}, num_reads=738, annealing_time=1195.4)
>>> qpu = DWaveSampler(region='eu-central-1')
>>> q0 = qpu.nodelist[1]
>>> q1 =  next(iter(qpu.adjacency[q0]))
>>> q0, q1  # The two chosen qubits
(31, 32)
>>> qpu.sample_ising({}, {(q0, q1): -1}, num_reads=738, annealing_time=1195.4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "$ENV_DIR/dtest2/lib/python3.8/site-packages/dimod/sampleset.py", line 1032, in __repr__
    self.record,
  File "$ENV_DIR/dtest2/lib/python3.8/site-packages/dimod/sampleset.py", line 1126, in record
    self.resolve()
  File "$ENV_DIR/dtest2/lib/python3.8/site-packages/dimod/sampleset.py", line 1490, in resolve
    samples = self._result_hook(self._future)
  File "$ENV_DIR/dtest2/lib/python3.8/site-packages/dwave/system/samplers/dwave_sampler.py", line 449, in _hook
    raise exc
  File "$ENV_DIR/dtest2/lib/python3.8/site-packages/dwave/system/samplers/dwave_sampler.py", line 436, in _hook
    return resolve(computation)
  File "$ENV_DIR/dtest2/lib/python3.8/site-packages/dwave/system/samplers/dwave_sampler.py", line 426, in resolve
    sampleset.resolve()
  File "$ENV_DIR/dtest2/lib/python3.8/site-packages/dimod/sampleset.py", line 1490, in resolve
    samples = self._result_hook(self._future)
  File "$ENV_DIR/dtest2/lib/python3.8/site-packages/dwave/cloud/computation.py", line 833, in <lambda>
    sampleset = dimod.SampleSet.from_future(self, lambda f: f.wait_sampleset())
  File "$ENV_DIR/dtest2/lib/python3.8/site-packages/dwave/cloud/computation.py", line 771, in wait_sampleset
    self._load_result()
  File "$ENV_DIR/dtest2/lib/python3.8/site-packages/dwave/cloud/computation.py", line 907, in _load_result
    raise self._exception
  File "$ENV_DIR/dtest2/lib/python3.8/site-packages/dwave/cloud/client/base.py", line 1288, in _do_submit_problems
    message = Client._sapi_request(
  File "$ENV_DIR/dtest2/lib/python3.8/site-packages/dwave/cloud/client/base.py", line 1827, in _sapi_request
    raise SolverError(error_msg=error_msg, error_code=error_code)
dwave.cloud.exceptions.SolverError: <html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>
</body>
</html>

Here are the relevant packages in that environment:

$ pip freeze | grep dwave
dwave-cloud-client==0.13.0
dwave-optimization==0.3.0
dwave-preprocessing==0.6.6
dwave-samplers==1.3.0
dwave-system==1.26.0
dwave_networkx==0.8.15

I have tried this with both Python 3.11.10 and Python 3.8.10 and have the same result each time ( not a single successful submission)

On another environment with Python3.8.10 and the following packages:

$ pip freeze | grep dwave
dwave-cloud-client==0.12.0
dwave-greedy==0.3.0
dwave-hybrid==0.6.11
dwave-inspector==0.5.0.post0
dwave-neal==0.6.0
dwave-ocean-sdk==7.0.0
dwave-optimization==0.1.0
dwave-preprocessing==0.6.5
dwave-samplers==1.2.0
dwave-system==1.25.0
dwave-tabu==0.5.0
dwave_networkx==0.8.15
dwavebinarycsp==0.3.0

The same minimal reproducible example always succeeds. Perhaps there is a bug in the new version of one of these packages?

iamashwin99 commented 2 months ago

Interestingly, on the problematic environment, the error goes away by changing slightly to a different annealing time (1195.41) or num_reads=739. But those exact values are not working

arcondello commented 2 months ago

Hi @iamashwin99 , we're looking into it! Will let you know once we find something.

randomir commented 2 months ago

Hi @iamashwin99, this seems to be related to our web application firewall being overly protective.

Until we address the issue server-side, one workaround is to disable compression on upload of QPU problems, client-side. If you change the second line of your example to:

qpu = DWaveSampler(region='eu-central-1', compress_qpu_problem_data=False)

the problem is successfully processed.

iamashwin99 commented 2 months ago

Hi @randomir, I can condfirm that this suggested soultion works! Thanks for letting me know.

Would you like me to close the issue? or would it be a good idea to leave it open untill the server-side issue is fixed?

randomir commented 2 months ago

Thanks for confirming, @iamashwin99. Let's keep the issue opened until we fix it server-side.