Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
MarquessV committed Feb 21, 2024
1 parent 84576d4 commit 5a7c1b2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions docs/source/the_quantum_computer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=============================================

Expand Down
2 changes: 1 addition & 1 deletion pyquil/api/_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down

0 comments on commit 5a7c1b2

Please sign in to comment.