AWS Braket requires an S3 bucket to store quantum task results. This is a mandatory requirement - all quantum tasks executed on Braket devices (simulators and QPUs) store their output in S3.
The easiest way to set up your S3 infrastructure is using our provided Terraform configuration:
cd terraform
# Copy example configuration
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your bucket name
nano terraform.tfvars
# Deploy infrastructure
terraform init
terraform plan
terraform apply
After deployment, Terraform will output the exact configuration for your QClojure backend:
;; Use the values from terraform output
(def backend
(braket/create-braket-simulator
{:s3-bucket "your-terraform-bucket-name"
:s3-key-prefix "braket-results/"
:region "us-east-1"}))
See terraform/README.md for detailed Terraform documentation.
The Terraform setup includes optional CloudWatch logging for monitoring Braket tasks:
# For development/experiments - disable CloudWatch to save costs
enable_cloudwatch = false
# For production - enable CloudWatch with log retention
enable_cloudwatch = true
cloudwatch_retention_days = 90 # Valid values: 1,3,5,7,14,30,60,90,120,150,180,365,400,545,731,1827,3653
Cost Considerations:
aws s3 mb s3://my-braket-results-bucket --region us-east-1
Create a bucket policy to restrict access to your AWS account:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "BraketTaskResults",
"Effect": "Allow",
"Principal": {
"Service": "braket.amazonaws.com"
},
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::my-braket-results-bucket",
"arn:aws:s3:::my-braket-results-bucket/*"
]
}
]
}
(require '[org.soulspace.qclojure.adapter.backend.braket :as braket])
;; For simulators
(def simulator-backend
(braket/create-braket-simulator {:s3-bucket "my-braket-results-bucket"
:s3-key-prefix "simulations/"}))
;; For QPUs
(def qpu-backend
(braket/create-braket-qpu "arn:aws:braket:us-east-1::device/qpu/rigetti/aspen-m-3"
{:s3-bucket "my-braket-results-bucket"
:s3-key-prefix "quantum-hardware/"
:region "us-east-1"}))
Your AWS credentials need the following permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"braket:*",
"s3:GetObject",
"s3:PutObject",
"s3:ListBucket"
],
"Resource": [
"*",
"arn:aws:s3:::my-braket-results-bucket",
"arn:aws:s3:::my-braket-results-bucket/*"
]
}
]
}
Braket stores results in your S3 bucket with the following structure:
my-braket-results-bucket/
├── braket-results/ # Default key prefix
│ ├── task-1234567890-uuid/
│ │ ├── results.json # Measurement results
│ │ └── task-metadata.json # Task execution metadata
│ └── task-1234567891-uuid/
│ ├── results.json
│ └── task-metadata.json
└── experiments/ # Custom key prefix
└── bell-states/
└── task-1234567892-uuid/
├── results.json
└── task-metadata.json
If you forget to specify an S3 bucket, you'll get this error:
ExceptionInfo: S3 bucket is required for Braket backend. AWS Braket stores all quantum task results in S3.
{:type :missing-s3-bucket,
:config {...},
:help "Provide :s3-bucket in the config map, e.g., {:s3-bucket \"my-braket-results\"}"}
;; Test that your backend can be created successfully
(def test-backend
(braket/create-braket-simulator {:s3-bucket "my-braket-results-bucket"}))
;; Check that the configuration is correct
(println (:config test-backend))
;; Should show your S3 bucket configuration
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
Ctrl+k | Jump to recent docs |
← | Move to previous article |
→ | Move to next article |
Ctrl+/ | Jump to the search field |