From b511bb1bcd54dff4959ade4d257a14b51121d43b Mon Sep 17 00:00:00 2001 From: Jake Selig Date: Tue, 2 Sep 2025 14:59:02 -0600 Subject: [PATCH 1/2] fix: clarify what printing a compiled program's output looks like for different targets --- docs/source/compiler.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/source/compiler.rst b/docs/source/compiler.rst index 1b923ea79..bf8c64344 100644 --- a/docs/source/compiler.rst +++ b/docs/source/compiler.rst @@ -37,9 +37,9 @@ as in the following: qc = get_qc("9q-square-qvm") - ep = qc.compile(Program(H(0), CNOT(0,1), CNOT(1,2))) + executable = qc.compile(Program(H(0), CNOT(0,1), CNOT(1,2))) - print(ep) + print(executable) .. Cannot actually check the output because quilc is non-deterministic, but still need to @@ -49,7 +49,7 @@ as in the following: ... -with output +with output (see note below) .. code:: text @@ -67,6 +67,8 @@ with output RX(-pi/2) 2 RZ(pi/2) 2 +Note that printing ``executable`` here — the result of a ``qc.compile`` call — only results in a readable native Quil program like the above if the Quantum Computer is a QVM. When compiling for live QPU targets, this printed output will be encrypted and opaque because of program translation. See :ref:`Compilation metadata ` for instructions on how to convert a program native gates independent of program translation. + The compiler connection is also available directly via the property ``qc.compiler``. The precise class of this object changes based on context (e.g., :py:class:`~pyquil.api.QPUCompiler`, :py:class:`~pyquil.api.QVMCompiler`), but it always conforms to the interface laid out by :py:class:`~pyquil.api.AbstractCompiler`: @@ -100,8 +102,8 @@ the previous example snippet is identical to the following: np = qc.compiler.quil_to_native_quil(p, protoquil=True) print(np) - ep = qc.compiler.native_quil_to_executable(np) - print(ep) + exe = qc.compiler.native_quil_to_executable(np) + print(exe) .. testoutput:: quilc :hide: @@ -147,6 +149,8 @@ To instruct the compiler to produce Quil code that can be executed on a QPU, you JupyterLab notebook's compiler) then specifying ``protoquil=False`` will override the server and forcefully disable protoquil. Specifying ``protoquil=None`` defers to the server's choice. +.. _compilation_metadata: + Compilation metadata ==================== From 22e05ccbcf69fe2dfd611aecb4505bba1f49a205 Mon Sep 17 00:00:00 2001 From: Jake Selig Date: Tue, 2 Sep 2025 15:01:27 -0600 Subject: [PATCH 2/2] fix: grammar --- docs/source/compiler.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/compiler.rst b/docs/source/compiler.rst index bf8c64344..9571f958d 100644 --- a/docs/source/compiler.rst +++ b/docs/source/compiler.rst @@ -67,7 +67,7 @@ with output (see note below) RX(-pi/2) 2 RZ(pi/2) 2 -Note that printing ``executable`` here — the result of a ``qc.compile`` call — only results in a readable native Quil program like the above if the Quantum Computer is a QVM. When compiling for live QPU targets, this printed output will be encrypted and opaque because of program translation. See :ref:`Compilation metadata ` for instructions on how to convert a program native gates independent of program translation. +Note that printing ``executable`` here — the result of a ``qc.compile`` call — only results in a readable native Quil program like the above if the Quantum Computer is a QVM. When compiling for live QPU targets, this printed output will be encrypted and opaque because of program translation. See :ref:`Compilation metadata ` for instructions on how to convert a program to native gates independent of program translation. The compiler connection is also available directly via the property ``qc.compiler``. The precise class of this object changes based on context (e.g., :py:class:`~pyquil.api.QPUCompiler`,