> ## Documentation Index
> Fetch the complete documentation index at: https://docs.haiqu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Amazon Braket

> Explore different hardware modalities and providers by running on AWS Braket devices

### Overview

As a platform-agnostic toolkit, Haiqu SDK is connected with QPUs (Quantum Processing Units) available via AWS Braket platform. This integration allows users to execute their algorithms on different hardware modalities and access, among else, devices offered by IQM, IonQ and Rigetti.

<Tip>
  ### Key Features of the Integration

  **Direct Access to AWS Braket via access tokens:** Haiqu SDK users can execute quantum algorithms and experiments on AWS Braket devices without needing extensive configuration.

  **Enhanced Workflow Management:** Haiqu SDK offers tools to manage and optimize jobs submitted to AWS Braket QPUs, making the development and execution of quantum programs more efficient.
</Tip>

### How to Access AWS Braket QPUs

The integration is designed to be user-friendly, with a focus on simplifying the process of accessing quantum resources. Below is a step-by-step guide to using Haiqu SDK for this purpose.

<Steps>
  <Step title="Configure AWS access credentials">
    Users must have valid access keys and IDs on AWS to run jobs on AWS Braket devices. If you don't yet have the credentials, please refer to the [AWS documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html). After you have acquired the credentials you can do one of the 3 things:

    1. Use `aws configure` CLI command:

    Credentails are then stored in `~/.aws/credentials` and `~/.aws/config` local files.

    2. Use the `save_aws_credentials()`function:

    ```python theme={null}
    haiqu.save_aws_credentials(
    	aws_access_key_id: "<AWS_ACCESS_KEY_ID>",
        aws_secret_access_key: "<AWS_SECRET_ACCESS_KEY>",
        aws_default_region: "<AWS_DEFAULT_REGION>",
    )
    ```

    3. Pass explicitly in `options` dictionary:

    ```python theme={null}
    options = {
        "aws_access_key_id": "<AWS_ACCESS_KEY_ID>",
        "aws_secret_access_key": "<AWS_SECRET_ACCESS_KEY>",
        "aws_default_region": "<AWS_DEFAULT_REGION>",
    }
    ```

    <Note>
      We recommend to issue and use temporary AWS credentails with limited access to AWS resources.
    </Note>
  </Step>

  <Step title="Configure Haiqu SDK">
    Before executing your job on an AWS Braket device you may need to define (or extend) the `options` dictionary with the relevant properties of the execution (e.g. what optimization level you would like to use in transpilation).

    ```python theme={null}
    options = {
        "transpilation_options": {
            "optimization_level": 3,
        },
    	# if you chose Option 3 in the previous step
        "aws_access_key_id": "<AWS_ACCESS_KEY_ID>",
        "aws_secret_access_key": "<AWS_SECRET_ACCESS_KEY>",
        "aws_default_region": "<AWS_DEFAULT_REGION>",
    }
    ```
  </Step>

  <Step title="Submit Quantum Jobs">
    Once authenticated, users can submit quantum circuits or algorithms to AWS Braket QPUs directly through Haiqu SDK. The SDK handles all backend operations, including job queuing, execution, and result retrieval.

    <CodeGroup>
      ```python by device_id theme={null}
      results_qpu = haiqu.run(
          haiqu_circuit,
          shots=1000,
          device_id="aws_ionq_aria_1",
          options=options,
      )
      ```

      ```python by device theme={null}
      device = haiqu.get_device("aws_ionq_aria_1")

      results_qpu = haiqu.run(
          haiqu_circuit,
          shots=1000,
          device=device,
          options=options,
      )
      ```
    </CodeGroup>
  </Step>

  <Step title="Monitor and Retrieve Results">
    Haiqu SDK provides monitoring tools to track the status of quantum jobs in real-time. Once a job is completed, users can retrieve the results and analyze them within the SDK environment.

    ```python theme={null}
    results_qpu.retrieve_status()

    results_qpu.to_json()
    ```

    <Tip>
      ### Benefits of the Integration

      **Simplified Access**: The integration eliminates complex setup procedures and allows users to focus on quantum application development.

      **Scalability**: Whether you are a researcher, developer, or enthusiast, Haiqu SDK enables scalable access to quantum resources tailored to your needs.

      **Flexibility**: The SDK supports a wide range of quantum programming libraries, making it a versatile tool for diverse projects.
    </Tip>
  </Step>
</Steps>

### Conclusion

Haiqu SDK's integration with AWS Braket QPUs marks an important step in making quantum computing more accessible and practical for a broad audience. Users can securely and efficiently access quantum hardware from different providers, opening new possibilities in research, development, and innovation. Whether you’re an experienced quantum programmer or a curious beginner, Haiqu SDK provides the tools you need to explore the quantum frontier with ease.

 
