AIAI EngineerApr 20, 2026· 10:51

Running LLMs on your iPhone: 40 tok/s Gemma 4 with MLX — Adrien Grondin, Locally AI

Adrien Grondin, developer of Locally AI, demonstrates how to run Gemma 4 and other LLMs on iPhone using Apple's MLX framework, achieving 40 tokens per second on the latest devices. He explains that MLX is optimized for Apple Silicon and that the open-source mlx-swift-lm GitHub repo enables easy integration into iOS, macOS, and iPadOS apps in under 10 minutes. Grondin recommends quantized models from the Hugging Face MLX community—typically 4-bit to 8-bit—and shows a live demo of Gemma 4 generating text offline. He confirms that mlx-swift-lm supports tool calling, though structured generation is not yet available. He also notes that Locally AI has been acquired by LM Studio, which now lets users run models via MLX or llama.cpp and connect them through OpenAI or Anthropic-compatible APIs.

Transcript

Intro0:00

Adrien Grondin0:15

Okay, hello everybody. I'm going to show you today how to run Gemma 4 on iPhone with MLX. So first, let's introduce myself: I'm Adrien, you can find my Twitter if you want to learn more about all on-device things.

I'm the developer of Locally AI, so maybe you've already seen the app. Locally AI is a chatbot that allows you to run on-device models on your iPhone with MLX. I will just go through what MLX is in a few seconds.

Basically, as I said, it's a chatbot, it's fully native. You can also chat with Apple Foundation with it, and many models that are compatible with MLX. One of these models is Gemma 4. So basically, Gemma 4, by Golden Mine, has a lot of models, and some of them can run on iPhone, like the smaller ones, and they're pretty great.

Maybe you've seen on Twitter one of the posts I've made that I demo it running in the app on iPhone. It's really fast, it runs really well on MLX, and behind the app it's using MLX. MLX is a framework made by Apple that is optimized for Apple silicon, so mainly the chip in iPhone, but also the chips on the Mac.

The app locally is available on iPad, it works also very well on this device, and macOS, and everything is built to be as optimized as possible on these devices. So if you want to run on iPhone a language model, Gemma works well, but you have a lot of models that you can run also: the Qwen model and the small LM model from Hugging Face.

mlx-swift-lm2:03

Adrien Grondin2:03

The place you'll want to go is GitHub, and go to the repo mlx-swift-lm. I won't go into detail on how you implement the repo, I think I'll let your agent implement that for you, but it's one repo that you need to install if you're developing an iOS or macOS or iPadOS app.

And you can use that to simply download the model and then run it. The API is very straightforward, very simple to implement. In less than 10 minutes you can have an iOS app with a model that is running on your device.

That's very simple to do, as mentioned. MLX, so this is mlx-swift-lm, but if you're more into Python apps or macOS apps, you can also run mlx-vlm from Prince. Maybe you've seen him, he's doing on-device for audio with MLX Audio and visual model with mlx-vlm, and also mlx-video

MLX Ecosystem2:33

Adrien Grondin2:55

to run image generation model or video generation model. MLX, the ecosystem is getting bigger, it's getting bigger, it's really greatright now. You can do pretty much everything, like omni-models, or as I said, text-to-speech, speech-to-speech. There's a lot of things that you can do with a model.

And basically, let's say you integrate

this model, you can't just run any model on it. You need to get some model, and there's a good place to get the model is Hugging Face. I'm pretty sure everybody heard of Hugging Face. And on Hugging Face, you will want to look for the MLX community.

Hugging Face3:21

Adrien Grondin3:35

This is where all the weight of a model, the quantized weight, the full size, will be uploaded. So you will just be able to go to this community, look for the models. I thinkright now there's almost 4,000 or 5,000 models uploaded, so the community is really active on it.

When a model is released by your lab, you will directly have it almost 30 minutes after release, quantized in 4-bit, 6-bit, and everything that you can imagine. Here you have an example for Gemma 4 HUB, which is the one I run on iPhone.

There's a lot of variants of it, from BF16, MXFP4, 5-bit, 6-bit, there's everything. So you download mlx-swift-lm, install it with your agent or anything, then you go to the MLX community and you just choose the model you want to run.

And then with the ID you can just pass it to the framework and it will be integrated with Hugging Face to download the model with mlx-swift-lm directly. So you just need to grab the ID and pass it to the framework.

Usually when you're running the model on iPhone, what you want to do is select some quantized version of the model, because the full size will be way too large. What I recommend is trying, depending on the size, between 3-bit and 8-bit.

Quantization4:42

Adrien Grondin5:01

Usually between 4-bit and 8-bit. Usually under 4-bit it's starting to get a lot of impact on the output and the models are not that great usually. 4-bit is the lower I would go, and 8-bit is the higher I would go if you're using really small models.

In my app, for example, I have some bigger models like Gemma 4, but I also have some liquid models that are 350 parameters, and this can run in shortcuts. So you can do a lot of kind of automation, because the models are really fast and really efficient at that size to do some text processing and things like this.

And on the latest iPhone, if you take Gemma 4 HUB, quantized in 4-bit, it's extremely fast. It can run easily at 40 tokens per second. I will just do an update in the slide, because I removed a slide where there's the video, but maybe I can add it back because I have a little bit more time.

40 tok/s Demo5:40

Adrien Grondin6:02

I will just go like this, so just to show you in demo what the 40 tokens per second means. And that's running live, offline. And as you can see, it's really fast. 40 tokens per second is more than acceptable for a lot of use cases.

This is, of course, streaming. You can also not do streaming and do a UI that just will wait for 4 seconds. And the output is quite long, so it's generating a lot of tokens. So on-device with MLX, it's working, it's here.

It's really not easy and really not hard to integrate. As I said, if you go to the repo mlx-swift-lm, it's a breeze to install. On top of that, as I said again, the latest iPhone is really great, but it works also with older iPhones.

You will not get 40 tokens per second, which is quite fast, but even if you get 20 tokens per second, that's already great and useful

for a lot of applications, a lot of use cases that you would want to do

with your app. You can go and scan this QR code if you want to try it by yourself. If you have an iPhone, the app is on the App Store, it's free to use. The only thing is that you will have to download the model.

Try Locally7:10

Adrien Grondin7:21

That's usually 1 GB or 3 GB, really depends on which model, but that's the biggest barrierright now, it's the size of the model. But this also is getting better. Models are getting smaller or getting smarter, and also the iPhone is getting better.

So next iPhone and the next next iPhone, everything is reaching really great usability from what I can see. And also on top of that, maybe you've heard the news yesterday, Locally has been acquired by LM Studio. If you don't know LM Studio, it's basically kind of an AI studio for all your local models.

LM Studio7:39

Adrien Grondin8:05

So you can download any model with LM Studio directly from Hugging Face. You can run them, and you can open the server, you can run them with Llama CPP, but also MLX, so you can really compare the different engines how they work.

As I said, you can open a server locally and connect your application to this hosted server with

various response types. For example, OpenAPI response type, or Anthropic response type for streaming and anything, and you can just get any model running really easily with that. So I want to thank you, that was a really short introduction, how you can do the same and run any model like in Gemma 4 if you want on your iPhone.

If you have any questions, also.

Guest9:03

Does this support tool calling?

Q&A9:03

Adrien Grondin9:04

Sorry?

Guest9:05

Does this support tool calling?

Adrien Grondin9:06

Yes, yeah, I forgot about that. So it supports tool calling.

Not yet structured generation. There are some packages on top of mlx-swift-lm that are trying to make this working.

Hugging Face is doing it, but you can easily find them online. But mlx-swift-lm, yes, it supports tool calling, so that's really useful if you want to do tool calling and call other systems. And the models are getting also better at tool calling.

They were not so great a year ago, now it's getting much better.

Guest9:43

I see you mentioned two things. First was the GitHub repo, and then the second thing was the app.

Adrien Grondin9:50

So you have the GitHub repo for mlx-swift-lm, that's the package that you will install in your app, and then you need to go to Hugging Face to get the weight of a model.

Guest10:03

But for a normal user, they can just download the app from the app?

Adrien Grondin10:07

Oh, and yes, if you want to try my app, you can. If you want to try itright now without having anything to install, you can do that.

Guest10:13

And you can choose any open-source model inside the app?

Adrien Grondin10:17

If there's a selection, but it's not any. I'm not sure that all the models run correctly on the iPhone, because not all of them work well.

Thank you very much.