From 5a7c1b2d863e7bbd4c84f9658e4fb63aa95596af Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Wed, 21 Feb 2024 10:13:40 -0800 Subject: [PATCH] update docs --- docs/source/the_quantum_computer.rst | 23 +++++++++++++++++++++++ pyquil/api/_compiler.py | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/docs/source/the_quantum_computer.rst b/docs/source/the_quantum_computer.rst index 33daf77cc..4c4165ab1 100644 --- a/docs/source/the_quantum_computer.rst +++ b/docs/source/the_quantum_computer.rst @@ -277,6 +277,29 @@ want a script that works for both QVM and QPU targets, you could do the followin # Working with a QPU - refresh calibrations qc.compiler.get_calibration_program(force_refresh=True) +Requesting a job cancellation +----------------------------- + +Jobs submitted to a QPU are queued for execution before they are run. While a job is pending execution, you can request +that the job be cancelled with `:py:meth:~pyquil.api.QPU#cancel`. This functionality is unavailable on the QVM, so you +can use a similar startegy to above to make sure the Quantum Abstract Machine (QAM) backing the QuantumComputer is +indeed a QPU to safely call this method: + +.. code:: python + + from pyquil.api import QPU + + job_handle = qc.qam.execute(p) + + if isinstance(qc.qam, QPU): + try: + qc.qam.cancel(job_handle) + print("Job was cancelled") + except QpuApiError: + # If this error was raised, then the job failed to be cancelled. + result = qc.qam.get_result(job_handle) + + Providing your own quantum processor topology ============================================= diff --git a/pyquil/api/_compiler.py b/pyquil/api/_compiler.py index 759806e1f..8accdefdd 100644 --- a/pyquil/api/_compiler.py +++ b/pyquil/api/_compiler.py @@ -146,7 +146,7 @@ def _fetch_calibration_program(self) -> Program: response = get_quilt_calibrations( quantum_processor_id=self.quantum_processor_id, ) - return Program(response.quilt) + return Program(response) def get_calibration_program(self, force_refresh: bool = False) -> Program: """