Live data from Hacker News

I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

apps.apple.com

71–80 of 208 posts

Re: I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

#71
post #45

Is it weird if I carry a phone with this and a solar charger around at all times, in case I suddenly get hurled back in time?

Also put the latest dump of Wikipedia on your phone (Kiwix is great for this). The complete English one with images is about 100 GB.

And for older phones, Wiki2Touch is a jailbreak app that does the same without images in about 14 GB.

I'm writing a Wiki2Touch archive viewer for more modern iOS, because my iPhone SE doesn't have 100 GB free for Kiwix.

Re: I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

#72
post #27

I have a 2020 16in MacBook Pro. I think it's the last generation of Intel chips. I've been struggling to get some of the LLM models like Mixtral to run on it. I hate the idea of needing to buy another $3k laptop less than 4 years after spending that much on my current machine. But if I want to get serious about developing non-chatgpt services, do I need a new M2 or M3 chip to get this stuff running locally?

On your CPU, you should be able to leverage the same AVX acceleration used on Linux and Windows machines. It's not going to make any GPU owners envious, but it might be enough to keep you satisfied with your current hardware.

AVX code on laptop cooling sounds like it could be even slower! I don’t miss the heat from an intel laptop!

Re: I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

#73

Are these apps using the neural compute parts of Apple's chips? Or ar they just using the regular CPU/GPU cores?

TL;DR: No, nearly all these apps will use GPU (via Metal), or CPU, not Neural Engine (ANE).

Why? I suggest a few main reasons: 1) No Neural Engine API 2) CoreML has challenges modeling LLMs efficiently right now. 3) Not Enough Benefit (For the Cost... Yet!)

This is my best understanding based on my own work and research for a local LLM iOS app. Read on for more in-depth justifications of each point!

---

1) No Neural Engine API

- There is no developer API to use the Neural Engine programmatically, so CoreML is the only way to be able to use it.

2) CoreML has challenges modeling LLMs efficiently right now.

- Its most-optimized use cases seem tailored for image models, as it works best with fixed input lengths[1][2], which are fairly limiting for general language modeling (are all prompts, sentences and paragraphs, the same number of tokens? do you want to pad all your inputs?).

- CoreML features limited support for the leading approaches for compressing LLMs (quantization, whether weights-only or activation-aware). Falcon-7b-instruct (fp32) in CoreML is 27.7GB [3], Llama-2-chat (fp16) is 13.5GB [4] — neither will fit in memory on any currently shipping iPhone. They'd only barely fit on the newest, highest-end iPad Pros.

- HuggingFace‘s swift-transformers[5] is a CoreML-focused library under active development to eventually help developers with many of these problems, in addition to an `exporters` cli tool[6] that wraps Apple's `coremltools` for converting PyTorch or other models to CoreML.

3) Not Enough Benefit (For the Cost... Yet!)

- ANE & GPU (Metal) have access to the same unified memory. They are both subject to the same restrictions on background execution (you simply can't use them in the background, or your app is killed[7]).

- So the main benefit from unlocking the ANE would be multitasking: running an ML task in parallel with non-ML tasks that might also require the GPU: e.g. SwiftUI Metal Shaders, background audio processing (shoutout Overcast!), screen recording/sharing, etc. Absolutely worthwhile to achieve, but for the significant work required and the lack of ecosystem currently around CoreML for LLMs specifically, the benefits become less clear.

- Apple's hot new ML library, MLX, only uses Metal for GPU[8], just like Llama.cpp. More nuanced differences arise on closer inspection related to MLX's focus on unified memory optimizations. So perhaps we can squeeze out some performance from unified memory in Llama.cpp, but CoreML will be the only way to unlock ANE, which is lower priority according to lead maintainer Georgi Gerganov as of late this past summer[9], likely for many of the reasons enumerated above.

I've learned most of this while working on my own private LLM inference app, cnvrs[10] — would love to hear your feedback or thoughts!

Britt

---

[1] https://github.com/huggingface/exporters/pull/37

[2] https://apple.github.io/coremltools/docs-guides/source/flexi...

[3] https://huggingface.co/tiiuae/falcon-7b-instruct/tree/main/c...

[4] https://huggingface.co/coreml-projects/Llama-2-7b-chat-corem...

[5] https://github.com/huggingface/swift-transformers

[6] https://github.com/huggingface/exporters

[7] https://developer.apple.com/documentation/metal/gpu_devices_...

[8] https://github.com/ml-explore/mlx/issues/18

[9] https://github.com/ggerganov/llama.cpp/issues/1714#issuecomm...

[10] https://testflight.apple.com/join/ERFxInZg

Re: I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

#74
post #72

Earlier quoted context omitted.

On your CPU, you should be able to leverage the same AVX acceleration used on Linux and Windows machines. It's not going to make any GPU owners envious, but it might be enough to keep you satisfied with your current hardware.

AVX code on laptop cooling sounds like it could be even slower! I don’t miss the heat from an intel laptop!

It runs faster and cooler than the software-accelerated alternative. Probably cooler than my 3070 too, my laptop sat ~50c when using AVX to generate Stable Diffusion Turbo images.

Re: I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

#75

Here is how to do that on Android: https://github.com/ggerganov/llama.cpp/#android

I don't think running raw llama.cpp under termux in a shell on your phone, after downloading and compiling it from scratch,, is really comparable to 'I made an app'.

[deleted]

Re: I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

#77
edit: my bad, I misread the price and it's really hard to see the price after you bought it to double check.

$10 for something that (I think) doesn't work on most phones but isn't gated to ones it works on feels hostile.

Probably there's no way to gate, in that case I'd suggest not charging for it. Or I guess adding a daily usage limit that's lifted with an IAP.

I'll admit I was off-put by the price to begin with, which probably amplifies what a slap in the face it feels like to pay and get something that doesn't work at all.

Re: I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

#78

edit: my bad, I misread the price and it's really hard to see the price after you bought it to double check. $10 for something that (I think) doesn't work on most phones but isn't gated to ones it works on feels hostile. Probably there's no way to gate, in that case I'd suggest not charging for it. Or I guess adding a daily usage limit that's lifted with an IAP. I'll admit I was off-put by the price to begin with, wh…

It's $1.99 and the description says:

The app requires a Pro iPhone with a minimum of 6GB of RAM. Only the following devices meet the requirement:

- iPhone 15 Pro, iPhone 14 Pro, iPhone 13 Pro, iPhone 12 Pro.

- iPads: Please check. RAM varies based on model and year.

Re: I made an app that runs Mistral 7B 0.2 LLM locally on iPhone Pros

#79
post #43
post #36

Earlier quoted context omitted.

Yes, you can set the temperature to 0, then they should be deterministic.

Someone mentions temperature in the context of algorithms, can't stop thinking, cool, simulated annealing. Haven't seen temperature used in any other family of algo before this.

I'm interested, how does LLM temperature relate to simulated annealing?
Post reply on HN