modular/mojo-gpu-puzzles

Learn GPU Programming in Mojo🔥 by Solving Puzzles

Mojo 🔥 GPU Puzzles – What It Is

Mojo GPU Puzzles is an open‑source, interactive learning kit that teaches you how to write GPU code in Mojo, Modular’s systems‑level language that blends Python‑like syntax with the performance of compiled code. The repository contains a series of self‑contained puzzles (problem files) and their solutions, plus tooling to build, run, and test the code on a real GPU.


Why It Matters

  • Mojo is positioned as a next‑generation language for AI‑hardware programming – it offers zero‑cost abstractions, a strong static type system, and built‑in tensor primitives while still feeling like Python.
  • Learning to program GPUs directly is a core skill for high‑performance AI workloads (model training, inference, custom kernels). These puzzles give hands‑on experience without the overhead of a textbook.
  • The project ships with a CI pipeline, sanitizers, and a pixi‑based development environment, making it a realistic, runnable codebase rather than a static tutorial.

How to Get Started

  1. Prerequisite – a CUDA‑capable NVIDIA GPU (driver ≥ 580 / CUDA 13.0).
  2. Clone the stable branch (matches the live web version) or main if you plan to contribute.
    git clone --branch stable https://github.com/modular/mojo-gpu-puzzles
    cd mojo-gpu-puzzles
    
  3. Install the recommended package manager pixi (handles Modular’s MAX/Mojo packages and GPU dependencies).
    curl -fsSL https://pixi.sh/install.sh | sh
    
  4. Build and view the puzzle book locally:
    pixi run book   # launches an mdBook server at http://localhost:3000
    
  5. Solve a puzzle by editing the corresponding file under problems/pXX/. The skeleton contains # FILL ME IN placeholders; you only add code.
  6. Test your solution on the GPU:
    pixi run tests p05   # runs the GPU‑accelerated test for puzzle 5
    
    Optional sanitizers (memcheck, racecheck, etc.) are provided for debugging kernel errors.

Development & Contribution

  • The repo uses pixi for all development commands (building the book, formatting, running tests, and invoking NVIDIA’s compute‑sanitizer).
  • CI checks ensure that problem skeletons stay in sync with solutions and that every unfilled puzzle still compiles.
  • Contributions are welcomed: improve explanations, fix bugs, or add new puzzles. Follow the usual fork‑branch‑PR workflow and see the issue templates for bug reports and feature requests.

Community & Support

  • Discord: discord.gg/modular – real‑time chat with other learners and the Modular team.
  • Modular Forum: discussion threads for deeper questions.
  • Newsletter: subscribe via the links in the README to receive updates when new puzzle editions are released.

License

The code is released under the LLVM License, a permissive open‑source license.


Bottom line: Mojo GPU Puzzles is a concrete, runnable educational project that lets developers get practical GPU‑programming experience in Mojo, a language that is increasingly relevant for AI and high‑performance computing.

Related

  • Dispatch
  • Dispatch
  • Dispatch
  • Dispatch
  • Project