Strangeworks SDK Braket Extension

PyPI

The service uses the Strangeworks API accessed through the Strangeworks python SDK. For more information on the general python sdk see our docs.

To get started you will need to install the SDK and authenticate using your API key. Your API key can be found on the dashboard page of the Strangeworks platform at https://portal.strangeworks.com.

Installation

The Strangeworks Braket SDK is installed using pip

pip install strangeworks-braket

Test your installation by running the following

$ python
>>> import strangeworks_braket
>>> print(strangeworks_braket.__version__)

Authentication

Authenticate using the strangeworks.authenticate() method

$ python
>>> import strangeworks
>>> strangeworks.authenticate(api_key="<your-api-key>")

Basic Usage

The SDK provides a Braket extension that can be used to run quantum circuits on the Strangeworks platform.

import strangeworks
from braket.circuits impot Circuit
from strangeworks_braket import StrangeworksDevice

# get your API key from the Strangeworks Portal
strangeworks.authenticate(
   api_key="your-api-key",
)

# Optional: If you have multiple instances (resources) of a product,
# you can set the resource to use here.
# strangeworks.set_resource_for_product('your-resource-slug', 'amazon-braket')


# Optional: You can list the Braket devices available on
# the Strangeworks Platform
devices = StrangeworksDevice.get_devices()
print("Available devices:")
for device in devices:
   print(f"  - {device.name} ({device.arn})")

# create a simple quantum circuit
bell_state = Circuit().h(0).cnot(0, 1)

# Choose a device (an AWS-hosted simulator in this case)
tn1 = StrangeworksDevice("arn:aws:braket:::device/quantum-simulator/amazon/tn1")

# Execute the circuit
print("\n🤖 Executing Circuit...\n")

task = tn1.run(bell_state, 1000)

# At this point, the job is running on the Strangeworks Platform.
# You can check the status of the job in the Portal, even if
# stop this script.
print(f"⏳ Job {task.id} submitted!\n")

# Lots of good info in here
result = task.result()

# View the counts (also visible in the Portal in a chart 📊)
print(f"🎉 📊 Counts: {result.measurement_counts}\n")

Python SDK Module Reference