catalyst.QJIT¶
- class QJIT(fn, compile_options)[source]¶
Bases:
CatalystCallable
Class representing a just-in-time compiled hybrid quantum-classical function.
Note
QJIT
objects are created by theqjit()
decorator. Please see theqjit()
documentation for more details.- Parameters:
fn (Callable) – the quantum or classical function to compile
compile_options (CompileOptions) – compilation options to use
- Variables:
original_function – This attribute stores fn, the quantum or classical function object to compile, as is, without any modifications
jaxpr – This attribute stores the Jaxpr compiled from the function as a string.
mlir – This attribute stores the MLIR compiled from the function as a string.
qir – This attribute stores the QIR in LLVM IR form compiled from the function as a string.
Attributes
obtain the MLIR representation after canonicalization
obtain the MLIR representation after optimization
LLVMIR textual representation.
- mlir¶
obtain the MLIR representation after canonicalization
- mlir_opt¶
obtain the MLIR representation after optimization
- qir¶
LLVMIR textual representation.
Methods
__call__
(*args, **kwargs)Call self as a function.
Compile Python function on initialization using the type hint signature.
call_with_wrapper
(wrapper, call_args, ...)Adds an additional wrapper to the wrapped function before invoking the __call__ method of this class.
capture
(args, **kwargs)Capture the JAX program representation (JAXPR) of the wrapped function.
compile
()Compile an MLIR module to LLVMIR and shared library code.
Generate Catalyst's intermediate representation (IR) as an MLIR module.
jit_compile
(args, **kwargs)Compile Python function on invocation using the provided arguments.
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_with_wrapper(wrapper, call_args, call_kwargs)¶
Adds an additional wrapper to the wrapped function before invoking the __call__ method of this class. The wrapper is expected to act like a decorator.
- capture(args, **kwargs)[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, **kwargs)[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