Suppose I have the simple circuit

bell = Circuit().h(0).cnot(control=0, target=1)


and I am running it in a notebook inside AWS. How can I download the results to my local pc when

1. I use the LocalSimulator().

2. An IonQ or a Rigetti device?

When you run on an IonQ or Rigetti device (or any other QPU or AWS-managed simulator) your results are stored in the S3 bucket/folder you specified at runtime:

# the name of the bucket
my_bucket = "example-bucket"
# the name of the folder in the bucket
my_prefix = "simulation-output"
s3_folder = (my_bucket, my_prefix)

# cloud-based managed simulator/QPU to run your circuit
device = AwsDevice('arn:aws:braket:::device/qpu/ionq/ionQdevice')

# execute the circuit


To download your results, navigate to that S3 bucket/folder, click on results.json, and then in the upper right corner, you will see a Download button.

The results of runs using the local simulator are not stored in S3, or written to any file:

device = LocalSimulator()


However, if you were so inclined, you could recreate the same behavior by doing a json.dump of the local quantum task result into a local file, and then use the upload_to_s3 or upload_local_data method from the braket.aws.AwsSession module.

For example, if you run

result = task.result()


followed by

import json

with open('result.json', 'w', encoding='utf-8') as f:
json.dump(str(result), f, ensure_ascii=False, indent=4)


a file result.json would be created in your working directory. In the AWS Braket notebook filesystem, the full path would be /home/ec2-user/SageMaker/result.json. Clicking the jupyter icon in the top left corner will take you back to the filesystem GUI, where you will see the results file present. Back in the notebook, you can then use the previously mentioned functions from the AwsSession module to upload this file to S3.

To reiterate, the results of circuits run using the LocalSimulator are not automatically sent to S3. The procedure that I've described is just one of many ways that you can explicitly write the results into a file, and manually upload to S3. This is possible both from jupyter on your local computer, and from inside of your AWS Braket notebook instance, and works effectively the same way.

• I don't understand the last part, but I think I had in mind something different. If you run in LocalSimulator in the cloud (not in e.g. in a laptop), how do you do to send the results to the s3 bucket? Feb 22 at 12:48
• @user2820579 Let me know if the edits I made help, or if it's still unclear Feb 22 at 16:18
• @user2820579 Why would you want to run the LocalSimulator in the cloud when you can use aws_sv1_simulator, which will send results to the bucket? Feb 22 at 16:18
• SIMPLE, sv1 is not free! Feb 23 at 8:47