Mojo🔥
- 35,000 times faster than Pyton.
- 3 times faster than TensorFlow.
- 2 times faster than Pytorch.
- Faster than c/c++.
Fastest AI engine by Modular. The primary goal is to create the fastest, most secure, and simple programming code for AI/ML.
Yes, Mojo is a new programming language by Modular.
🔴Best thing is syntax is precisely the same as Python. But the underline engine is entirely different
A Mojo code compared to Python code
- 2 times faster on an Intel processor.
- 3 times faster on an AMD processor.
- 4 times faster on a Graviton processor.
How Mojo is so fast?
Mojo is built from scratch.
Compute fragmentation / Floating point precision.
- CPU going to ram and taking data is called memory wall/memory latency.
- This is a bottleneck and we have to solve memory latency.
- Floating point precision: Let's say we are storing 60000000, 700, and 1000 on top of RAM so we convert them into 60 * 10⁶, 70*10¹, and 10*10², now we store these on RAM this is called floating point precision.
- Python uses 64bit floating point precision and c/c++ uses 32bit floating point precision.
- Data from memory gets stored on the local registry of CPU, more data in the local registry faster CPU processing, and the smaller the floating point precision size more data gets stored on the local registry of the CPU.
- Yes, Mojo supports 16-bit floating point precision size.
- The best way to measure CPU speed is FLOPS-floating point operations per second.
Data type.
- We don't define data type in Python and Python uses its intelligence to find data type which is time-consuming. So we can define data type in Mojo.
- We cant make variables immutable in python but in python, we can.
LLVM (Low Level Virtual Machine)
- LLVM is a collection of modular and reusable compiler and toolchain technologies.
- Compiler converts every programming code into LLVM code before then CPU executes it.
- Compiler takes time in this process.
- To solve this Mojo is built in such a way there is no time wasted in compiling to LLVM, Mojo engine directly works on LLVM i.e., Mojo engine converts code directly into LLVM code.
Matrix Multiplication.
- 50–60% of the time in a Neural Network program is taken for Matrix Multiplication.
- Time complexity is O(n³).
- Mojo solved this by SIMD(Single instruction multiple data) and its possible because 16-bit floating point.
- Concurrency and parallelism are supported by Mojo which is a must for matrix multiplication.
Class is not present in Mojo because it works on runtime polymorphism /dynamic dispatch which is time consuming , we have struct to perform OOPS concept in Mojo which is exactly same as class .
Get Prithvi A Parit’s stories in your inbox
Join Medium for free to get updates from this writer.
fn can be used as same as def to increase speed.
All these together make Mojo Super Fast.
Mojo is still in the development phase so it's not publicly released to Download.
We can use Mojo Playground at https://www.modular.com/ we get console and Jupyter Notebook.
var x: F16 = 18.
This is the syntax to define floating data type and 16bit Floating point.
Try watching at least the first 8 minutes of this video.
Chris Lattner creator of Swift, LLVM, PyTorch, TensorFlow is the man behind Mojo.
Big hats off to Chris Lattner👏.
Tried explaining as much as possible.
Thank you.









