Skip to content

Commit

Permalink
docs: Update new QPU compiler backend documentation, fix search funct…
Browse files Browse the repository at this point in the history
…ion (#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 e2fc78e.

* Revert "dependency spec fixes"

This reverts commit 4a15ae5.

* Revert "add sphinx_toolbox"

This reverts commit 45e2701.

* Revert "try sphinx autodoc extensions"

This reverts commit 398f762.

* Update docs/source/introducing_v4.rst

Co-authored-by: Michael Bryant <[email protected]>

* Update docs/source/introducing_v4.rst

Co-authored-by: Kalan <[email protected]>

* 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 <[email protected]>
Co-authored-by: Kalan <[email protected]>
  • Loading branch information
3 people authored Dec 8, 2023
1 parent adcba42 commit 1397bae
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"sphinx.ext.mathjax",
"sphinx.ext.ifconfig",
"sphinx.ext.viewcode",
"sphinxcontrib.jquery",
"nbsphinx",
"recommonmark",
]
Expand All @@ -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
Expand Down
15 changes: 10 additions & 5 deletions docs/source/introducing_v4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -114,18 +114,23 @@ 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 <https://github.com/rigetti/qcs-sdk-rust/blob/760df515ff9c88c1739fd69aeb00d8d38884345d/crates/python/qcs_sdk/qpu/translation.pyi#L139>`_ 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
from pyquil.api import get_qc, QPUCompilerAPIOptions
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
Expand Down
10 changes: 9 additions & 1 deletion pyquil/api/_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
# limitations under the License.
##############################################################################
from typing import Any, Dict, Optional
from typing_extensions import TypeAlias
from warnings import warn

from qcs_sdk import QCSClient
from qcs_sdk.qpu.rewrite_arithmetic import rewrite_arithmetic
from qcs_sdk.qpu.translation import (
get_quilt_calibrations,
translate,
TranslationOptions as QPUCompilerAPIOptions,
TranslationOptions as _TranslationOptions,
TranslationBackend,
)
from qcs_sdk.compiler.quilc import QuilcClient
Expand All @@ -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 <https://github.com/rigetti/qcs-sdk-rust/blob/760df515ff9c88c1739fd69aeb00d8d38884345d/crates/python/qcs_sdk/qpu/translation.pyi#L139>`_
""" # noqa: E501


class QPUCompilerNotRunning(Exception):
pass
Expand Down

0 comments on commit 1397bae

Please sign in to comment.