Error running Amazon Braket SV1 via Strangeworks

27 Views Asked by At

I've been successfully trialing and running jobs on the Strangeworks configuration that we use in the office (Rigetti), and have been trying to run jobs on Amazon Braket instead. I've included my config adapted from the template which is currently throwing an error. What am I missing here?

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

strangeworks.authenticate(api_key=" ", store_credentials=False)
sw_qaoa = StrangeworksQAOA(resource_slug=" ")

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

################################
######## Define algorithm parameters
problem_params = {
    "nqubits": nodes,    # Number of variables in the problem / number of qubits
    "maxiter": 50,  # Maximum number of iterations in algorithm
    "shotsin": 500,  # Number of times quantum circuit is measured at each iteration
    "p": 1,              # Optional Input: Controls the depth of the Quantum Circuit ansatz. Default p=1
    "theta0": [1.0, 1.0],  # Optional Input: Starting point for variational parameters. If specified must be equal to 2p
    "alpha": 0.1,  # Optional Input: Cvar parameter, float between 0 and 1 - https://arxiv.org/pdf/1907.04769.pdf. Default alpha=1.0
    "optimizer": "COBYLA",  # Optional Input: Classical optimizer to use: 
                            # Possible Values:
                            # 'COBYLA' (Default), 'Nelder-Mead', 'Powell', 'CG', 'BFGS', 'Newton-CG', 'L-BFGS-B', 'TNC', 
                            # 'SLSQP', 'trust-constr', 'dogleg', 'trust-ncg', 'trust-exact', 'trust-krylov'
                            # Additionals for IBM backends: 'SPSA', 'NFT'
                                          
    "ising": False,  # Optional Input: is the problem an Ising problem or a QUBO problem, i.e. are the values of the variables {-1/2,+1/2} (Ising) or {0,1} (QUBO, Default)
    "warm_start": False,  # Optional Input: Run warm start qaoa or not - https://arxiv.org/abs/2009.10095. Default False: Standard QAOA ansatz
    "qrr": False,  # Optional Input: Quantum Relax and Round QAOA algorithm - https://arxiv.org/abs/2307.05821. Default False: Standard QAOA
    }

backend = "SV1" # Change this to another ibm backend name or an aws device name
sw_job = sw_qaoa.run(backend, problem, problem_params)

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

There are 1 best solutions below

0
davidryan On BEST ANSWER

Going out on a limb here, but worth checking, have you installed the Python packages specifically for this QAOA operation? If you're coming over from a previous config, you may need to check that this is the case.

Install packages using pip: ​

pip install -U pip && pip install strangeworks-qaoa

This is the package you're importing into python per your example and an easy one to overlook isn't present. ​

from strangeworks_qaoa.sdk import StrangeworksQAOA