Microgpt in pure C hits 10M tps on Apple m5

(github.com)

49 points | by dhorthy 1 day ago

5 comments

  • Retr0id 9 minutes ago
    > The most atomic way to train and inference a GPT in pure, dependency-free C.

    What sense of the word "atomic" is meant here?

    • elromulous 8 minutes ago
      No dependencies, self-contained
  • ilaksh 1 hour ago
    This is not an LLM obviously , it's just for generating random names. But interesting to think of the possibilities of truly tiny language models if there were connected together.
    • alightsoul 10 minutes ago
      It's an slm (small language model) due to number of parameters and it uses the same architecture as an llm, but llms have billions of parameters
    • dcow 56 minutes ago
      Is token rate a function of parameter size?
      • rbanffy 19 minutes ago
        Not quite linear, but yes.
    • api 32 minutes ago
      Isn't a MoE model basically a cascading tree of smaller models or some variation of that?
  • pkilgore 12 minutes ago
    Honestly not sure this is impressive. I ported microgpt to zig as a learning exercise, then moved scalar engines to NEON/metal just to see what happened. Besides metal being slower (I probably did something wrong, but it could be due to the fixed costs of memory transfer into the GPU not being worth it due to the small model).

    Anyways, it was also stupid fast, particularly compared to the python version. But I was pretty sure that's irrelevant to real production architectures!

  • throwa356262 1 hour ago
    And the 5 years old AMD Ryzen 5 5600H is doing 7M?

    Am I reading this right? Then I need to try this on Strix Halo

    • rbanffy 14 minutes ago
      And it's only using AVX-2 and not AVX-512, AMX or ACE. Or built-in GPUs and NPUs (the M series doesn't emphasize matrix multiplication on the CPU side because it already has matrix multiplication units on the GPU, which is always attached).
      • bigyabai 4 minutes ago
        Before the M5, there was no dedicated matrix multiplication hardware on the Apple Silicon GPU. Their solution was generally using the NPU and AMX coprocessors for tensor and matrix workloads.
  • fwip 1 hour ago
    Model is 4K parameters - I don't know enough about that size of model to know if this impressive or not.
    • altcognito 52 minutes ago
      It's a trivial example. This won't be useful outside of a VERY specific domain without more parameters. Many people need to know about the bitter lesson.

      https://en.wikipedia.org/wiki/Bitter_lesson

      Over time, I'm sure we'll be able to filter information better and get parameter counts down, but I wouldn't count on that within the next 6 months.

      • odo1242 21 minutes ago
        The point here is that the library's overhead cost is very low. The fact that a tiny model can reach 10M tokens per second means that the overhead of token decode, memory allocation, calling the model, etc. is very low. The model doesn't actually need to be useful to prove that point.
        • voakbasda 14 minutes ago
          It’s interesting and worthy of genuine applaud for being a good starting point for further work.

          That said, I am more interested in what size model this could manage while producing “just enough” tokens per second to work at a conversational rate. What are models in that class capable of doing for me?