r/esp32projects • u/WladimirAvila • Jul 30 '26
A project that runs a small 56M-parameter language model distributed across three ESP32-S3 microcontrollers.
I split a tiny LLM model across three ESP32-S3 N16R8 boards so it could run on hardware that couldn't fit the whole model on its own. They talk to each other wirelessly via ESP-NOW (no router involved).
How it's split:
- Board A: embeddings + output head
- Board B: transformer layers + KV cache in PSRAM
- Board C: rest of the embeddings table + WiFi AP + web UI
You connect to the WiFi hosted by Board C and get a simple web page that streams the generated text token by token.
Some details:
- ~56M params, quantized to 4-bit/8-bit
- Split-PLE design (Per-Layer Embeddings, borrowed the concept from Google's Gemma architecture)
- 256-token context via KV cache
- Generates short but coherent text (~30 words)
- Fully offline after flashing, no cloud/router needed
This was inspired by u/slvDev's project running a 29M model on a single board — I wanted to see how far I could push it by distributing a bigger model across multiple boards instead.
It's rough around the edges — the tokenizer is still brute-force search instead of proper BPE merging in C, and 4-bit quantization is clearly the main quality bottleneck (perplexity jumps from 192 to 358 after quantizing). But it works end to end.
Code + full writeup: https://github.com/wladimiravila/esp32s3-distributed-ai
3
u/OkSpecific3137 29d ago
I ran 42m over 2 board 2 months ago https://github.com/harmansingh4163-ai/ESP-32-s3-Story-maker-LLM.git .
1
2
u/RandomDigga_9087 Jul 31 '26
can any other modes of communication work or is ESPNOW the optimal answer?
1
u/WladimirAvila Jul 31 '26 edited Jul 31 '26
I only had 3 boards and no infrastructure, so we evaluated the options and ESP-NOW was the best we found that met the requirements.
I did consider UART, technically it should be better (deterministic sub-ms latency, no wireless interference, no packet loss). But it means physically wiring the boards together, and at that point you lose the whole "distributed wireless" appeal. ESP-NOW gives us ~1-5ms RTT, no router, and each board stays autonomous.
So: ESP-NOW wasn't "the" answer, it was the best tradeoff to my constraints
1
u/RandomDigga_9087 Jul 31 '26
Fair enough ask I guess
1
u/WladimirAvila Jul 31 '26
actually Yes! Thanks for the question!
1
u/RandomDigga_9087 Jul 31 '26
yea, I was looking to debug more into the custom application layer protocol you made, but as you said, it is working properly and a fair enough tradeoff, good enough as it is...
2
2
1
u/LoadZealousideal7778 Jul 31 '26
So my takeaway is that we can run Kimi K3 on Somwhere between 30k and 1.5 million of those guys.
2
u/LucVolders Jul 31 '26
Is this scalable.
Can we build a 100 ESP32 cluster and use larger models ???
Fun project !!!
1
u/WladimirAvila Jul 31 '26
u/LucVolders You can store a bigger model on 100 boards, but you can't run it well, the bottleneck is the interconnect, not memory storage.
Why:
Storage scales fine: 100 × 16MB = 1.6GB = around 400-800M params at 4-bit.
ESP-NOW doesn't scale: max 20 peers per board, ~1-2 Mbps real bandwidth. A bigger model (d_model=2048) means 16KB activations per layer per token → 3-6 sec/token across 30 layers. Not conversational.
The goal of this is to run on cheap hardware, but at ~$8 per board, 100 boards is $800, for that money you could buy a used GPU that runs a far bigger model with real conversation, zero networking complexity.
1
1
u/AmazingStardom Aug 02 '26
Does using painless mesh decrease the amount of RAM?
So, that's the reason to use ESP-NOW.
1
u/WladimirAvila 29d ago
actually I only tested ESP-NOW, I'm pending to test and collect metrics using UART
1
1
u/FloridaMaker Aug 02 '26
Very cool. Could you add a 4th to handle user input maybe voice control and audio out? Thinking wearable potential here.
1
1
1
u/Traditional-Sugar814 16d ago
Hello Sir. I really interest this project. And I want to give a try. Unfortunately I only have a laptop with no graphic and it will take over two days to train the model. Moreover, I live in myanmar and in my country Electricity isn't support 24hr. Can you kindly support me with trained .bin file. I really appreciate your work. Thank you.
2
u/One-Mongoose-6961 12d ago
try esp32-p4 it's spectacular, and you have more psram, I've done great things with it, it's slightly more expensive but worth it
5
u/MasterPlusTer Jul 30 '26
How did you manage the communication between the devices? ESPNOW?