%azure.target

Summary

Sets or displays the active execution target for Q# job submission in an Azure Quantum workspace.

Description

This magic command allows for specifying or displaying the execution target for Q# job submission in an Azure Quantum workspace.

The Azure Quantum workspace must have been previously initialized using the %azure.connect magic command magic command. The specified execution target must be available in the workspace and support execution of Q# programs.

Optional parameters

  • The target ID to set as the active execution target for Q# job submission. If not specified, the currently active execution target is displayed.

Possible errors

  • NotConnected: Not connected to any Azure Quantum workspace.
  • 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
  • NoTarget: No execution target has been configured for Azure Quantum job submission.

Target capabilities

When setting a target, the target capability is set to the maximum capability level supported by the given target, such that all capabilities allowed by the target are allowed in subsequent Q# compilation functions and operations.

You can restrict target capability levels further by using qsharp.azure.target_capability(). This may be useful, for instance, when comparing functionality between different targets.

Examples for %azure.target

Example 1

Sets the current target for Q# job submission to provider.qpu:

In []: %azure.target provider.qpu
Out[]: Loading package Microsoft.Quantum.Providers.Provider and dependencies...
        Active target is now provider.qpu
        <detailed properties of active execution target>

Example 2

Clears the current target information:

In []: %azure.target --clear

Example 3

Displays the current target and all available targets in the current Azure Quantum workspace:

In []: %azure.target
Out[]: Current execution target: provider.qpu
        Available execution targets: provider.qpu, provider.simulator
        <detailed properties of active execution target>