April 18, 2026
Training an LLM in Swift, Part 1: Taking matrix multiplication from Gflop/s to Tflop/s
10 implementations of handwritten matrix multiplication: from plain C and Swift through to Metal
In this article, I try to get my own handwritten matrix multiplication code running as fast as possible for training a Large Language Model (LLM) in Swift. The aim is to give some insight into the key steps for optimizing mathematics code in Swift. I also hope that these examples will offer a sense of scale about the capabilities of the different units on …