Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support job cancellation for QPUs, perform automatic retries on transient network failures. #1741

Merged
merged 4 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 strategy 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
Loading
Loading