Skip to content

Instantly share code, notes, and snippets.

@erichulburd
Last active October 14, 2019 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erichulburd/b4a86e54de787664d38afc658b1d5ed0 to your computer and use it in GitHub Desktop.
Save erichulburd/b4a86e54de787664d38afc658b1d5ed0 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Hello QMI\n",
"\n",
"Welcome to your QMI! Your Quantum Machine Image is a virtual development and execution environment for quantum programming. It is hosted in close physical proximity to the QPUs in Rigetti’s quantum data center. This integrated platform eliminates the network latency found in web API access models, allowing you to iterate faster. It comes with a pre-configured Jupyter server that is a great way to get started writing quantum programs, and running them on the QVM and the QPU. Don't forget to also try connecting to your QMI via `ssh` (Secure Shell), and moving files to and from your QMI using Secure Copy (`scp`). For more information on this, check out our [documentation](https://www.rigetti.com/qcs/docs/getting-started-with-your-qmi#qmi).\n",
"\n",
"In this beginner's example, we are going to run a simple `hello_qmi()`. This function composes a simple quantum program, compiles it, and then runs it on the target device of your choice: either the QVM or a QPU. It is located in the `hello_qmi.py` file in the home folder of your QMI at `/home/forest/hello_qmi.py`. You can browse to this file directly in Jupyter, or find it by `ssh`ing into your QMI."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Imports\n",
"\n",
"To import `hello_qmi`, we must include in our path the folder in our QMI where it's located: one folder up from our current directory, or `..`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import sys\n",
"sys.path.append(os.path.abspath(os.path.join('..')))\n",
"from hello_qmi import hello_qmi"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Run against the QVM Simulator\n",
"\n",
"The function `hello_qmi` takes an optional argument naming the device to target (the QVM or a QPU). If no argument is provided, the default device is a `9q-generic-qvm`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\"\"\"Reminder! Please take a look at hello_qmi.py, where this function resides,\n",
"to see what program it is creating, how it compiles, and how it runs against\n",
"the QVM.\"\"\"\n",
"hello_qmi()"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment