DEV Community

I Ran a 500M-Parameter LLM on an ESP32-C3 Microcontroller

Borjan Ladinski on November 27, 2026

I wanted to see how far I could push a tiny microcontroller. My ESP32-C3 has a 160 MHz processor, around 400 KB of SRAM, and 4 MB of flash storage...
Collapse
 
iictp profile image
IICTP •

The INT8 result is the part that surprised me most — 273,440 µs beating both INT4 and INT2 is a good reminder that lower bit widths save storage without automatically speeding up computation. I also appreciated the honesty about what the milestone actually is: verified transformer computation and next-token selection on the chip, not a standalone chatbot. The 167s → 19s partial-benchmark improvement makes me curious how much of that overhead was weight streaming versus the compute itself — did one dominate?

Collapse
 
borjanladinski profile image
Borjan Ladinski •

Thanks! I didn't measure weight streaming and computation separately in that benchmark, so I can't give an exact breakdown. The 167s → 19s improvement was for a partial benchmark, not full inference. Weight streaming is a major bottleneck in the full model since the ESP32 has to receive the weights while doing all the computation locally. Separating the two timings is something I'd like to benchmark next.

Collapse
 
iictp profile image
IICTP •

Thanks for being precise about what was and wasn't measured — knowing the 167s-to-19s improvement was a partial benchmark on a single fixed input keeps the result honest, and it's genuinely useful that you didn't guess at the split. I don't have a method for separating weight streaming from computation on the ESP32 myself, but the question is a good one — has anyone in the thread suggested a way to time the two phases apart, or is that still an open experiment?

Collapse
 
analista_83 profile image
Sammi De Blas •

Separating weights from compute is the only way 400 KB of SRAM can touch a 500M parameter model. What matters here is the per-layer latency on a 160 MHz core and where the attention cache spills. How many tokens per second did the ESP32 actually produce, and did quantisation change the output on the same prompt?

Collapse
 
borjanladinski profile image
Borjan Ladinski •

The full run took 4,164 seconds to process 4 input tokens and generate 1 output token. That's roughly 0.00024 tokens/sec end to end, not a steady-state generation benchmark.

The KV cache stayed entirely on the ESP32, so there was no cache spilling to the PC. Only model weights and embeddings were streamed.

For quantization, INT8 produced the same next token (" Paris") as the original floating point model on the tested prompt. I haven't verified whether this holds across other prompts.

Collapse
 
analista_83 profile image
Sammi De Blas •

Calling it a latency figure instead of a throughput number keeps the comparison honest for tiny boards.

Collapse
 
gautamtalksdev profile image
Gautam K •

Doing the actual transformer math on the chip instead of offloading is the fun constraint. With about 400 KB of SRAM the weights have to stream in piece by piece. What did a token cost in the end, and was flash read speed or compute the bottleneck?

Collapse
 
borjanladinski profile image
Borjan Ladinski •

The final verified run took about 69 minutes to process a 4-token prompt and generate one token using all 24 transformer layers. The ESP32 generated “Paris” from “Capital of France:”.

The weights were streamed over USB from the PC, not read from flash. I haven't measured streaming and compute time separately, so I can't say which dominated. That's something I'd like to benchmark next.

Collapse
 
gautamtalksdev profile image
Gautam K •

69 minutes for one token, and it said Paris. That's a great result for a proof. Splitting USB streaming time from compute time would be a fun next benchmark; I'd guess the streaming dominates, but the measurement will tell.

Collapse
 
userxnom profile image
Abdullah Naseer •

The honesty here is what makes it land — you don't claim a standalone chatbot, you claim a verified next-token ID from real transformer computation on a 160 MHz chip with 400 KB of SRAM, with the PC only streaming weights. The INT8 result surprised me too: 273,440 µs versus 530,232 for INT4 and 546,245 for INT2 — lower bits shrink storage but don't automatically speed up the math, and your microbenchmark says that plainly. And the 167s to 19s speedup is a good reminder that the bottleneck was streaming and pipeline overhead, not the transformer itself. What would it take to get from one verified token to a slow but real multi-token reply — is the next wall streaming, memory, or just patience?

Collapse
 
borjanladinski profile image
Borjan Ladinski •

The next step is to loop the inference process: take the selected token, feed it back into the model, update the KV cache on the ESP32, and repeat.

I think streaming will remain the biggest bottleneck, since the model weights still need to pass through the device for each generated token. Memory is also tight, especially as the KV cache grows.

So multi-token generation is the next milestone. Speed is a separate problem, and even a few generated tokens would be a useful proof of concept.

Collapse
 
timmyzinin profile image
Tim Zinin •

Saying plainly that the verified result is a next token, with the weights streamed from the PC, makes the experiment much easier to trust. Once you loop it for several tokens, how will you check that the output on the chip still matches the reference implementation?

Collapse
 
alexshev profile image
Alex Shev •

The milestone is convincing precisely because the PC supplies bytes while the ESP32 performs the transformer steps and token choice. For the multi-token version, a compact per-step verification trace would be valuable: prompt position, streamed-weight bytes, selected token ID, and a digest or tolerance check against the reference logits. That would show where a divergence starts without implying that one matching next token proves the whole generation path.

Collapse
 
syedfahads profile image
Syed Fahad •

at about 69 minutes a token, a short haiku is a full day on that board lol. please post when it finishes its first full sentence