qat.pipelines.pipeline module

class CompilePipeline(name, model, frontend, middleend, backend, target_data=None, disable_model_validation=False)

Bases: BasePipeline

Implements a pipeline that compiles quantum programs.

In addition to the hardware model and target data, a compilation pipeline consists of the following components:

  1. Frontend: Compiles a high-level language-specific, but target-agnostic, input (e.g., QASM, QIR, …) to QAT’s intermediate representation (IR), QatIR.

  2. Middleend: Takes the QatIR and performs a sequences of passes that validate and optimise the IR, and prepare it for codegen.

  3. Backend: Handles code generation to allow the program to be executed on the target.

In the future, this might be relaxed so compilation pipelines can be defined more abstractly, only requiring the compile() to be implemented.

property backend: BaseBackend
compile(program, compiler_config=None)

Compiles a source program into an executable using the pipeline’s components.

Parameters:
  • program – The source program to compile.

  • compiler_config (Optional[CompilerConfig]) – Configuration options for the compiler, such as optimization and results formatting.

Return type:

tuple[Executable, MetricsManager]

Returns:

An executable of the compiled program for the target device and the metrics manager containing metrics collected during compilation.

property frontend: BaseFrontend
property middleend: BaseMiddleend
class ExecutePipeline(name, model, runtime, target_data=None, disable_model_validation=False)

Bases: BasePipeline

Implements a pipeline that can execute quantum programs.

In addition to the hardware model and target data, an execution pipeline consists of the following components:

  1. Runtime: Manages the execution of the program, including the engine and the post- processing of the results.

  2. Engine: Communicates the compiled program with the target devices, and returns the results.

In the future, this might be relaxed so execution pipelines can be defined more abstractly, only requiring the execute() to be implemented.

property engine: NativeEngine

Returns the engine within the runtime.

execute(package, compiler_config=None)

Uses the runtime and engine in the pipeline to execute a compiled program and process the results.

Checks that the hardware model in the pipeline matches the hardware model used during compilation.

Parameters:
  • package (Executable) – The compiled program to execute.

  • compiler_config (Optional[CompilerConfig]) – Configuration options for the compiler, such as optimization and results formatting.

Return type:

tuple[dict, MetricsManager]

Returns:

A dictionary of results from the execution and the metrics manager containing metrics collected during execution.

property runtime: BaseRuntime
class Pipeline(name, model, frontend, middleend, backend, runtime, target_data=None, disable_model_validation=False)

Bases: CompilePipeline, ExecutePipeline

A composite pipeline that can both compile and execute quantum programs.

This pipeline combines the functionality of both compilation and execution pipelines, allowing for a complete workflow from source program to execution. See CompilePipeline and ExecutePipeline for more details on the components involved in compilation and execution.