From 1397baef5b04077461b70cf1fa806d2c04339033 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Thu, 7 Dec 2023 16:09:58 -0800 Subject: [PATCH] docs: Update new QPU compiler backend documentation, fix search function (#1708) * update v2 backend docs * try sphinx autodoc extensions * add sphinx_toolbox * dependency spec fixes * remove broken extension * Revert "remove broken extension" This reverts commit e2fc78eb697bf98f1e367c0ecfae663bd306c376. * Revert "dependency spec fixes" This reverts commit 4a15ae59e529fbdc97d743ef037cde2621978f4d. * Revert "add sphinx_toolbox" This reverts commit 45e270118c8aa50a09813f810e0f3e566944d490. * Revert "try sphinx autodoc extensions" This reverts commit 398f7623fc6a9d96eaed8f808ecdd26de25290a3. * Update docs/source/introducing_v4.rst Co-authored-by: Michael Bryant * Update docs/source/introducing_v4.rst Co-authored-by: Kalan <22137047+kalzoo@users.noreply.github.com> * test different method of aliasing * what if we add a docstring? * explicit type alias * get TypeAlias from typing_extensions * Sphinx wont render docstrings to type aliases, so this will have to do * add jQuery --------- Co-authored-by: Michael Bryant Co-authored-by: Kalan <22137047+kalzoo@users.noreply.github.com> --- docs/source/conf.py | 2 ++ docs/source/introducing_v4.rst | 15 ++++++++++----- pyquil/api/_compiler.py | 10 +++++++++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 646ccae22..f097ebe90 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -35,6 +35,7 @@ "sphinx.ext.mathjax", "sphinx.ext.ifconfig", "sphinx.ext.viewcode", + "sphinxcontrib.jquery", "nbsphinx", "recommonmark", ] @@ -53,6 +54,7 @@ pygments_style = "sphinx" todo_include_todos = True # intersphinx_mapping = { "python": ("https://docs.python.org/3/", None) } +autodoc_type_aliases = {"QPUCompilerAPIOptions": "pyquil.api._qpu_compiler.QPUCompilerAPIOptions"} # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output diff --git a/docs/source/introducing_v4.rst b/docs/source/introducing_v4.rst index bf8bc61c3..db3f01f0b 100644 --- a/docs/source/introducing_v4.rst +++ b/docs/source/introducing_v4.rst @@ -21,7 +21,7 @@ Here is an example of how you might use a memory map in practice: from pyquil.gates import RZ from pyquil.quil import Program - qc = get_qc("Ankaa-1") + qc = get_qc("Ankaa-9Q-1") program = Program() theta = program.declare("theta", "REAL") program += RZ(theta, 0) @@ -50,7 +50,7 @@ In pyQuil v4, Gateway is enabled by default and it is generally recommended to k from pyquil.api import get_qc, ExecutionOptionsBuilder, ConnectionStrategy from pyquil.quil import Program - qc = get_qc("Ankaa-1") + qc = get_qc("Ankaa-9Q-1") program = Program() exe = qc.compile(program) @@ -114,7 +114,10 @@ you should use the ``get_raw_readout_data`` method to access the raw data and bu Using the new QPU Compiler Backend ---------------------------------- -Rigetti's next-generation QPU compiler is accessible through pyQuil v4. This new backend is still in development, so while it will eventually become the default, it is currently in limited access. If you have access, you can configure your compiler to use it using the new ``QPUCompilerAPIOptions`` class: +Rigetti's next-generation QPU compiler is accessible through pyQuil v4. This backend is required for Ankaa-family QPUs and can be configured with the new :py:class:`~pyquil.api.QPUCompilerAPIOptions` class. This class +is a type alias of ``qcs-sdk-python``'s ``TranslationOptions``. See its `API documentation `_ for more information on all the available parameters. + +.. TODO: When qcs-sdk-python has live documentation, we should setup intersphinx so it can be linked to directly. .. code:: python @@ -122,10 +125,12 @@ Rigetti's next-generation QPU compiler is accessible through pyQuil v4. This new from pyquil.quil import Program program = Program() - qc = get_qc("Ankaa-1") + qc = get_qc("Ankaa-9Q-1") api_options = QPUCompilerAPIOptions() - api_options.use_backend_v2() + api_options.v2( + passive_reset_delay_seconds=0.0002 + ) # Option 1: Apply to all compiled programs qc.compiler.api_options = api_options diff --git a/pyquil/api/_compiler.py b/pyquil/api/_compiler.py index 6ddcd9df5..7cb726039 100644 --- a/pyquil/api/_compiler.py +++ b/pyquil/api/_compiler.py @@ -14,6 +14,7 @@ # limitations under the License. ############################################################################## from typing import Any, Dict, Optional +from typing_extensions import TypeAlias from warnings import warn from qcs_sdk import QCSClient @@ -21,7 +22,7 @@ from qcs_sdk.qpu.translation import ( get_quilt_calibrations, translate, - TranslationOptions as QPUCompilerAPIOptions, + TranslationOptions as _TranslationOptions, TranslationBackend, ) from qcs_sdk.compiler.quilc import QuilcClient @@ -33,6 +34,13 @@ from pyquil.quilatom import MemoryReference from pyquil.quilbase import Declare +QPUCompilerAPIOptions: TypeAlias = _TranslationOptions +""" +An alias of `qcs-sdk-python`'s `TranslationOptions` class. + +See `TranslationOptions in qcs-sdk-python `_ +""" # noqa: E501 + class QPUCompilerNotRunning(Exception): pass