Live data from Hacker News

Running a 28.9M parameter LLM on an $8 microcontroller

github.com

11–20 of 79 posts

Re: Running a 28.9M parameter LLM on an $8 microcontroller

#11

Why can't this scale to run much larger models on CPU backed by flash with good access patterns?

Someone did this exact thing recently, but running GLM-5.2 with something like 16GB of DRAM, a standard desktop CPU and nVME SSD.

I think they got something like 10 _seconds per token_ (not tokens per second).

EDIT: it was 25GB of ram and up to 20 seconds per token! https://github.com/JustVugg/colibri

Re: Running a 28.9M parameter LLM on an $8 microcontroller

#12

>esp32-s3 This microcontroller is a beast, currently using it to do dev work on a pi4. Having two usb ports with one otg lets you do some neat things that would cost $100+ otherwise

If you want to do this at the $1 price point, you can on RP2350, albeit with some limitations. In particular, it maxes out at full speed (12Mbps). The trick is to use the on-chip USB peripheral for one, and connect the other to GPIO pins backed by PIO.

This works today with tinyusb and pico-pio-usb, but I'm also playing with a Rust port which I'm hoping will have higher performance.

Re: Running a 28.9M parameter LLM on an $8 microcontroller

#13

Why can't this scale to run much larger models on CPU backed by flash with good access patterns?

My guess is because the ESP32's flash is only ~1/4 the bandwidth of the internal SRAM. If you do this on a more powerful system not only is the gap much wider but you also have much more compute you need to keep fed with bandwidth to be efficient.

Re: Running a 28.9M parameter LLM on an $8 microcontroller

#14
post #10

It's crazy what $5 can buy you in a microcontroller these days. Have a look at these Milk-V boards: https://milkv.io The duo has up to 256MB of memory, and a 1TOPS@INT8 TPU. They run Linux and are $5. I bought 5!

You can buy sub-$0.50 microcontrollers. But even at $5, I don't know why you'd want to run models on them, it's an environment constrained to the point of being useless for this task.

And I hope it stays that way, I don't want MCU shortages...

Re: Running a 28.9M parameter LLM on an $8 microcontroller

#15

>esp32-s3 This microcontroller is a beast, currently using it to do dev work on a pi4. Having two usb ports with one otg lets you do some neat things that would cost $100+ otherwise

If you want to do this at the $1 price point, you can on RP2350, albeit with some limitations. In particular, it maxes out at full speed (12Mbps). The trick is to use the on-chip USB peripheral for one, and connect the other to GPIO pins backed by PIO. This works today with tinyusb and pico-pio-usb, but I'm also playing with a Rust port which I'm hoping will have higher performance.

$8 ish gets you an ESP32-S3 board with PSRAM, flash, and two USB-C ports. The PSRAM and flash are specifically used for this LLM project. I can't find anything like that with the RP2350 for $1.

Re: Running a 28.9M parameter LLM on an $8 microcontroller

#16
post #10

It's crazy what $5 can buy you in a microcontroller these days. Have a look at these Milk-V boards: https://milkv.io The duo has up to 256MB of memory, and a 1TOPS@INT8 TPU. They run Linux and are $5. I bought 5!

You can buy sub-$0.50 microcontrollers. But even at $5, I don't know why you'd want to run models on them, it's an environment constrained to the point of being useless for this task. And I hope it stays that way, I don't want MCU shortages...

I want to run music models on the Milk-V and have them jam in realtime with me.

Re: Running a 28.9M parameter LLM on an $8 microcontroller

#17

Why can't this scale to run much larger models on CPU backed by flash with good access patterns?

Someone did this exact thing recently, but running GLM-5.2 with something like 16GB of DRAM, a standard desktop CPU and nVME SSD. I think they got something like 10 _seconds per token_ (not tokens per second). EDIT: it was 25GB of ram and up to 20 seconds per token! https://github.com/JustVugg/colibri

That's incredible. Sure, not practical for most applications, but if you really want a local top tier model, you can run it on anything as long as you are patient.

As someone with a healthy amount of RAM, but just a 16GB GPU, I am wondering what kind of work I could queue up for overnight runs. I thought the best models were fully out of reach, but the 128GB CPU only test had a 1.8 tokens/second. While not speedy, you could probably do something with that given extensive coffee breaks. This speed simulator[0] demos what it looks like.

[0] https://shir-man.com/tokens-per-second/?speed=1.8

Re: Running a 28.9M parameter LLM on an $8 microcontroller

#18
post #10

It's crazy what $5 can buy you in a microcontroller these days. Have a look at these Milk-V boards: https://milkv.io The duo has up to 256MB of memory, and a 1TOPS@INT8 TPU. They run Linux and are $5. I bought 5!

Don't forget the 128 bit vector ISA with 32 registers, supporting up to 64 bit int and FP, and with LMUL=8 you can process 1024 bits with a single instruction (at 3 cycles per 128 bits for most operations). Fully supported by GCC and CLANG (xTHeadVector) and compatible with RVV 1.0 with just a command line switch if you use the C intrinsic functions. (a lot of code working on 8 bit elements is binary compatible with RVV 1.0 too e.g. typical memcpy(), memset(), memcmp(), strlen(), strcpy(), strcmp())

When I bought my 64 MB Duo they were $3!

Then for a long time they were $5 for the 64 MB, $7 for the 256 MB, and $10 for the 512 MB.

Sadly, like everything else, they've gone up considerably this year.

https://arace.tech/products/milk-v-duo

https://arace.tech/products/milkv-duo-s

Re: Running a 28.9M parameter LLM on an $8 microcontroller

#19
post #10

It's crazy what $5 can buy you in a microcontroller these days. Have a look at these Milk-V boards: https://milkv.io The duo has up to 256MB of memory, and a 1TOPS@INT8 TPU. They run Linux and are $5. I bought 5!

You can buy sub-$0.50 microcontrollers. But even at $5, I don't know why you'd want to run models on them, it's an environment constrained to the point of being useless for this task. And I hope it stays that way, I don't want MCU shortages...

isn't floor price 0.10$ for last couple years?

Re: Running a 28.9M parameter LLM on an $8 microcontroller

#20
post #8
post #5

This is a really neat use of the per-layer embedding trick. It's also worth noting that there viable TTS models that are ~20-30M param, so it might mean you can have a ESP32 with no network access read stuff out to you in near real time!

One of the things I have been wanting to try for a while now is something like this with a layer per MCU. I have some crazy ideas with RP2350's talking to each other with dedicated lines fed by PIO going through a combination of interpolators and dual multiply instructions. PSRAM, Flash, and even SD cards may not have the best bandwidth individually, but they can reach quite impressive rates when you have a shitton o…

Run the numbers before you waste time here. I doubt this will work.
Post reply on HN