A developer has introduced llm.mojo — a port of Andrej Karpathy's llm.c project to the Mojo language. By utilizing handwritten CUDA and Metal kernels, the solution demonstrates significant superiority over standard frameworks on Apple Silicon and comparable speeds to the original C code on NVIDIA architecture.

image
image
image

What Happened

The llm.mojo project implements GPT-2 training using optimized GPU kernels. On Apple Silicon (M4 Max), the solution runs 1.71x faster than PyTorch MPS in bf16 mode. On the NVIDIA GB10 architecture, it achieves parity with the original llm.c (CUDA) in bf16 mode and a 7% superiority in fp32 (TF32) mode.

Context

The project is based on llm.c — Andrej Karpathy's minimalistic implementation of language model training in C. Porting to Mojo allows for combining low-level GPU control with the capabilities of a new high-performance language, minimizing the overhead characteristic of interpreted languages.

Why It Matters for the Industry

This implementation confirms Mojo's potential as a serious competitor to C++ and the Python/PyTorch combination in deep learning tasks. It paves the way for a new generation of high-performance kernel libraries and a paradigm shift in AI infrastructure development, where Mojo could become the standard for writing efficient kernels.

Why It Matters for Users

For individual developers and small teams, this means the ability to perform efficient model training and fine-tuning on powerful laptops and personal workstations with performance close to specialized server solutions. This significantly accelerates the prototyping cycle on local hardware.

Sources

Author

Look at AI, Editorial Staff