Skip to main content
Back

Tiny Corp Moves AMD LLM Kernels Into Dedicated slopkernels Module

Tinygrad spins out a dedicated kernel library written in Python that emits UIR, its minimalist shape-aware IR, targeting AMD MI300X and beyond.

Repo, Full Access
  • Tinygrad added a slopkernels directory, fast AMD LLM kernels written in Python emitting UIR.
  • UIR is tinygrad's shape-aware IR, simpler than PTX, LLVM IR, HIP, or CUDA.
  • Kernels moved out of core behind a versioned API for easier contributions.
  • A follow-up PR added AddrSpace.TEMPLATE and pregenerated templated UIR kernels.
  • Team plans to grind MI300X kernels once more machines land in CI.
  • Hotz compares UIR to LEAN for kernels, a machine-checkable spec for search.

Tiny Corp has moved its hand-tuned AMD LLM kernels into a dedicated slopkernels directory in tinygrad. Python generators in the module emit UIR, tinygrad’s low-level intermediate representation, which existing backends lower for the target device. The new boundary lets contributors tune kernels and automate performance searches without changing the compiler core.

Kernels move out of the compiler core

  1. Extract and version. The extraction PR moved the LLM kernels out of tinygrad’s core and placed them behind a versioned UIR API.
  2. Reintegrate at the top level. The merge PR returned them to the main repository as a sibling module with its own CI workflow and GPU benchmark gates.

The resulting tree removes the old tinygrad/llm/kernels path. Projects that import that internal directory must migrate to the versioned interface. Other users can adopt slopkernels selectively because the optimized kernels remain optional.

George Hotz has described slopkernels as a more accessible contribution target than the tightly constrained tinygrad core, which enforces strict line-count limits. Planned MI300X capacity in CI would let maintainers test more kernel variants on the hardware they intend to optimize.

UIR narrows the search space

UIR occupies the layer between a Python kernel generator and a target-specific backend. It is comparable in purpose to NVIDIA’s PTX, LLVM IR, and Mesa’s NIR, which encode programs in forms that compilers can analyze and lower. Tinygrad’s design keeps the instruction surface small and makes tensor shapes explicit.

Shape awareness records dimensions, tiling, and data movement directly in the representation. Search tools therefore operate on concrete kernel properties and produce output that can be checked against a constrained specification. Hotz has compared this validation model to Lean, the theorem prover, because both systems restrict generated output to machine-checkable forms.

A follow-up change added AddrSpace.TEMPLATE, allowing Python definitions to produce reusable, parameterized LLM kernels. Generated .uir files remain outside Git and are materialized on demand, keeping derived artifacts out of source control.

Python writes the low-level program

Python keeps kernel generation, templating, and autotuning in ordinary functions, and tinygrad handles target-specific lowering. A typical kernel follows four stages:

  1. Parameterize. A Python function receives the tensor shape and tuning parameters.
  2. Emit. The function constructs UIR nodes for computation, tiling, and data movement.
  3. Lower. A tinygrad backend translates the UIR program for a supported CPU, GPU, or DSP target.
  4. Measure. Hardware benchmarks feed latency or throughput results back into manual tuning or automated search. Trusted contributors can use gated GPU CI, while the mock AMD backend supports offline UIR generation without physical hardware.

Portable UIR still requires architecture-specific tuning. Wave size, memory hierarchy, instruction support, and cache behavior determine the fastest schedule on each device, even when the same generator can feed several backends.

The AMD targets: Strix Halo and MI300X

Tinygrad’s initial LLM target is the Qwen3.8 family on AMD Strix Halo under Linux, followed by the MI300X. Strix Halo covers high-end client and workstation systems, while the MI300X targets data-center workloads, giving the project two distinct AMD architectures for testing its approach.

AMD’s practical constraint is often kernel coverage across model operators, tensor shapes, and device generations. slopkernels gives those schedules a dedicated, versioned home. Automated search can vary tile sizes, workgroup layouts, and memory-access patterns, then retain candidates that pass UIR checks and hardware benchmarks.

AMDKernelVault approaches the same optimization problem by training models on roughly 40,000 HIP and Triton kernel examples. Tinygrad is testing whether a smaller, shape-aware representation can constrain the search enough to reduce the bootstrap data and validation work.

Where developers plug in

The repository changes establish the infrastructure for optimization. Actual gains remain specific to the model, tensor shape, driver, and device, and the PR sequence provides no universal performance figure. Teams evaluating the kernels need end-to-end latency and throughput measurements on their own workloads.

Audience Practical consequence
AMD inference teams Test the optional kernel pack against production model shapes and measure latency, throughput, and memory use.
Projects using the old path Replace integrations based on tinygrad/llm/kernels with the versioned UIR interface.
Kernel contributors Add or tune Python generators in slopkernels, run offline checks through the mock AMD backend, and use gated GPU benchmarks when eligible.
Compiler researchers Study UIR and its template system as a concrete design for shape-aware kernel synthesis and machine-checked search.