Problem using reverse annealing through AWS

Apologies in advance for a very tedious question. I'm accessing the hardware through Amazon Web Services for a project and the reverse annealing feature seems to not be working. In particular, when I run:

 

device = "arn:aws:braket:::device/qpu/d-wave/Advantage_system1"
qpu = BraketDWaveSampler(("amazon-braket-test-test", "test"), device)
J = {coupler: random.choice([-1, 1]) for coupler in qpu.edgelist}
initial = {qubit: random.randint(0, 1) for qubit in qpu.nodelist}
reverse_schedule = [[0.0, 1.0], [5, 0.45], [99, 0.45], [100, 1.0]]
reverse_anneal_params = dict(anneal_schedule=reverse_schedule,initial_state=initial,reinitialize_state=True)
#sampleset = qpu.sample_ising({}, J, num_reads=10)
sampleset = qpu.sample_ising({}, J, num_reads=10, **reverse_anneal_params)

 

I get an error (output posted at the end of this message since it is long), however when I comment the last line and uncomment the second to last line it works correctly, suggesting that the reverse annealing protocol is where the issue is (note this example follows very closely to the one at https://docs.dwavesys.com/docs/latest/c_solver_parameters.html#anneal-schedule )

The error output is:

 
---------------------------------------------------------------------------
ValidationError                           Traceback (most recent call last)
<ipython-input-69-40b538d38917> in <module>
      6 reverse_anneal_params = dict(anneal_schedule=reverse_schedule,initial_state=initial,reinitialize_state=True)
      7 #sampleset = qpu.sample_ising({}, J, num_reads=10)
----> 8 sampleset = qpu.sample_ising({}, J, num_reads=10, **reverse_anneal_params)

~/.venvs/venv2021_1/lib/python3.8/site-packages/braket/ocean_plugin/braket_dwave_sampler.py in sample_ising(self, h, J, **kwargs)
    140             {0: 1, 1: -1}
    141         """
--> 142         return super().sample_ising(h, J, **kwargs)
    143 
    144     def sample_ising_quantum_task(

~/.venvs/venv2021_1/lib/python3.8/site-packages/braket/ocean_plugin/braket_sampler.py in sample_ising(self, h, J, **kwargs)
    186             h = dict((v, b) for v, b in enumerate(h) if b or v in self._access_optimized_nodelist())
    187 
--> 188         aws_task = self.sample_ising_quantum_task(h, J, **kwargs)
    189         variables = set(h).union(*J)
    190 

~/.venvs/venv2021_1/lib/python3.8/site-packages/braket/ocean_plugin/braket_dwave_sampler.py in sample_ising_quantum_task(self, h, J, **kwargs)
    179             {0: 1, 1: -1}
    180         """
--> 181         return super().sample_ising_quantum_task(h, J, **kwargs)
    182 
    183     def sample_qubo(self, Q: Dict[Tuple[int, int], int], **kwargs) -> SampleSet:

~/.venvs/venv2021_1/lib/python3.8/site-packages/braket/ocean_plugin/braket_sampler.py in sample_ising_quantum_task(self, h, J, **kwargs)
    244             raise BinaryQuadraticModelStructureError("Problem graph incompatible with solver.")
    245 
--> 246         return self.solver.run(
    247             Problem(ProblemType.ISING, h, J),
    248             self._s3_destination_folder,

~/.venvs/venv2021_1/lib/python3.8/site-packages/braket/aws/aws_device.py in run(self, task_specification, s3_destination_folder, shots, poll_timeout_seconds, poll_interval_seconds, *aws_quantum_task_args, **aws_quantum_task_kwargs)
    138             `braket.aws.aws_quantum_task.AwsQuantumTask.create()`
    139         """
--> 140         return AwsQuantumTask.create(
    141             self._aws_session,
    142             self._arn,

~/.venvs/venv2021_1/lib/python3.8/site-packages/braket/aws/aws_quantum_task.py in create(aws_session, device_arn, task_specification, s3_destination_folder, shots, device_parameters, disable_qubit_rewiring, tags, *args, **kwargs)
    122         if tags is not None:
    123             create_task_kwargs.update({"tags": tags})
--> 124         return _create_internal(
    125             task_specification,
    126             aws_session,

/usr/lib/python3.8/functools.py in wrapper(*args, **kw)
    873                             '1 positional argument')
    874 
--> 875         return dispatch(args[0].__class__)(*args, **kw)
    876 
    877     funcname = getattr(func, '__name__', 'singledispatch function')

~/.venvs/venv2021_1/lib/python3.8/site-packages/braket/aws/aws_quantum_task.py in _(problem, aws_session, create_task_kwargs, device_arn, device_parameters, disable_qubit_rewiring, *args, **kwargs)
    444         {
    445             "action": problem.to_ir().json(),
--> 446             "deviceParameters": DwaveDeviceParameters.parse_obj(device_parameters).json(
    447                 exclude_none=True
    448             ),

~/.venvs/venv2021_1/lib/python3.8/site-packages/pydantic/main.cpython-38-x86_64-linux-gnu.so in pydantic.main.BaseModel.parse_obj()

~/.venvs/venv2021_1/lib/python3.8/site-packages/pydantic/main.cpython-38-x86_64-linux-gnu.so in pydantic.main.BaseModel.__init__()

ValidationError: 1 validation error for DwaveDeviceParameters
providerLevelParameters -> initialState
  value is not a valid list (type=type_error.list)

0

Comments

2 comments
  • Hello,

    It looks like you are using Amazon Braket, so you might need to reach out to the Amazon Support team to get more information that is specific to Braket:
    https://aws.amazon.com/contact-us/

    Usually the initial_state variable takes on the form of a dictionary as you can see in the documentation.
    Something like the following:

    {0: -1, 1: -1}

    The reverse_annealing Jupyter Notebook might be a useful resource for you to look at. 
    It is under /leap/techniques/reverse_annealing in the Jupyter Hub:
    https://cloud.dwavesys.com/leap/learning/

    As I had mentioned above, Braket might wrap things a little different, so you might require additional assistance from Amazon.

    I hope this helps to resolve your issue!
    Please let us know if you have any additional questions or follow-up.

    0
    Comment actions Permalink
  • I have spoken with someone at AWS and they have helped resolve the issue. I will post it here in case other people run into the same problem and are looking here for a solution. The issue apparently relates to https://github.com/dwavesystems/dwave-cloud-client/issues/465 and basically boils down to the fact that the AWS version wants the initial state as a list rather than a dictionary (with 3 for unused variables).

    1
    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post