Installing Locally

Follow the steps below to use the Forest SDK locally.

Installing locally is most useful for development using a QVM. Running programs against a QPU requires a reservation as well as network access to the QPU (available via your provisioned JupyterLab IDE).

Install the Compiler and QVM

Start by downloading the quilc and qvm binaries for your operating system.

If you'd like to skip installing quilc and qvm locally, you can run them from pre-created Docker images instead. For example:

docker run --rm -it -p 5555:5555 rigetti/quilc -P -S
docker run --rm -it -p 5000:5000 rigetti/qvm -S

macOS

To install on macOS, double-click forest-sdk.dmg once it's downloaded. Then double-click forest-sdk.pkg and follow the on-screen instructions.

When you're finished, move on to verify the installation.

To uninstall, remove the following files:

  • /usr/local/bin/qvm

  • /usr/local/bin/quilc

  • /usr/local/share/man/man1/qvm.1

  • /usr/local/share/man/man1/quilc.1

Windows

To install on Windows, double-click forest-sdk.msi once it's downloaded, then follow the on-screen instructions.

When you're finished, move on to verify the installation.

To uninstall:

  1. Use the Windows search bar to search for "Add or remove programs"

  2. Uninstall the application named "Forest SDK for Windows"

Linux

There are three ways to install on Linux: deb, rpm, or bare-bones.

deb

Unpack the downloaded tarball and change to its resulting directory by running the following in a terminal (replacing <version> with the downloaded version of the SDK):

tar -xf forest-sdk-linux-deb.tar.bz2
cd forest-sdk-<version>-linux-deb

From here, run the following command to complete the install (replacing <version> with the downloaded version of the SDK):

sudo ./forest-sdk-<version>-linux-deb.run

When you're finished, move on to verify the installation.

To uninstall, run:

sudo apt remove forest-sdk

rpm

Unpack the downloaded tarball and change to its resulting directory by running the following in a terminal (replacing <version> with the downloaded version of the SDK):

tar -xf forest-sdk-linux-rpm.tar.bz2
cd forest-sdk-<version>-linux-rpm

From here, run the following command to complete the install (replacing <version> with the downloaded version of the SDK):

sudo ./forest-sdk-<version>-linux-rpm.run

When you're finished, move on to verify the installation.

To uninstall, run:

sudo yum uninstall forest-sdk

or

sudo rpm -e forest-sdk

bare-bones

The bare-bones installation only contains the executable binaries and manual pages — it doesn’t contain any of the requisite dynamic libraries. As such, installation doesn’t require administrative or sudo privileges.

First, unpack the downloaded tarball and change to its resulting directory by running the following in a terminal (replacing <version> with the downloaded version of the SDK):

tar -xf forest-sdk-linux-barebones.tar.bz2
cd forest-sdk-<version>-linux-barebones

From here, run the following command to complete the install (replacing <version> with the downloaded version of the SDK):

./forest-sdk-<version>-linux-barebones.run

Upon successful installation, this will have created a new directory rigetti in your home directory that contains all of the binary and documentation artifacts.

To uninstall, remove the ~/rigetti directory.

This method of installation requires you, through any means, to install shared libraries for BLAS, LAPACK, and libffi.

On a Debian-derivative system, this could be accomplished with:

sudo apt-get install liblapack-dev libblas-dev libffi-dev libzmq3-dev

Or on any rhel-derivative systems (e.g. Amazon Linux) with:

sudo yum install -y lapack-devel blas-devel epel-release
sudo yum install -y zeromq3-devel

Verify Installation

To check that the binaries were properly installed, run the following commands in a terminal. They should each execute successfully and print version numbers.

quilc --version
qvm --version

Install pyQuil

We publish new versions of pyQuil to PyPI. You can install pyQuil just like any other PyPI package.

pyQuil requires Python 3.7, 3.8, or 3.9

Using pip:

pip install pyquil

Using poetry:

poetry install pyquil

If you'd like to install pyQuil from source, see the pyQuil GitHub repository.

Using a Virtual Environment

We highly recommend installing into a virtual environment. For example, you can create a virtual environment named .venv and activate it with the following command prior to installing pyQuil or other packages:

python -m venv .venv
source .venv/bin/activate

To deactivate the virtual environment, run:

deactivate

Start the Compiler and QVM

Open a terminal window and start the compiler in server mode:

quilc -P -S

Then, open a second terminal window and start the QVM in server mode:

qvm -S

For more details on using the quilc and qvm binaries, see the quilc Reference and the QVM Reference.

Run a Program

Now that the compiler and QVM servers are running, try running a simple program. Save the following Python script to a file called pyquil_bell.py:

pyQuil v3
pyQuil v2
pyQuil v3
from pyquil import get_qc, Program
from pyquil.gates import H, CNOT, MEASURE
from pyquil.quilbase import Declare
program = Program(
Declare("ro", "BIT", 2),
H(0),
CNOT(0, 1),
MEASURE(0, ("ro", 0)),
MEASURE(1, ("ro", 1)),
).wrap_in_numshots_loop(10)
qc = get_qc("2q-qvm")
print(qc.run(qc.compile(program)).readout_data.get("ro"))
pyQuil v2
from pyquil import get_qc, Program
from pyquil.gates import H, CNOT, MEASURE
from pyquil.quilbase import Declare
program = Program(
Declare("ro", "BIT", 2),
H(0),
CNOT(0, 1),
MEASURE(0, ("ro", 0)),
MEASURE(1, ("ro", 1)),
).wrap_in_numshots_loop(10)
qc = get_qc("2q-qvm")
print(qc.run(qc.compile(program)))

Then, run your script from a terminal:

python pyquil_bell.py

If all goes well, you'll see results similar to the following:

[[1 1]
[0 0]
[1 1]
[0 0]
[1 1]
[0 0]
[1 1]
[1 1]
[1 1]
[0 0]]

Using JupyterLab

If you prefer working with Jupyter notebooks instead of Python files, you can install and run JupyterLab easily by running the following in a terminal:

pip install jupyterlab
jupyter lab

We recommend doing this from a virtual environment.

If you're not familiar with using JupyterLab, we recommend this handy guide.