Small model lab

Getting LFM3 into iPhone Safari

LFM3 1.7B is Liquid AI's first small model trained for agent harnesses, and in Squiggle it does what the smaller ones don't: it greets you without reaching for a tool, writes code itself, and picks the right tool when it needs one. But the only builds that ran in a browser were llama.cpp on the CPU (1.7 words a second in Safari on an iPhone 16) and an ONNX export that killed the Safari tab while downloading. WebLLM runs models on the GPU through WebGPU, which Safari on iOS now has, and nobody had built LFM3 for it.

It runs: 13.7 tokens a second in Safari on an iPhone 16, first word in 15 seconds, with Squiggle's full prompt and tools. Getting there took a model definition written from scratch, a compiler built from source, and eight Hugging Face jobs (51 CPU-minutes, about 3 cents). A 3-bit build saved 200 MB and lost the model's judgement. Liquid's own 4-bit weights, trained to survive the rounding, drop into our build bit-for-bit.

Why any of this: the 2 GB tab

Everything on this page comes from one number. Safari on an iPhone gives a web page roughly 2 GB of memory, and iOS kills the tab, with no warning and nothing the page can catch, the moment it goes over. Apple doesn't publish the limit, so we measured it with Squiggle's memcap page, on two phones. It fills a tab with memory until the browser stops it, several times over, once each for plain JavaScript, WebAssembly and the GPU.

Show every memory type, lowest to best run

Two things in the iPhone's numbers decided everything after this. All four kinds of memory stop at about the same 1.9 GB, and filling JavaScript and the GPU at the same time stops there too (992 MB + 936 MB in the middle run), so it's one budget: a model's weights on the GPU come out of the same 1.9 GB as the page. And it's steady: five rounds landed within about 0.1 GB of each other. An Android phone in Firefox went past every cap the test had, so the limit is Safari's on iOS, not phones in general. Test your own phone.

A 1 GB model doesn't fit just because 1 GB is less than 1.9 GB. What matters is how much memory the runtime needs to load it and to run a long prompt through it. Here's how each way of running LFM3 went, measured with Squiggle's memtest page in Safari on that iPhone 16:

So the question became: is there a runtime that keeps LFM3 under 1.9 GB through a whole task? WebLLM was the best bet, because it loads weights shard by shard straight onto the GPU instead of holding the whole file in JavaScript first. That's why Qwen3 0.6B and LFM2.5 1.2B already ran on WebLLM on this iPhone when the same sizes died elsewhere. No WebLLM build of LFM3 existed, so the rest of this page is making one.

Eight jobs to a working build

Each job ran on a Hugging Face CPU box. The red ones failed, and each failure got one step further than the one before. Pick a job.

Why not just use the existing tools?

A WebLLM model is two halves that have to agree: weights, and a .wasm model library compiled by TVM, which carries its own copy of TVM's runtime. WebLLM's JavaScript calls into that runtime by name. TVM renamed those functions in October 2026, and WebLLM 0.2.87 followed. So a library compiled before the rename and the current WebLLM can't talk to each other, and every prebuilt compiler you can download was from before it.

That's why the LFM2.5 build Squiggle already used only loads on WebLLM 0.2.86, and why LFM3 needed TVM built from source at the exact commit WebLLM 0.2.87 ships with (e345029), plus mlc-llm (MLC's model compiler) at the matching commit. Neither had any LFM model in it, so the model itself had to be written too.

What had to be written: three kinds of layer

LFM3 isn't a plain transformer. 13 of its 24 layers are short convolutions that only look at the last few tokens, 5 use attention over a 256-token window, and 6 use attention over everything. Each needed its own code in MLC's model language. Click a layer to see how far back it reads.

Rounding to a few bits

To fit in a Safari tab, each weight becomes a small whole number times a shared scale, one scale per group of weights. These are 32 real weights from LFM3. The hollow dots are the original values, the filled ones are where rounding puts them, and the lines are the levels it can choose from.

Bits
Rounded by

How far each method moves the weights

Average distance between the rounded and original weights, as a share of an average weight, over 256 rows of each matrix. MLC's plain 4-bit is a little worse than llama.cpp's because it uses 15 levels where llama.cpp uses all 16. Its 3-bit uses only 7.

Liquid's trained weights are no closer to the originals than plain rounding. They're a little further away. In 70–78% of groups Liquid picked a different scale than plain rounding would, and 6–12% of the weights sit on a different level. That's the training: weights moved on purpose, so that what the model does stays the same even though the numbers changed. Plain rounding is only trying to keep the numbers close.

Copying Liquid's weights without rounding again

Liquid ships its trained 4-bit weights as llama.cpp's Q4_0. MLC's format looks almost the same, groups of 32 with one fp16 scale, but counts its levels from the other end. Rounding Liquid's weights a second time would throw the training away. Flipping the level and the sign of the scale instead lands every weight exactly where Liquid put it. Drag the level.

The converter (qad_to_mlc.py) does this for all 107 linear layers and was checked bit-for-bit against Liquid's file on every kind of layer. MLC never notices a negative scale: it's just a number.

Which build wrote this?

Each build got "Hii" (or "Hi"), in Safari on the iPhone 16 or through llama.cpp on a server. Same model, same prompt and tools. Guess which build each reply came from.

Where the memory goes

A web page in iPhone Safari can't see how much memory it has. iOS kills the whole tab when it uses too much, with no warning and no error the page can catch. Safari for iOS has no setting for this, and a page can't ask for more. On the test iPhone 16 Squiggle's memcap test put the limit at about 1.9 GB, and it's one budget: JavaScript, WebAssembly and WebGPU all draw from it. A model's weights live on the GPU, so they come out of the same 1.9 GB as the page. The 4-bit build ran a whole conversation, then died partway through a task once a tool result made the prompt longer.

Weights
Model library
Context

What it says

Builds: 4-bit Liquid's trained 4-bit 3-bit The code, job logs and full write-up Try it in Squiggle