dwavesystems / dwavesystems/dwave-cloud-client
Active Qubit definitions are not handled properly when h is sent as a list - impacts reverse annealing
- Dominant language
- Python
- Stars
- 63
- Forks
- 44
- Avg merge
- 13h 45m
- Merged PRs (30d)
- 1
Description
here are some code snippets that work and doesn't work
lets initialize stuff:
```
con = Client(endpoint=url, token=token, permissive_ssl=True)
solver = con.get_solver(solver_name)
h = [0] * 2048
J = {(1, 5): -1, (0, 5): -1, (1, 4): -1, (0, 4): -1}
anneal_schedule = [[0, 1], [0.2, 0.8], [8.2, 0.8], [8.4, 1.0]]
```
here if I send in an empty dict for h, and define the active qubits to be the qubits used in J, its all good
```
initial = []
activeQ = {i for k in J for i in k}
for i in range(solver.properties['num_qubits']):
if i in activeQ:
initial.append(1)
else:
initial.append(3)
solsnp = solver.sample_ising({},J,
initial_state=initial,
num_reads=1,
anneal_schedule=anneal_schedule)
print solsnp.energies
```
---> [-4.0]
Now if I change my h submission into a [0]*2048, I get the following error, which is possibly due to creating a h -dict from the 0 h list that turns all activatable qubits active
```
initial = []
activeQ = {i for k in J for i in k}
for i in range(solver.properties['num_qubits']):
if i in activeQ:
initial.append(1)
else:
initial.append(3)
solsnp = solver.sample_ising(h,J,
initial_state=initial,
num_reads=1,
anneal_schedule=anneal_schedule)
print solsnp.energies
```
----->
```
Traceback (most recent call last):
File "/home/iozfidan/jupyter/sapitests/tests.py", line 82, in
print solsnp.energies
File "/home/iozfidan/miniconda3/envs/dxf_dev/lib/python2.7/site-packages/dwave/cloud/computation.py", line 485, in energies
return self.result()['energies']
File "/home/iozfidan/miniconda3/envs/dxf_dev/lib/python2.7/site-packages/dwave/cloud/computation.py", line 454, in result
self._load_result()
File "/home/iozfidan/miniconda3/envs/dxf_dev/lib/python2.7/site-packages/dwave/cloud/computation.py", line 621, in _load_result
raise self.error
dwave.cloud.exceptions.SolverFailureError: initial_state must be specified for all active qubits
```
I can prove the above statement by replacing the definition of activeQ to include all alive qubits
```
activeQ = solver.properties['qubits']
for i in range(solver.properties['num_qubits']):
if i in activeQ:
initial.append(1)
else:
initial.append(3)
solsnp = solver.sample_ising(h,J,
initial_state=initial,
num_reads=1,
anneal_schedule=anneal_schedule)
print solsnp.energies
```
---> [-4.0]
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.