catalyst
catalyst copied to clipboard
Make it easier to modify and recompile IR
Context:
This PR introduces two new methods in frontend/catalyst/debug/compiler_functions.py.
get_pipeline_output(fn: QJIT, pass_name: str) -> strfetches the IR string after the given pipeline passpass_name.replace_ir(fn: QJIT, pass_name: str, new_ir: str) -> Noneoverwrites the IR and specify a starting pass (exclusive)pass_namefor the next compilation.
The possible options for pass_name are
- MILR:
mlir,HLOLoweringPass,QuantumCompilationPass,BufferizationPass, andMLIRToLLVMDialect - LLVM:
llvm_ir,CoroOpt,O2Opt,Enzyme, andlast
Note that last denotes the IR right before object file generation.
Changes:
QJITnow has an extra flagoverwrite_irto specify the new IR for compilation.CompilerOptionsnow has an extra flagstartAfterPassto specify the compilation start after the given pass.CompilerOutputnow has an extra flagreachTargetPassto indicate if the given pass is reached.- Update documentation
Debugging Tips.
Limitations
- To get IRs from
get_pipeline_output, the function must be compiled withkeep_intermediate=True - We must define a function first for recompilation.
Related GitHub Issues: [sc-67088]