How to export Bloqade code to Aquila through Amazon Braket

To run a problem on Aquila, the first step is to convert the Hamiltonian from its standard Bloqade format to one that can be taken by the Amazon Braket service. We need the Bloqade_schema package, and then use hardware_transform to make the conversion.

using BloqadeSchema

transformed_h, transform_info = hardware_transform(Hamiltonian);

Still, one should always check if the transformed Hamiltonian is acceptable given hardware constraints. We can test that via the function validate

validate(transformed_h)

To submit jobs to Aquila, all one needs now is their AWS Braket credentials, which can be generated from the AWS Braket package, and the function submit_to_braket, which takes as input the desired Hamiltonian, the number of shots for the experiment, and, of course, the credentials.

Note: submit_to_braket can take as input the original Bloqade Hamiltonian as well, before transforming.hardware_transform is invoked automatically to make sure the Hamiltonian satisfies the hardware requirements. Still, the process of transforming and validating a Hamiltonian by hand is advised, to ensure calculations don’t go wrong.

using AWS

access_key_id = "your_access_key_id"

secret_key = "your_secret_key"

token = "your_token"

credentials = AWS.AWSCredentials(access_key_id, secret_key, token)

task = submit_to_braket(transformed_h, 100; credentials=credentials)

And that is it! The final disclaimer is that once jobs have been sent to Braket, the data that comes back is not really part of the Bloqade infrastructure. To interact with the results, one has to rely on the Braket.jl package and functions like state (that will tell you if your task ran, is in the queue, was cancelled, or failed) and result or get_measurements, to read the actual data. For more info, take a lookt at Braket.jl’s documentation

access_key_id and secret_key are available from AWS Console. But where to get “token” from?

Hi @aniruddha ,

If your AWS account is SSO (Single Sign-On) Enabled you’ll see a “token” section. Otherwise, if you don’t see it then you don’t need to provide it :smiley:

If you run into any issues with explicitly passing your credentials in, feel free to pass them in as environment variables and Braket.jl should be able to detect them. You can also explicitly add them through the ENV dictionary that Julia always has containing the environment variables it’s detected.

Hope that helps!

1 Like