strangeworks_qaoa package#

Submodules#

strangeworks_qaoa.sdk module#

class StrangeworksQAOA(resource_slug: str | None = ' ')#

Bases: object

Strangeworks client object.

backends()#
To-Do: Add cross check as to which backends the current user actually has
access to.
Currently, this just lists all backends that could work with the qaoa

service.

get_results(sw_job, calculate_exact_sol=False, display_results=False)#
job_list(update_status=True)#
run(backend, problem, problem_params)#

Method to submit QAOA problem to backend.

Parameters:
  • problem – Hamiltonian whose ground state we want to find. Can be either a networkx graph, a qiskit PauliSumOp operator, a QUBO Matrix or a Dwave BinaryQuadraticModel.

  • problem_params

    nqubits (int): number of qubits shotsin (int): number of shots. Number of times quantum circuit is run

    and measured

    maxiter (int): max number of iteration loops in minimisation p (int): Optional. Number of repetitions in qaoa ansatz alpha (float): Optional. Parameter between 0 and 1, which controls the

    CVar expectation value, - https://arxiv.org/pdf/1907.04769.pdf alpha = 1, usual expectation value alpha < 1, modified expectation value for quantum simulation with classical outputs

    theta0 (array): Optional, initial vector of parameters. optimizer (str): Optional, string specifying classical optimizer,

    default=’SPSA’.

    ansatz (str or QuantumCircuit): Optional, Variational circuit

    parametrized with coefficients to optimise for the energy

    ising (bool): Optional, If True then the input problem is treated as

    an Ising problem. If False or unspecified, then the input problem is treated as a QUBO problem.

    problem_type (str): Optional, If the problem is a quantum encoding of a classical problem (i.e. the solution is one of the basis states)

    then we can make some simplifications and employ some tricks to make the algorithm potentially more optimal.

    optimization_level: IBM only. How much optimization to perform on the

    circuits. Higher levels generate more optimized circuits, at the expense of longer transpilation times. This is based on the optimization_level parameter in qiskit-terra but may include backend-specific optimization. Default: 1.

    • 0: no optimization

    • 1: light optimization

    • 2: heavy optimization

    • 3: even heavier optimization

    resilience_level: IBM only. How much resilience to build against errors.

    Higher levels generate more accurate results, at the expense of longer processing times. Default: 1.

    • 0: No mitigation.

    • 1: Minimal mitigation costs. Mitigate error

    associated with readout errors. * 2: Medium mitigation costs. Typically reduces bias in estimators but is not guaranteed to be zero bias. Only applies to estimator. * 3: Heavy mitigation with layer sampling. Theoretically expected to deliver zero bias estimators. Only applies to estimator.

Returns:

Strangeworks Job object

update_status(sw_job)#

strangeworks_qaoa.serializer module#

pickle_deserializer(p, input_type='dict')#
pickle_serializer(obj, return_type='dict')#

strangeworks_qaoa.utils module#

convert_QUBO_to_Ising(QUBO_mat)#
get_Ham_from_PauliSumOp(H_pauliSum)#
get_Ham_from_QUBO(QUBO_mat)#
get_Ham_from_graph(G)#
get_Ising(G)#
get_PauliSumOp(G)#
get_QUBO(G)#
get_QUBO_from_Ham(H, nodes)#
get_cost_bitstring(bitstring, problem, ising=False)#
get_energy(x, H, ising=False)#

Get the energy of the quantum state

Parameters:
  • x (str) – bitstring of ones and zeros

  • H (List) – Hamiltonian which we are to find the minimum value

Returns:

energy of the state x.

Return type:

En (float)

get_exact_en(G, nodes, ising=False)#
get_graph(nodes, seedin)#

Generate networkX graph where each node is connected to all other nodes. The weights of the connections are random and uniformly distributed between -1 to 1

get_graph_from_Ham(H, nqubits)#
get_nReg_MaxCut_PauliSumOp(n, nodes, seedin)#

Generate PauliSumOp where each node has n connections to a random slection of the other nodes. The weights of the connections are random and uniformly distributed between -1 to 1

get_nReg_MaxCut_QUBO(n, nodes, seedin)#

Generate QUBO matrix where each node has n connections to a random slection of the other nodes. The weights of the connections are random and uniformly distributed between -1 to 1

get_nReg_MaxCut_graph(n, nodes, seedin)#

Generate networkX graph where each node has n connections to a random slection of the other nodes. The weights of the connections are random and uniformly distributed between -1 to 1

get_rand_PauliSumOp(nodes, seedin)#

Generate random PauliSumOp The weights of the connections are random and uniformly distributed between -1 to 1

get_rand_QUBO(nodes, seedin)#

Generate random QUBO matrix The weights of the connections are random and uniformly distributed between -1 to 1

Module contents#

Strangeworks QAOA SDK Extension.