%azure.submit

Warning

This documentation refers to the Classic QDK, which has been replaced by the Modern QDK.

The Modern QDK only supports the '%%qsharp' magic command.

Summary

Submits a job to an Azure Quantum workspace.

Description

This magic command allows for submitting a Q# operation or function to be run on the specified target in the current Azure Quantum workspace. The command returns immediately after the job is submitted.

The Azure Quantum workspace must have been previously initialized using the %azure.connect magic command, and an execution target for the job must have been specified using the %azure.target magic command.

Required parameters

  • Q# operation or function name. This must be the first parameter, and must be a valid Q# operation or function name that has been defined either in the notebook or in a Q# file in the same folder.
  • Arguments for the Q# operation or function must also be specified as key=value pairs.

Optional parameters

  • jobName=<string>: Friendly name to identify this job. If not specified, the Q# operation or function name will be used as the job name.
  • jobParams=<JSON key:value pairs>: Provider-specific job parameters expressed in JSON as one or more key:value pairs to be passed to the execution target. Values must be strings.
  • shots=<integer> (default=500): Number of times to repeat execution of the specified Q# operation or function.

Possible errors

  • NotConnected: Not connected to any Azure Quantum workspace.
  • NoTarget: No execution target has been configured for Azure Quantum job submission.
  • NoOperationName: No Q# operation name was specified for Azure Quantum job submission.
  • InvalidTarget: The specified target is not enabled in this workspace. Please make sure the target name is valid and that the associated provider is added to your workspace. To add a provider to your quantum workspace in the Azure Portal, see https://aka.ms/AQ/Docs/AddProvider
  • UnrecognizedOperationName: The specified Q# operation name was not recognized.
  • InvalidEntryPoint: The specified Q# operation cannot be used as an entry point for Azure Quantum job submission.
  • JobSubmissionFailed: Failed to submit the job to the Azure Quantum workspace.

Examples for %azure.submit

Example 1

Submit a Q# operation defined as operation MyOperation(a : Int, b : Int) : Result for execution on the active target in the current Azure Quantum workspace:

In []: %azure.submit MyOperation a=5 b=10
Out[]: Submitting MyOperation to target provider.qpu...
       Job successfully submitted for 500 shots.
          Job name: MyOperation
          Job ID: <Azure Quantum job ID>
       <detailed properties of submitted job>

Example 2

Submit a Q# operation defined as operation MyOperation(a : Int, b : Int) : Result for execution on the active target in the current Azure Quantum workspace, specifying a custom job name, number of shots, and provider-specific job parameters:

In []: %azure.submit MyOperation a=5 b=10 jobName="My job" shots=100 jobParams={"Key1":"Val1","Key2":"Val2"}
Out[]: Submitting MyOperation to target provider.qpu...
       Job successfully submitted for 100 shots.
          Job name: My job
          Job ID: <Azure Quantum job ID>
       <detailed properties of submitted job>