Repository navigation
Memory Management for MLIR - #685
Conversation
|
Hi @JoelMathewC @willow-ahrens @kylebd99, i have pushed the memory management model in these branch. Please take a look and let me know if you have any comments or feedback. Thanks! |
Merging this PR will not alter performance
Comparing Footnotes
|
|
I took a look at this and it should work! Although I'm concerned about the overhead from the python callback. I do think restricting ownership to either python or MLIR rather than both is a good choice. With the Julia backend we gave Julia full ownership (that's because of reasons that are finch.jl specific). I think Pytorch which lowers to C code has C managing the memory. Could you take a look at why they chose to do that, maybe they had a reason that we might not be seeing right now. |
|
I think we allow frameworks to choose who allocs memory by changing buffers. so the malloc-buffer is handled by C, but the numpy-buffer uses callbacks. we could just have an mlir-buffer and then have mlir support a numpy-buffer with callbacks. |
|
@willow-ahrens I will make a memref buffer to follow the theme of MLIR and MLIR would own this buffer. MLIR would use callbacks for numpy buffer for the Python end. @JoelMathewC The problem with giving MLIR full ownership of the buffer is that we currently handle serialized buffer and numpy buffer as two seperate copies of the same address. If the serialized buffer gets realloc without updating the numpy buffer, both would go out of sync and cause segfaults. We fix this error by using a callback. |
|
Hi everyone, I have finished this PR. I have made some changes from the previous md. The biggest change was making the slots from immutable to mutable. I made this change because it would support resizing more flexibly. This warrants some refactoring in mlir.py. This PR enables many things: firstly, we can finally support sparse outputs in mlir (as seen in the test_sparse_update.py). Secondly, mlir supports zero-copy construction of mlir buffer. Thirdly, we have a precise write-up of the MLIR resizing documentation In this PR, I had to change one of the test as Resize was lowered to an assert. My PR changed Resize so I had to change that specific test. When I was testing for the sparse output, I was returning errors in the loop nodes for incorrect assignment of loop variables so I added a function called loop_carried_name to fix that error. |
* Added dev_doc.md for mlir codegen * First draft of memref_buffer * Edit: added sparse output and finished memeory management * fix description * Added test for memrefbuffer * Fin
* Added dev_doc.md for mlir codegen * First draft of memref_buffer * Edit: added sparse output and finished memeory management * fix description * Added test for memrefbuffer * Fin
…ngs (#703) * fixing LRU implementation * precommit error fixing * cached_matrix form implemented * [pre-commit.ci] pre-commit autoupdate (#712) updates: - [github.com/astral-sh/ruff-pre-commit: v0.16.9 → v0.16.10](astral-sh/ruff-pre-commit@v0.16.9...v0.16.10) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * `pixi update` and fix new `ty` lints (#710) * `pixi update` * Fix type checking errors caught by new version of `ty`. * Memory Management for MLIR (#685) * Added dev_doc.md for mlir codegen * First draft of memref_buffer * Edit: added sparse output and finished memeory management * fix description * Added test for memrefbuffer * Fin * Add sponsors section to README (#714) Added sponsors section with acknowledgments for NSF and Codspeed. * Update sponsorship section in README.md (#715) * Fix stale public exports blocking wildcard imports (#686) * Fix stale public exports blocking wildcard imports Signed-off-by: 李永祺 <[email protected]> * Preserve importable public exports and validate the export list Restore the existing Reflector and element_type exports from their public submodules. Keep unavailable property names out of __all__, normalize its static order and duplicates, and cover availability, uniqueness, and wildcard imports. Assisted-by: OpenAI Codex (model: GPT-6, autonomous) Signed-off-by: 李永祺 <[email protected]> * Keep the requested public export invariant test Remove the redundant object identity and wildcard import tests, along with their unused imports, as requested in review. Assisted-by: OpenAI Codex (model: GPT-6, autonomous) Signed-off-by: 李永祺 <[email protected]> * Keep Ruff export ordering after rebasing main Remove the RUF022 suppression and redundant ordering assertion as requested in review. Preserve export availability and uniqueness checks. Validate 3093 public-export and interface tests, with 54 skips, and all repository pre-commit hooks. Assisted-by: OpenAI Codex (model: GPT-6, autonomous) Signed-off-by: 李永祺 <[email protected]> --------- Signed-off-by: 李永祺 <[email protected]> * precommig * fix --------- Signed-off-by: 李永祺 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Hameer Abbasi <[email protected]> Co-authored-by: Yu Sheng <[email protected]> Co-authored-by: Willow Ahrens <[email protected]> Co-authored-by: Dori <[email protected]> Co-authored-by: Willow Ahrens <[email protected]>
Fixes #636 Fixes #637