QJIT

class QJIT(fn, compile_options)[source]

Bases: object

Class representing a just-in-time compiled hybrid quantum-classical function.

Note

QJIT objects are created by the qjit() decorator. Please see the qjit() documentation for more details.

Parameters
  • fn (Callable) – the quantum or classical function to compile

  • compile_options (CompileOptions) – compilation options to use

__call__(*args, **kwargs)

Call self as a function.

aot_compile()

Compile Python function on initialization using the type hint signature.

capture(args)

Capture the JAX program representation (JAXPR) of the wrapped function.

compile()

Compile an MLIR module to LLVMIR and shared library code.

generate_ir()

Generate Catalyst's intermediate representation (IR) as an MLIR module.

jit_compile(args)

Compile Python function on invocation using the provided arguments.

pre_compilation()

Perform pre-processing tasks on the Python function, such as AST transformations.

run(args, kwargs)

Invoke a previously compiled function with the supplied arguments.

__call__(*args, **kwargs)[source]

Call self as a function.

aot_compile()[source]

Compile Python function on initialization using the type hint signature.

capture(args)[source]

Capture the JAX program representation (JAXPR) of the wrapped function.

Parameters

args (Iterable) – arguments to use for program capture

Returns

captured JAXPR PyTreeDef: PyTree metadata of the function output Tuple[Any]: the dynamic argument signature

Return type

ClosedJaxpr

compile()[source]

Compile an MLIR module to LLVMIR and shared library code.

Returns

the compilation result and LLVMIR

Return type

Tuple[CompiledFunction, str]

generate_ir()[source]

Generate Catalyst’s intermediate representation (IR) as an MLIR module.

Returns

the in-memory MLIR module and its string representation

Return type

Tuple[ir.Module, str]

jit_compile(args)[source]

Compile Python function on invocation using the provided arguments.

Parameters

args (Iterable) – arguments to use for program capture

Returns

whether the provided arguments will require promotion to be used with the compiled

function

Return type

bool

pre_compilation()[source]

Perform pre-processing tasks on the Python function, such as AST transformations.

run(args, kwargs)[source]

Invoke a previously compiled function with the supplied arguments.

Parameters
  • args (Iterable) – the positional arguments to the compiled function

  • kwargs – the keyword arguments to the compiled function

Returns

results of the execution arranged into the original function’s output PyTrees

Return type

Any