Skip to main content

Strangeworks-Azure

PyPI version

The strangeworks-azure package provides a similar experience to Microsoft Azure.

šŸ“‘ Package Documentation

Installationā€‹

To get started, make sure you have Python 3.10 or above (installation) and are familiar with setting up and using virtual environments.

pip install -U pip && pip install strangeworks-azure

Usageā€‹

Here's a simple example of creating a Bell state with Microsoft Azure.

Before running:

  1. Set up your environment and install strangeworks-Azure
  2. In the portal, Activate Microsoft Azure to create a Resource
  3. Replace your-api-key with your key from the Portal homepage
  4. Run the script!
Azure: Hello World
import strangeworks
from qiskit import QuantumCircuit
from strangeworks_azure import StrangeworksBackend

# 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', 'azure-quantum')


# Optional: You can list the Braket devices available on
# the Strangeworks Platform
backends = StrangeworksBackend.get_backends()
print("Available backends:")
for backend in backends:
print(f" - {backend.name} ({backend.status})")

# create a simple quantum circuit
circuit = QuantumCircuit(2, 2)
circuit.h(0)
circuit.cnot(0,1)
circuit.measure([0,1], [0,1])

# Choose a device (an IonQ-hosted simulator in this case)
ionq = StrangeworksBackend("ionq.simulator")

# Execute the circuit
print("\nšŸ¤– Executing Circuit...\n")

task = ionq.run(circuit, shots=100)

# 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")

task.status()

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

# View the counts (also visible in the Portal in a chart šŸ“Š)
print(f"šŸŽ‰ šŸ“Š Counts: {result.get('counts')}\n")

šŸ„³ Success! You may view your job in the portal.

šŸ˜… Something went wrong? Find us in Slack!