catalyst
catalyst copied to clipboard
Support importing MLIR file or stream into Catalyst
Summary
Catalyst should provide a way to import an MLIR file or stream directly into its workflow. This would enable users to leverage MLIR interoperability by ingesting pre-existing IRs or those generated by other tools.
Motivation
- Enable advanced transformations and analysis before ingestion.
- Improve flexibility for researchers and advanced users.
Expected behavior
- Users can import an MLIR file or provide an MLIR stream (e.g., via stdin, etc.) into Catalyst.
- Need to validate if the MLIR instructions are supported in the backend.
import catalyst.load
program_mlir_str = "MLIR CONTENT"
program_mlir_path = "path to mlir"
qjit_cir_1 = catalyst.load(program_mlir_str)
qjit_cir_2 = catalyst.load(filepath=program_mlir_path)
# Execute the program
qjit_cir_1()
qjit_cir_2()
@sengthai not exactly what you requested but take a look at this PR https://github.com/PennyLaneAI/catalyst/pull/1334 :)
@sengthai not exactly what you requested but take a look at this PR #1334 :)
Nice! Thanks @erick-xanadu! The core functions are there! I think that approach is helpful for debugging and for users who try to execute their MLIR as well. We should take further action on your PR.
Besides Erick's approach, it's hard to implement what you suggest above @sengthai because we need the type signature of the program in order to correctly provide arguments and interpret results. At some point I think we were inspecting the IR and attempt to deduce the type signature automatically, but it wasn't without issues (at least with the llvmir I remember it did not work).