Skip to main content

Rigetti QCS

Rigetti Quantum Cloud Service (QCS) is a cloud service that provides access to the latest Rigetti quantum computing resources.

Backends

To learn more about the Rigetti backends available through Strangeworks, see the Rigetti Backends page.

Strangeworks-Rigetti

PyPI version

📑 Package Documentation

The strangeworks-rigetti package allows users to run construct and solve problems using pyQuil, the Rigetti quantum computing library. Rigetti documentation lives at https://docs.rigetti.com/qcs/ ​ To get started, make sure you have Python 3.10 or 3.11 (installation) and are familiar with setting up and using virtual environments.

Install packages using pip: ​

pip install -U pip && pip install strangeworks-rigetti

​ Import package into python: ​

import strangeworks
from strangeworks_rigetti import get_qc

​ Before running:

  1. Set up your environment and install strangeworks-rigetti and strangeworks
  2. In the portal, Activate Strangeworks Rigetti Service to create a Resource and get the resource id and replace it with resource-id below
  3. Replace your-api-key below with your key from the Portal homepage
  4. Use examples below to utilize the various functionality. See Examples section below for an example script.

Authenticate with strangeworks python sdk using users API token:

strangeworks.authenticate(api_key="your-api-key")

​ Get a quantum computing resource using the rigetti sdk extension by supplying a quantum computing backend name, the resource slug and a qvm setting

qc = get_qc(
"Ankaa-2", resource_slug=resource_id, as_qvm=True
) # as_qvm=False will produce a billable transaction for using hardware

Example

​ Here is an example on how to run a simple circuit on a rigetti quantum computing resource

import pyquil
from pyquil.gates import CNOT, MEASURE, H

import strangeworks
from strangeworks_rigetti import get_qc

strangeworks.authenticate(api_key="your-api-key")

# get rigetti resource
res = strangeworks.get_resource_for_product("rigetti")

# as_qvm=True uses the quantum virtual machine
# as_qvm=False sends a billable job to an actual Rigetti machine
qc = get_qc(
"Ankaa-2", resource_slug=res.slug, as_qvm=True
)

program = pyquil.Program()
program = program.inst(H(0))
program = program.inst(CNOT(0, 1))
ro = program.declare("ro", "BIT", 2)
program = program.inst(MEASURE(0, ro[0]))
program = program.inst(MEASURE(1, ro[1]))
program.wrap_in_numshots_loop(10)

res = qc.run(program, circuit_type="qasm")

print(res)

🥳 Success! You may view your job in the portal.

😅 Something went wrong? Find us in Slack!