Strangeworks-Azure
The strangeworks-azure
package provides a similar experience to Microsoft Azure.
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:
- Set up your environment and install
strangeworks-Azure
- In the portal, Activate Microsoft Azure to create a Resource
- Replace
your-api-key
with your key from the Portal homepage - 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!