# Should Julia use MLIR in the future?

**URL:** <https://discourse.julialang.org/t/should-julia-use-mlir-in-the-future/110459>\
**Category:** Internals & Design\
**Tags:** question\
**Created:** [February 20, 2024, 3:25pm UTC](https://discourse.julialang.org/t/should-julia-use-mlir-in-the-future/110459 "2024-02-20T15:25:54Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [February 20, 2024, 5:40pm UTC](https://discourse.julialang.org/t/should-julia-use-mlir-in-the-future/110459/6 "2024-02-20T17:40:01Z")

</div>

To add onto this, it’s worth pointing out that MLIR and Mojo are not magic. The “ML” in MLIR stands for “multi-level”; think [Inception](https://en.wikipedia.org/wiki/Inception) for LLVM rather than Machine Learning. In fact, LLVM IR is a MLIR “dialect”. Most Mojo code running on CPU (and likely a lot running on GPU) is “lowered” from a higher-level dialect into LLVM IR, while all Julia code is lowered from a higher-level IR which is _not_ a MLIR dialect into LLVM IR.

This should offer some insight into why just making Julia use MLIR instead of LLVM IR directly wouldn’t change much. Does that mean there’s no benefit to using MLIR? No. You could imagine how a library like Coil.jl could benefit if Julia IR was a MLIR dialect. Other non-LLVM MLIR dialects help Mojo achieve functionality like auto-vectorization at the language level, while the Julia ecosystem has to deal with issues like [Why is LoopVectorization deprecated?](https://discourse.julialang.org/t/why-is-loopvectorization-deprecated/109547) because trying to integrate with the compiler is far more fragile.

Lastly, I should point out that neither Mojo nor the Julia ecosystem support TPUs right now. There have been [attempts](https://github.com/JuliaGPU/XLA.jl) to get Julia code running on TPUs, but see above about fragile compiler integration. Additionally, TPUs speak a very limited set of high-level array operations and _nothing else_. Given most Julia and Mojo code is being written at a significantly lower level and using constructs (e.g. complex loops, lazy conditionals with side effects) that are not supported in the XLA IR TPUs use, it’s unlikely either will get great language-level support any time soon. The best path is likely via some high-level DSL, which is basically what JAX is for Python.

---

_[View the full topic](https://discourse.julialang.org/t/should-julia-use-mlir-in-the-future/110459)._
