Issue with Amazon braket (region)

Dear, When i try to run this command

dev_remote = qml.device(
“braket.aws.qubit”,
device_arn=device_arn,
wires=n_wires,
s3_destination_folder=s3_folder,
parallel=True,
)

I get the error:

NoRegionError: You must specify a region

The Region of my S3 bucket is : US West (N. California) us-west-1

Full error msg is:

---------------------------------------------------------------------------
NoRegionError                             Traceback (most recent call last)
<ipython-input-2-f8e60c8e036e> in <module>
      5 n_wires = 25
      6 
----> 7 dev_remote = qml.device(
      8     "braket.aws.qubit",
      9     device_arn=device_arn,

~\anaconda3\envs\Quantum python 3_8\lib\site-packages\pennylane\__init__.py in device(name, *args, **kwargs)
    222 
    223         # load device
--> 224         return plugin_device_class(*args, **options)
    225 
    226     raise DeviceError("Device does not exist. Make sure the required plugin is installed.")

~\anaconda3\envs\Quantum python 3_8\lib\site-packages\braket\pennylane_plugin\braket_device.py in __init__(self, wires, device_arn, s3_destination_folder, shots, poll_timeout_seconds, poll_interval_seconds, aws_session, parallel, max_parallel, max_connections, max_retries, **run_kwargs)
    260         **run_kwargs,
    261     ):
--> 262         device = AwsDevice(device_arn, aws_session=aws_session)
    263         if DeviceActionType.JAQCD not in device.properties.action:
    264             raise ValueError(f"Device {device.name} does not support quantum circuits")

~\anaconda3\envs\Quantum python 3_8\lib\site-packages\braket\aws\aws_device.py in __init__(self, arn, aws_session)
     79         super().__init__(name=None, status=None)
     80         self._arn = arn
---> 81         self._aws_session = AwsDevice._aws_session_for_device(arn, aws_session)
     82         self._properties = None
     83         self._provider_name = None

~\anaconda3\envs\Quantum python 3_8\lib\site-packages\braket\aws\aws_device.py in _aws_session_for_device(device_arn, aws_session)
    310             return AwsDevice._aws_session_for_qpu(device_arn, aws_session)
    311         else:
--> 312             return aws_session or AwsSession()
    313 
    314     @staticmethod

~\anaconda3\envs\Quantum python 3_8\lib\site-packages\braket\aws\aws_session.py in __init__(self, boto_session, braket_client, config)
     38             self.braket_client = braket_client
     39         else:
---> 40             self.braket_client = self.boto_session.client("braket", config=self._config)
     41 
     42     #

~\anaconda3\envs\Quantum python 3_8\lib\site-packages\boto3\session.py in client(self, service_name, region_name, api_version, use_ssl, verify, endpoint_url, aws_access_key_id, aws_secret_access_key, aws_session_token, config)
    256 
    257         """
--> 258         return self._session.create_client(
    259             service_name, region_name=region_name, api_version=api_version,
    260             use_ssl=use_ssl, verify=verify, endpoint_url=endpoint_url,

~\anaconda3\envs\Quantum python 3_8\lib\site-packages\botocore\session.py in create_client(self, service_name, region_name, api_version, use_ssl, verify, endpoint_url, aws_access_key_id, aws_secret_access_key, aws_session_token, config)
    832             retryhandler, translate, response_parser_factory,
    833             exceptions_factory, config_store)
--> 834         client = client_creator.create_client(
    835             service_name=service_name, region_name=region_name,
    836             is_secure=use_ssl, endpoint_url=endpoint_url, verify=verify,

~\anaconda3\envs\Quantum python 3_8\lib\site-packages\botocore\client.py in create_client(self, service_name, region_name, is_secure, endpoint_url, verify, credentials, scoped_config, api_version, client_config)
     83             self._endpoint_resolver, scoped_config, client_config,
     84             service_signing_name=service_model.metadata.get('signingName'))
---> 85         client_args = self._get_client_args(
     86             service_model, region_name, is_secure, endpoint_url,
     87             verify, credentials, scoped_config, client_config, endpoint_bridge)

~\anaconda3\envs\Quantum python 3_8\lib\site-packages\botocore\client.py in _get_client_args(self, service_model, region_name, is_secure, endpoint_url, verify, credentials, scoped_config, client_config, endpoint_bridge)
    324             self._response_parser_factory, self._loader,
    325             self._exceptions_factory, config_store=self._config_store)
--> 326         return args_creator.get_client_args(
    327             service_model, region_name, is_secure, endpoint_url,
    328             verify, credentials, scoped_config, client_config, endpoint_bridge)

~\anaconda3\envs\Quantum python 3_8\lib\site-packages\botocore\args.py in get_client_args(self, service_model, region_name, is_secure, endpoint_url, verify, credentials, scoped_config, client_config, endpoint_bridge)
     69                         endpoint_url, verify, credentials, scoped_config,
     70                         client_config, endpoint_bridge):
---> 71         final_args = self.compute_client_args(
     72             service_model, client_config, endpoint_bridge, region_name,
     73             endpoint_url, is_secure, scoped_config)

~\anaconda3\envs\Quantum python 3_8\lib\site-packages\botocore\args.py in compute_client_args(self, service_model, client_config, endpoint_bridge, region_name, endpoint_url, is_secure, scoped_config)
    145 
    146         s3_config = self.compute_s3_config(client_config)
--> 147         endpoint_config = self._compute_endpoint_config(
    148             service_name=service_name,
    149             region_name=region_name,

~\anaconda3\envs\Quantum python 3_8\lib\site-packages\botocore\args.py in _compute_endpoint_config(self, service_name, region_name, endpoint_url, is_secure, endpoint_bridge, s3_config)
    216         if service_name == 'sts':
    217             return self._compute_sts_endpoint_config(**resolve_endpoint_kwargs)
--> 218         return self._resolve_endpoint(**resolve_endpoint_kwargs)
    219 
    220     def _compute_s3_endpoint_config(self, s3_config,

~\anaconda3\envs\Quantum python 3_8\lib\site-packages\botocore\args.py in _resolve_endpoint(self, service_name, region_name, endpoint_url, is_secure, endpoint_bridge)
    298     def _resolve_endpoint(self, service_name, region_name,
    299                           endpoint_url, is_secure, endpoint_bridge):
--> 300         return endpoint_bridge.resolve(
    301             service_name, region_name, endpoint_url, is_secure)
    302 

~\anaconda3\envs\Quantum python 3_8\lib\site-packages\botocore\client.py in resolve(self, service_name, region_name, endpoint_url, is_secure)
    399                 is_secure=True):
    400         region_name = self._check_default_region(service_name, region_name)
--> 401         resolved = self.endpoint_resolver.construct_endpoint(
    402             service_name, region_name)
    403 

~\anaconda3\envs\Quantum python 3_8\lib\site-packages\botocore\regions.py in construct_endpoint(self, service_name, region_name, partition_name)
    131         # Iterate over each partition until a match is found.
    132         for partition in self._endpoint_data['partitions']:
--> 133             result = self._endpoint_for_partition(
    134                 partition, service_name, region_name)
    135             if result:

~\anaconda3\envs\Quantum python 3_8\lib\site-packages\botocore\regions.py in _endpoint_for_partition(self, partition, service_name, region_name, force_partition)
    146                 region_name = service_data['partitionEndpoint']
    147             else:
--> 148                 raise NoRegionError()
    149         # Attempt to resolve the exact region for this partition.
    150         if region_name in service_data['endpoints']:

NoRegionError: You must specify a region.

Thanks in advance!

Hey @NikSchet!

Did you run aws configure as detailed here (which requires an install of the AWS CLI).

Alternatively, you can create or edit your credentials in the ~/.aws/credentials and ~/.aws/config locations.

Let me know if this works!

Thanks for the fast reply. Indeed i followed the instructions and changed region to “us-west-1” and it worked. No when i train the model i get the error

ValueError: s3_destination_folder must be of size 2 with a 'bucket' and 'key' respectively.

The error is raised when i run the model.fit command:

historyh = modelh.fit(X_train, y_train,
                      validation_data=(X_test, y_test),
                      callbacks=[es,lr_history,lrate,CSVLogger('training.log')],
                      epochs=epochsH,
                      batch_size=batch_size)

Thanks!

Hey @NikSchet,

Oh that’s weird, what have you set for the s3_folder variable? If you are following the approach here, you need to update the bucket and foldername to your S3 bucket. For example, if your bucket is called pl-braket and your folder is sim_results, you’d have:

s3_folder=("pl-braket", "sim_results")

You can create an S3 bucket from the AWS management console.

Also, it looks like you’re training a relatively complicated hybrid QML model. To first debug any problems with accessing your S3 bucket, it might be an idea to try out the simple usage examples here.

Thanks a lot, so i think the problem was with AWS since after some hour the problem solved by itself (i also restarted kernel multiple times)

1 Like