Strangeworks SDK QAOA 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 Peptide design SDK is installed from a private git repo using pip

pip install strangeworks-qaoa

Test your installation by running the following

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

Authentication#

Authenticate using the strangeworks.authenticate() method

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

Basic Usage#

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

import strangeworks
from strangeworks_qaoa.sdk import StrangeworksQAOA
import strangeworks_qaoa.utils as utils

# Authenticate with the Strangeworks API and set the resource for the
# product (this is only needed for products with more than one resource)
strangeworks.authenticate(api_key=os.getenv("STRANGEWORKS_API_KEY"))
sw_qaoa = StrangeworksQAOA(resource_slug="resource-slug"))

################################
######## Create problem from QUBO
nodes = 4
seed = 0
n = 3
problem = utils.get_nReg_MaxCut_QUBO(n, nodes, seed)

maxiter = 50
shotsin = 1000
theta0 = [1.0, 1.0]
p = 1
alpha = 0.1
optimizer = "COBYLA"
ansatz = "qaoa_strangeworks"

problem_params = {
    "nqubits": nodes,
    "maxiter": maxiter,
    "shotsin": shotsin,
    "theta0": theta0,   # optional
    "p": p,             # optional
    "alpha": alpha,     # optional
    "optimizer": optimizer, # optional
    "ansatz": ansatz,   # optional
    }


backend = "ibmq_qasm_simulator"
sw_job = sw_qaoa.run(backend, problem, problem_params)

result = sw_qaoa.get_results(sw_job,calculate_exact_sol=True)

Python SDK Module Reference#