Checking how many agents are working

How this works
Contact
← Blog
Two phones lying face up on a dark steel bench, teal cables running between them and a small olive-lit chip beside, with the AMARBARO mark above.
✎blogbericht

Can a phone run a language model? What we found

The short version

A phone can run a small model with exactly correct output, but two phones given identical code can differ in steadiness, so a single device proves little.

What this is about

Can the phone in your pocket run a language model? Yes, a small one. We ran our own engine on two Android phones and checked that it produces the same words as a well-known reference program. We also learned that two phones running the same code can behave quite differently.

This article tells what we measured and what it does not show.

Why it matters

A phone is the most common computer in the world. If a model can run there, your text can stay on a device you carry. But phones are not small desktops. They have less memory, they get hot, and their chips vary a lot from model to model.

What changes on a phone

On the desktop, our engine runs on a big graphics card. A phone has a different kind of processor, called Arm64, and its own graphics chip. So the engine's card kernels cannot move over. We ported the processor-side kernels by hand into Mojo from a vendor binding, and checked them against the reference.

The check has three layers, each of which could fail alone:

  1. The 4-bit matrix multiply from the vendor's code matches the reference program's own multiply, byte for byte, on both phones.
  2. The same kernel, ported into Mojo, matches the vendor's.
  3. The whole engine, built from the ported kernels, produces the same greedy tokens as llama.cpp on both phones, for a 0.5B model at 4-bit weights.

All three passed. Notice what that proves, and what it does not. It proves that on these two phones, for this small model, our arithmetic gives the same numbers as the reference, bit for bit. It does not prove that the engine is fast, that it works for larger models, or that it works inside our phone app.

What we measured

The two phones were a Xiaomi and a OnePlus. We froze a steadiness rule before the runs: in a run of twenty, every run must stay above 0.7 times that run's own median.

  • Xiaomi. It passed cleanly. Prefill ran at 1.142 times llama.cpp and decode at 1.066 times, with no stalls over the whole run.
  • OnePlus. It was faster on every median: prefill at 2.16 times and decode at 1.58 times llama.cpp. But three of the twenty runs fell below 0.7 times the median, with a spread as wide as 59 percent on one measure and 32 percent on the other. It failed its own gate.

A median hides a few bad runs, which is why our gate checks every run, not just the middle one. A phone that is faster on average but unsteady has a result and an open bug. We report both together. Our current suspect is that processor cores are put to sleep between parallel stretches of work, but that is a suspicion and the question is not closed.

The OnePlus is also the phone with less room: about 2.5 GB of free memory. A pre-packed loader we built cut its anonymous memory from 276 MB to 5 MB, which it needs. It missed a speed bar we had set before, on first-token time, and we kept the feature anyway, labeled with the bar it missed.

A phone's graphics chip

We also tried the phone's graphics chip, on a Xiaomi 17 Ultra, which has an Adreno 840. We wanted to know whether changes to a key kernel make the chip faster and cheaper to run. But the phone hides its hardware counters without root access, and the power readings for the graphics chip all read zero. So we judged each kernel by three numbers: the time on the chip, a checksum that every version had to match, and the energy the battery gave up.

Energy could only be read with the charging cable out. On a cable, the charger hides the load. And it is the whole phone's extra draw, not the graphics chip alone.

Results at one size, 4096 by 4096:

  • The starting kernel took 160.8 microseconds.
  • A version using subgroups took 144.7, about 10 percent less, with the same energy.
  • A version using packed integer math took 144.4 microseconds and 16 percent less energy, with the chip 9 degrees Celsius cooler after 60 seconds than the starting kernel.

The integer version has a caution: it changes the output on real data, because it rounds the inputs to 8-bit numbers. Our test data was chosen so the rounding was exact. An engine that adopted it would need a quality check on real tokens first. And that is one phone, one driver and one day.

Why the two phones disagree

We do not fully know. The Xiaomi is steady and the OnePlus is not, under the same code and the same rule. The lesson is plain: one device's pass says nothing about another. A claim based on one phone generalizes only as far as two phones agree, and these two do not.

Words you may not know

  • Arm64: the kind of processor in most phones.
  • Bit-exact: giving exactly the same output as a reference, down to the last bit.
  • Prefill: reading the prompt. See the earlier article on the two speeds.
  • Decode: writing the answer one token at a time.
  • Median: the middle value of a sorted list of results.
  • Hardware counter: a number the chip keeps about its own work.
  • Adreno: the graphics chip family in many Android phones.

Try it

  • See how we look at why a processor instruction stalls, on a desktop or a phone, on the corewait project page. The page lists sequential read speed for five devices, three of them phones, and how to record a run through the Android debug tool.
  • Run a phone test of your own: time the same task ten times, and note the slowest and fastest, not only the average.
  • If you have two phones, run the same thing on both, and see if they agree.

Reacties

Nog geen reacties.

Inloggen om te reageren.