Major Step:
New emx-onnx-cgen 1.5 Compiles Qwen, Llama & Co. to C

December 01, 2026

The weights sit in a separate file, and the code is something you can read, review and step through in a debugger.

Until now, emx-onnx-cgen compiled small models, from kilobytes to megabytes. Last month’s language model on a floppy disk was one of them: 380 KB of weights, and a KV cache that ONNX has nowhere to keep.

Release 1.5 takes a step of about a factor of 1,000: to small language models in the gigabyte range. Ten models from Hugging Face now compile to plain C, up to Llama 3.2 1B with 1.2 GB of weights.

𝗧𝗲𝗻 𝗺𝗼𝗱𝗲𝗹𝘀

Qwen2.5-0.5B · Qwen3-0.6B · SmolLM2-360M · Gemma 3 270M · ERNIE 4.5 0.3B · LFM2-350M · LFM2-700M · Granite 4.0 H 350M · TinyLlama 1.1B · Llama 3.2 1B

270M to 1.2B parameters, all 8-bit exports from onnx-community.

𝗔 𝗹𝗮𝗻𝗴𝘂𝗮𝗴𝗲 𝗺𝗼𝗱𝗲𝗹 𝗮𝘀 𝗽𝗹𝗮𝗶𝗻 𝗖

About 20,600 lines of plain C, not counting blank lines and comments, describe all of Llama 3.2 1B: every layer, the attention, the handling of the KV cache. No framework, no interpreter, no hidden kernels, nothing beyond the C standard library. All that is missing for a complete chat in C is a tokenizer and a little glue code.

𝗪𝗵𝗮𝘁 𝗯𝗿𝗲𝗮𝗸𝘀 𝗮𝘁 𝗮 𝗴𝗶𝗴𝗮𝗯𝘆𝘁𝗲

  • The KV cache outgrows the model. At its full context of 131,072 tokens, Llama 3.2 1B needs 8 GiB of cache for 1.2 GB of weights. The cache lives in persistent state buffers, one declaration covers every layer, and its maximum size is fixed when the C code is generated.

  • Static data hits a wall. A Windows executable holds at most 2 GB of it. Above 1 GiB, weights, state and temporaries move to the heap by themselves, allocated once at load time, never during inference.

  • The code gets long. Granite 4.0 H prefill has 4,398 node functions; nodes with identical kernels now share one, and 338 remain.

  • Architectures stop being plain transformers. GroupQueryAttention and RotaryEmbedding from ONNX Runtime GenAI exports, short convolutions in LFM2 and Mamba2 layers in Granite 4.0 H all compile.

𝗛𝗼𝘄 𝘄𝗲 𝗰𝗵𝗲𝗰𝗸𝗲𝗱 𝗶𝘁

Every model ran as generated C and in ONNX Runtime on the same inputs. The logits agree within 6e-4 up to the first int8 rounding tie, and greedy decoding picks the same tokens apart from near ties.

𝗪𝗵𝗮𝘁 𝗰𝗼𝗺𝗲𝘀 𝗻𝗲𝘅𝘁

Release 1.5 is the start of language model support in emx-onnx-cgen. The next step is support in the emmtrix Edge AI Compiler, which takes the portable C from emx-onnx-cgen and specializes it for a concrete target with source transformations and vectorization.

One thing this is not: a microcontroller story. These models need hundreds of megabytes to gigabytes of memory.

Illustration of Qwen, Llama, Gemma, SmolLM, ERNIE, LFM2, Granite and TinyLlama flowing through a funnel labelled “emx-onnx-cgen 1.5” onto a chip marked “C”, representing the conversion of language models into C code.

emx-onnx-cgen 1.5 translates ten language models into portable C code.

Cookie Consent with Real Cookie Banner