https://www.modular.com/mojo Engine Overview PERFORMANCE DASH dOCS Mojo Overview Docs Hardware Blog Careers Company About Vision Team Newsletter Culture contact Sign inGet Started Menu Mojo -- a new programming language for all AI developers. Mojo combines the usability of Python with the performance of C, unlocking unparalleled programmability of AI hardware and extensibility of AI models. Get started with MojoRead the docs SOFTMAX.PY Mojo python def softmax(lst): norm = np.exp(lst - np.max(lst)) return norm / norm.sum() def softmax(lst): norm = np.exp(lst - np.max(lst)) return norm / norm.sum() struct NDArray: def max(self) -> NDArray: return self.pmap(SIMD.max) struct SIMD[type: DType, width: Int]: def max(self, rhs: Self) -> Self: return (self >= rhs).select(self, rhs) 01 Usability & Programmability Write everything in one language Write Python or scale all the way down to the metal. Program the multitude of low-level AI hardware. No C++ or CUDA required. Take a tour of Mojo FILE_NAME. def sort(v: ArraySlice[Int]): for i in range(len(v)): for j in range(len(v) - i - 1): if v[j] > v[j + 1]: swap(v[j], v[j + 1]) FILE_NAME. struct MyPair: var first: Int var second: F32 def __init__(self, first: Int, second: F32): self.first = first self.second = second FILE_NAME. def reorder_and_process(owned x: HugeArray): sort(x) # Update in place give_away(x^) # Transfer ownership print(x[0]) # Error: 'x' moved away! FILE_NAME. def exp[dt: DType, elts: Int] (x: SIMD[dt, elts]) -> SIMD[dt, elts]: x = clamp(x, -88.3762626647, 88.37626266) k = floor(x * INV_LN2 + 0.5) r = k * NEG_LN2 + x return ldexp(_exp_taylor(r), k) FILE_NAME. def exp_buffer[dt: DType](data: ArraySlice[dt]): # Search for the best vector length alias vector_len = autotune(1, 4, 8, 16, 32) # Use it as the vectorization length vectorize[exp[dt, vector_len]](data) Features include: Progressive Types Leverage types for better performance and error checking. Zero Cost Abstractions Take control of storage by inline-allocating values into structures. Ownership + borrow checker Take advantage of memory safety without the rough edges. Portable parametric algorithms Leverage compile-time meta-programming to write hardware-agnostic algorithms and reduce boilerplate. LANGUAGE INTEGRATED Auto-tuning Automatically find the best values for your parameters to take advantage of target hardware. As well as: The full power of MLIR Parallel heterogenous runtime Fast compile times FILE_NAME. def sort(v: ArraySlice[Int]): for i in range(len(v)): for j in range(len(v) - i - 1): if v[j] > v[j + 1]: swap(v[j], v[j + 1]) Features include: Progressive Types Leverage types for better performance and error checking. FILE_NAME. struct MyPair: var first: Int var second: F32 def __init__(self, first: Int, second: F32): self.first = first self.second = second Features include: Zero Cost Abstractions Take control of storage by inline-allocating values into structures. FILE_NAME. def reorder_and_process(owned x: HugeArray): sort(x) # Update in place give_away(x^) # Transfer ownership print(x[0]) # Error: 'x' moved away! Features include: Ownership + borrow checker Take advantage of memory safety without the rough edges. FILE_NAME. def exp[dt: DType, elts: Int] (x: SIMD[dt, elts]) -> SIMD[dt, elts]: x = clamp(x, -88.3762626647, 88.37626266) k = floor(x * INV_LN2 + 0.5) r = k * NEG_LN2 + x return ldexp(_exp_taylor(r), k) Features include: Portable parametric algorithms Leverage compile-time meta-programming to write hardware-agnostic algorithms and reduce boilerplate. FILE_NAME. def exp_buffer[dt: DType](data: ArraySlice[dt]): # Search for the best vector length alias vector_len = autotune(1, 4, 8, 16, 32) # Use it as the vectorization length vectorize[exp[dt, vector_len]](data) Features include: LANGUAGE INTEGRATED Auto-tuning Automatically find the best values for your parameters to take advantage of target hardware. 02 Performance Unlock Python performance Utilize the full power of the hardware, including multiple cores, vector units, and exotic accelerator units, with the world's most advanced compiler and heterogenous runtime. Achieve performance on par with C++ and CUDA without the complexity. Play with Mojo Parallelization Mojo leverages MLIR, which enables Mojo developers to take advantage of vectors, threads, and AI hardware units. PYTHON Single-threaded execution Mojo Parallel processing across multiple cores Languages Time (S) * Speedup vs Python Python 3.10.9 1027 s 1x Pypy 46.1 s 22x Scalar C++ 0.20 s 5000x Mojo 0.03 s 35000x * Algorithm Mandelbrot Instance AWS r7iz.metal-16xl Intel Xeon 03 Interoperability Access the entire Python ecosystem Experience true interoperability with the Python ecosystem. Seamlessly intermix arbitrary libraries like Numpy and Matplotlib and your custom code with Mojo. Read the programming manual MAKE_PLOT. def make_plot(m: Matrix): plt = Python.import_module("matplotlib.pyplot") fig = plt.figure(1, [10, 10 * yn // xn], 64) ax = fig.add_axes([0.0, 0.0, 1.0, 1.0], False, 1) plt.imshow(image) plt.show() make_plot(compute_mandelbrot()) [644ee27fc5] Mojo 04 Extensibility Upgrade your models and the Modular stack Easily extend your models with pre and post-processing operations, or replace operations with custom ones. Take advantage of kernel fusion, graph rewrites, shape functions, and more. Model extensibility Mojo can upgrade the existing operations in your model. Input layer Hidden layers Output layer 05 GET STARTED NOW Try Mojo out right now in our Playground Mojo is still a work in progress, but it's available to try today in our JupyterHub-based Playground. Run through tutorials and write your own Mojo code. Sign up for access [644c56ba42] Mojo 01. EASY TO GET STARTED We have plenty of easy-to-use Jupyter notebooks to help you get started learning Mojo . 02. Unleash your mojo Our docs will help you quickly discover why Mojo is such a powerful extension to Python, and the future of AI programming. 03. JOIN the mojo COMMUNITY Come and chat with us on our Discord, and help shape the future of the language as we continue to develop it. Ready to play with Mojo? Reach out to gain access to the Mojo Playground. Request access API Reference, Tutorials, & More Read the Mojo docs Engine Mojo Hardware Performance Get Started Blog Careers Copyright (c) 2023, Modular Inc Terms , Privacy & Acceptable Use *