Main Content

cancel

Request to cancel quantum task

Since R2023a

Installation Required: This functionality requires MATLAB Support Package for Quantum Computing.

Description

cancel(task) submits a request to cancel the specified task sent to the Amazon® Web Services (AWS®) or the IBM® Qiskit® Runtime Services. The request to cancel the task is granted only if the task status is "queued" or "running". Otherwise, this function call has no effect. A successfully canceled task changes the task status to "finished".

Note

The cost of running the task may not be billed depending on when the task is canceled. For more details, consult the documentation provided by the quantum device provider, such as Amazon Braket Documentation or IBM Quantum access plans.

example

Examples

collapse all

Create a quantum circuit that consists of a Hadamard gate and a controlled X gate to entangle two qubits.

gates = [hGate(1); cxGate(1,2)];
c = quantumCircuit(gates);

Connect to a remote quantum device through AWS. Create a task that runs the circuit on the device.

dev = quantum.backend.QuantumDeviceAWS("Lucy");
task = run(c,dev)
task = 

  QuantumTaskAWS with properties:

    TaskARN: "arn:aws:braket:us-west-1:123456789012:quantum-task/ab01234c-0123-4567-89a0-1abc23d4efg5"
     Status: "queued"

Cancel the task while it is queued.

cancel(task)

Create a quantum circuit that consists of a Hadamard gate and a controlled X gate to entangle two qubits.

gates = [hGate(1); cxGate(1,2)];
c = quantumCircuit(gates);

Connect to a remote quantum device through the IBM Qiskit Runtime Services. Create a task that runs the circuit on the device.

dev = quantum.backend.QuantumDeviceIBM("ibmq_qasm_simulator");
task = run(c,dev)
task = 

  QuantumTaskIBM with properties:

         TaskID: "123abcd4efa5abcde123"
      SessionID: <missing>
    AccountName: "your_account_name"
         Status: "queued"

Cancel the task while it is queued.

cancel(task)

Input Arguments

collapse all

Task that runs the circuit on a quantum device, specified as a QuantumTaskAWS or a QuantumTaskIBM object.

Version History

Introduced in R2023a