catalyst
catalyst copied to clipboard
Migrating to One-Shot Bufferization
Context:
MLIR removed old bufferization (Conversion-Based bufferization) passes and introduced new One-Shot-Bufferization pass. [Link]
Note that Ownership-based Buffer Deallocation will be handled in a different PR.
- ~Only update llvm and mhlo.~ Jax sticks with 0.4.28.
Description of the Change: Newly Added Bufferization Interface: Comparing implemented interface methods with BufferizationOpInterface.td. Operation List: https://github.com/PennyLaneAI/catalyst/blob/8d0324db672d507d651b46fd65e9058455a9bb03/mlir/lib/Bufferization.md
Major Updates:
- Create
one-shot-bufferizeinterface forcatalyst-bufferize,gradient-bufferize, andquantum-bufferize. - The operations to be bufferized should be registered with
declarePromisedInterfaces. - Bufferize
FunctionOPInterfacelikeForwardOPandReverseOpneed to accessOneShotModuleBufferize. Gradient.ReturnOPisReturnLikenow to support bufferization.- Set
function-boundary-type-conversiontoidentity-layout-mapto avoid invalid type conversion betweenMemref<T>andMemref<T, Stride<...>> - Use
allow-return-allocs-from-loopsflag to avoidscp.forandscp.whileto avoid arg and yield types mismatch - Async tests need
copy-before-writeflag
Required LLVM and MHLO Patches:
- Make
OneShotModuleBufferizesupportFunctionOpInterfaceinstead ofFuncOP. https://github.com/llvm/llvm-project/pull/110322 FunctionOpInterfacepatch to mhlo. https://github.com/openxla/xla/pull/17935- Update MemRefType conversion in CallOp bufferization. https://github.com/llvm/llvm-project/pull/105929
Related GitHub Issues: [sc-71487] [Discourse discussion about migration] [Discord discussion about FunctionOpInterface and FuncOp] [Discord discussion about memory layout] [LLVM Upstream]
https://github.com/llvm/llvm-project/commit/7f04a8ad131881b5a58b97c8191733ed42d18e20
youtube link with discussion about one-shot bufferizer pdf with info