amazon-braket / amazon-braket-examples

Example notebooks that show how to apply quantum computing with Amazon Braket.
https://aws.amazon.com/braket/
Apache License 2.0
463 stars 224 forks source link

Dwave_factoring example fails to run due to validation error of the device schema #51

Closed kmotohas closed 3 years ago

kmotohas commented 3 years ago

The following cell in quantum_anealing/Dwave_Factoring/Dwave_factoring.ipynb throws ValidationException with error messages below.

sampleset = sampler_fixed_embedding.sample(bqm, num_reads=100)
print("Best solution found: \n",sampleset.first.sample)
---------------------------------------------------------------------------
ValidationException                       Traceback (most recent call last)
<ipython-input-54-656093bed65b> in <module>
----> 1 sampleset = sampler_fixed_embedding.sample(bqm, num_reads=100)
      2 print("Best solution found: \n",sampleset.first.sample)

~/anaconda3/envs/Braket/lib/python3.7/site-packages/dwave/system/composites/embedding.py in sample(self, bqm, **parameters)
    501             self._fix_embedding(embedding)
    502 
--> 503         return super(LazyFixedEmbeddingComposite, self).sample(bqm, **parameters)
    504 
    505 

~/anaconda3/envs/Braket/lib/python3.7/site-packages/dwave/system/composites/embedding.py in sample(self, bqm, chain_strength, chain_break_method, chain_break_fraction, embedding_parameters, return_embedding, warnings, **parameters)
    277             parameters['ignored_interactions'] = ignored
    278 
--> 279         response = child.sample(bqm_embedded, **parameters)
    280 
    281         def async_unembed(response):

~/anaconda3/envs/Braket/lib/python3.7/site-packages/dimod/core/sampler.py in sample(self, bqm, **parameters)
    169                 # sample_qubo is implemented
    170                 Q, offset = bqm.to_qubo()
--> 171                 sampleset = self.sample_qubo(Q, **parameters)
    172             else:
    173                 h, J, offset = bqm.to_ising()

~/anaconda3/envs/Braket/lib/python3.7/site-packages/braket/ocean_plugin/braket_dwave_sampler.py in sample_qubo(self, Q, **kwargs)
    207             {0: 1, 4: 0}
    208         """
--> 209         return super().sample_qubo(Q, **kwargs)
    210 
    211     def sample_qubo_quantum_task(self, Q: Dict[Tuple[int, int], int], **kwargs) -> QuantumTask:

~/anaconda3/envs/Braket/lib/python3.7/site-packages/braket/ocean_plugin/braket_sampler.py in sample_qubo(self, Q, **kwargs)
    281             {0: 1, 4: 0}
    282         """
--> 283         aws_task = self.sample_qubo_quantum_task(Q, **kwargs)
    284         variables = set().union(*Q)
    285         return BraketSampler.get_task_sample_set(aws_task, variables)

~/anaconda3/envs/Braket/lib/python3.7/site-packages/braket/ocean_plugin/braket_dwave_sampler.py in sample_qubo_quantum_task(self, Q, **kwargs)
    237             {0: 1, 4: 0}
    238         """
--> 239         return super().sample_qubo_quantum_task(Q, **kwargs)
    240 
    241     def _process_solver_kwargs(self, **kwargs) -> Dict[str, Any]:

~/anaconda3/envs/Braket/lib/python3.7/site-packages/braket/ocean_plugin/braket_sampler.py in sample_qubo_quantum_task(self, Q, **kwargs)
    340             self._s3_destination_folder,
    341             logger=self._logger,
--> 342             **solver_kwargs,
    343         )
    344 

~/anaconda3/envs/Braket/lib/python3.7/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)
    147             poll_interval_seconds=poll_interval_seconds,
    148             *aws_quantum_task_args,
--> 149             **aws_quantum_task_kwargs,
    150         )
    151 

~/anaconda3/envs/Braket/lib/python3.7/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)
    130             disable_qubit_rewiring,
    131             *args,
--> 132             **kwargs,
    133         )
    134 

~/anaconda3/envs/Braket/lib/python3.7/functools.py in wrapper(*args, **kw)
    838                             '1 positional argument')
    839 
--> 840         return dispatch(args[0].__class__)(*args, **kw)
    841 
    842     funcname = getattr(func, '__name__', 'singledispatch function')

~/anaconda3/envs/Braket/lib/python3.7/site-packages/braket/aws/aws_quantum_task.py in _(problem, aws_session, create_task_kwargs, device_arn, device_parameters, disable_qubit_rewiring, *args, **kwargs)
    448     )
    449 
--> 450     task_arn = aws_session.create_quantum_task(**create_task_kwargs)
    451     return AwsQuantumTask(task_arn, aws_session, *args, **kwargs)
    452 

~/anaconda3/envs/Braket/lib/python3.7/site-packages/braket/aws/aws_session.py in create_quantum_task(self, **boto3_kwargs)
     90             str: The ARN of the quantum task.
     91         """
---> 92         response = self.braket_client.create_quantum_task(**boto3_kwargs)
     93         return response["quantumTaskArn"]
     94 

~/anaconda3/envs/Braket/lib/python3.7/site-packages/botocore/client.py in _api_call(self, *args, **kwargs)
    314                     "%s() only accepts keyword arguments." % py_operation_name)
    315             # The "self" in this scope is referring to the BaseClient.
--> 316             return self._make_api_call(operation_name, kwargs)
    317 
    318         _api_call.__name__ = str(py_operation_name)

~/anaconda3/envs/Braket/lib/python3.7/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params)
    633             error_code = parsed_response.get("Error", {}).get("Code")
    634             error_class = self.exceptions.from_code(error_code)
--> 635             raise error_class(parsed_response, operation_name)
    636         else:
    637             return parsed_response

ValidationException: An error occurred (ValidationException) when calling the CreateQuantumTask operation: The field deviceParameters does not match the expected schema for the selected device. Please refer to the github repo amazon-braket-schemas-python for examples

I did not change any parts except for a bucket name and its prefix. A region I am using is us-west-2.

christianbmadsen commented 3 years ago

We've identified the issue and applied a fix. Thanks for bringing this to our attention.