Skip to content

Azure Quantum loader#

Introduction#

The Azure Quantum loader lets a solver access the Azure Quantum target selected for a QCentroid job without hardcoding Azure credentials, workspace configuration, resource IDs, or target names in the source code.

Use AzureLoader when your solver submits jobs directly to Azure Quantum targets. Use AzureQiskitLoader when your solver works with Azure Quantum through a Qiskit-compatible backend.

Import#

from QCentroidLoaders import AzureLoader

For Qiskit-compatible Azure Quantum backends:

from QCentroidLoaders import AzureQiskitLoader

Get the selected target#

Call AzureLoader.get_target() when your solver is ready to submit the job:

target = AzureLoader.get_target()

In the platform runtime, this target is resolved from the provider and backend selected by the user when launching the job.

When running locally without platform initialization, AzureLoader.get_target() returns a lightweight local Azure development target. This fallback is not a full Azure Quantum emulator.

For Qiskit-compatible Azure Quantum backends, use:

backend = AzureQiskitLoader.get_target()

When running locally without platform initialization, AzureQiskitLoader.get_target() returns a local Qiskit simulator.

Example pattern#

qcentroid.py
from typing import Any
import logging

from QCentroidLoaders import AzureLoader

logger = logging.getLogger("qcentroid-user-log")
logging.basicConfig()
logger.setLevel(logging.INFO)

def run(
    input_data: dict[str, Any],
    solver_params: dict[str, Any],
    extra_arguments: dict[str, Any],
) -> dict[str, Any]:
    logger.info("Preparing Azure Quantum job...")

    target = AzureLoader.get_target()
    logger.info(f"Using Azure Quantum target: {target}")

    shots = solver_params.get("shots", 100)

    # Build the provider-specific program or circuit here.
    # The exact submission call depends on the Azure Quantum package and
    # target type used by your solver.
    program = build_program(input_data, solver_params)

    logger.info("Sending job to Azure Quantum...")
    job = target.submit(program, shots=shots)

    logger.info("Obtaining job result...")
    result = job.get_results()

    logger.info(f"Result from Azure Quantum target: {result}")

    return {
        "status": "ok",
        "provider": "azure-quantum",
        "target": str(target),
        "result": result,
    }

def build_program(
    input_data: dict[str, Any],
    solver_params: dict[str, Any],
) -> Any:
    # Replace this placeholder with the program format expected by the
    # Azure Quantum target used by your solver.
    return input_data

Platform execution#

When this solver runs in QCentroid:

  1. The user selects the solver and the Azure Quantum target in the dashboard or API.
  2. The platform injects the required provider credentials and workspace configuration.
  3. AzureLoader.get_target() returns the configured target.
  4. The solver submits the job and returns the result to QCentroid.

Local execution#

For local development, install the local loader package from the public QCentroid loaders repository when it is available:

pip install git+<loaders-repository-url>

Then configure your Azure Quantum credentials and workspace settings as described in that repository if you want to run against a remote Azure Quantum target locally. If you do not initialize the loader with a remote target, the loader returns a local development target.

Best practices#

  • Keep shots and other target options configurable through solver_params.
  • Validate the generated program locally or against a simulator before running on paid hardware.
  • Avoid logging Azure credentials, workspace secrets, subscription IDs when they are sensitive, or provider tokens.

QCentroid Loaders overview

Azure Quantum cost control best practices