Running LLM Inside ESP32 RAM: Evolution of the WiTiAI INT8 96K for a Standalone IoT Ecosystem

Running LLM Inside ESP32 RAM: Evolution of the WiTiAI INT8 96K for a Standalone IoT Ecosystem

AdminPokdartik · 18 Nov 2026 · 255 times

Running generative artificial intelligence (AI) models on cheap microcontrollers like the ESP32 is often considered impossible without the help of the cloud or external memory (PSRAM). However, the WiTiAI INT8 96K development project proves that modern Large Language Model (LLM) architectures can be pared down and optimized to run seamlessly locally within the ESP32's built-in SRAM—no WiFi, no filesystem, and no Python interpreter. 

Architectural Leap: From 4-Bit QnM To Native INT8 96K

The WiTi1 INT8 96K runtime is the result of porting and extreme simplification of the qnm-kernel inference engine. While the previous approach relied on a 4-bit quantization (QnM) format that stored activations in float32 and performed decoding per dot-product operation, this new architecture uses a native INT8 per-row approach for weights while storing activations in INT8 per vector format before accumulating to int32. 

This fundamental change makes the model with a capacity of 95,968 parameters (96K) with a vocabulary of 64 character-level symbols (character-level) fully executable using static memory without dynamic allocation (malloc/heap). All modern computing components—from RMSNorm, RoPE (Rotary Position Embedding), GQA (Grouped-Query Attention), to SwiGLU—are maintained in portable C99 language code.

Super Compact Memory Footprint in ESP32 SRAM

False One of the biggest challenges in embedded systems is memory limitations. By embedding model weights as a constant array (const) directly in Flash/ROM memory, RAM usage can be kept to a minimum: 

  • INT8 Model Weights + Scale: Takes up approximately 96.6 KiB (98,928 bytes) in Flash/ROM memory.
  • KV Cache (128 tokens): Allocated statically at 112.0 KiB in RAM.
  • Working Buffer (Activation, Logits, LUT): Only requires about 3.9 KiB in RAM. 

Overall, this runtime only requires a total of ± 115.9 KiB RAM for a context length of 128 tokens. If the context length is set to 64 tokens (WITI_MAX_SEQ=64), RAM requirements shrink drastically to ± 60 KiB, leaving a lot of space for the classic ESP32 to perform both sensor reading and network communication tasks simultaneously. 

Computational Performance and Parity Test Accuracy

Each token generation on the WiTi1 96K model requires a computational load of approximately 192,000 MAC operations (Multiply-Accumulate) based on an 8-bit integer.On a 240 MHz ESP32 microcontroller—which lacks hardware-specific INT8 dot-product instructions—inference speeds are estimated at 3 to 10 milliseconds per token (equivalent to 100–300 tokens per second). 

In a parity test against a floating-point computing reference (float32 in NumPy/PyTorch), the C INT8 runtime recorded a very high level of cosine similarity, namely <0.99997 to 0.99999 with a maximum error below 0.093. 

Real Applications in Agricultural IoT Scenarios

The WiTi1 INT8 96K model has been specially trained for the tasks of command translation and hardware sensor reading (PIN -> sensors). For example, when the system receives raw text input in the form of "pin a0", the model immediately processes it locally and produces a structured output such as "light sensor value 512.". 

In evaluation of this IoT scenario, this model achieved 100% accuracy (16/16 on the standard prompt and 128/128 on all prompt variations). This capability paves the way for low-cost edge devices to understand light text instructions, map sensor states autonomously, and support both the ESP-IDF and Arduino IDE frameworks directly. 

Commentary (0)

Leave a Comment