---
title: "WWDC 24: Running Mistral 7B with Core ML"
description: "Mistral 7B Instruct can run on a Mac with Core ML using features new in iOS 18 and macOS Sequoia: the MLTensor Swift type for tensor pre- and post-processing, stateful buffers that keep the kv-cache on the GPU instead of passing it in and out on every call, and block-wise 4-bit quantization."
url: "https://swe.quest/articles/wwdc-24-running-mistral-7b-with-core-ml-8ff5ba3b889a9bf2"
canonical: "https://huggingface.co/blog/mistral-coreml"
source: "Hugging Face"
published: "2024-07-22"
difficulty: "medium"
kind: "How-to"
reading_minutes: 13
tags: ["inference","llms","swift","mobile"]
---

# WWDC 24: Running Mistral 7B with Core ML

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2024-07-22, 13 min read, How-to. Original: [https://huggingface.co/blog/mistral-coreml](https://huggingface.co/blog/mistral-coreml)

## Summary

Mistral 7B Instruct can run on a Mac with Core ML using features new in iOS 18 and macOS Sequoia: the MLTensor Swift type for tensor pre- and post-processing, stateful buffers that keep the kv-cache on the GPU instead of passing it in and out on every call, and block-wise 4-bit quantization. The conversion patches the transformers Mistral attention to use a pre-allocated, in-place kv-cache, traces it with torch.jit, and converts it with coremltools RangeDim inputs and StateType caches. Int4 per-block linear quantization (block size 32) shrinks the model from about 14GB in float16 to about 3.8GB. Inference then runs through the preview branch of swift-transformers.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Swift](https://swe.quest/tags/swift.md) (Languages)
- [Mobile](https://swe.quest/tags/mobile.md) (Web & mobile)

## Prerequisites

- transformer kv-cache ([easy posts on Caching](https://swe.quest/tags/caching.md?difficulty=easy))
- PyTorch model tracing ([easy posts on Observability](https://swe.quest/tags/observability.md?difficulty=easy))
- weight quantization basics ([easy posts on Inference & serving](https://swe.quest/tags/inference.md?difficulty=easy))
- Swift ([easy posts on Swift](https://swe.quest/tags/swift.md?difficulty=easy))

## Keywords

Core ML, coremltools, Mistral 7B, swift-transformers, MLTensor, Apple Silicon, WWDC 24

## Related posts

- [Releasing Swift Transformers: Run On-Device LLMs in Apple Devices](https://swe.quest/articles/releasing-swift-transformers-run-on-device-llms-in-apple-devices-ee6106831bf892fd.md): Hugging Face · 2023-08-08 · Medium · 15 min read · Swift, Inference & serving, LLMs, Mobile
  Hugging Face released swift-transformers, an alpha Swift package with a transformers-like API for on-device text generation, along with the swift-chat demo app, updated exporters and transformers-to-coreml conversion tools, and pre-converted Llama 2 7B and Falcon 7B Core ML models.
- [Faster Stable Diffusion with Core ML on iPhone, iPad, and Mac](https://swe.quest/articles/faster-stable-diffusion-with-core-ml-on-iphone-ipad-and-mac-5c3ad0b6711e28d5.md): Hugging Face · 2023-06-15 · Medium · 9 min read · Inference & serving, Mobile, Computer vision, Hardware
  Core ML in iOS 17 and macOS 14 adds 6-bit weight palettization for running Stable Diffusion faster and with less memory.
- [Swift Transformers Reaches 1.0 – and Looks to the Future](https://swe.quest/articles/swift-transformers-reaches-1-0-and-looks-to-the-future-a8395154e2037c4e.md): Hugging Face · 2025-09-26 · Easy · 5 min read · Swift, Inference & serving, LLMs, Mobile
  swift-transformers, Hugging Face's Swift library for running local models on Apple Silicon, reaches 1.0.
- [Stable Diffusion XL on Mac with Advanced Core ML Quantization](https://swe.quest/articles/stable-diffusion-xl-on-mac-with-advanced-core-ml-quantization-eb7e4e62c0405a93.md): Hugging Face · 2023-07-27 · Medium · 8 min read · Inference & serving, Computer vision, Mobile, Swift
  Stable Diffusion XL base has been ported to Core ML for Apple Silicon Macs (macOS 14 beta), with end-to-end latency ranging from 46 s on an M1 Max to 20 s on an M2 Ultra using CPU+GPU and the ORIGINAL attention implementation.
- [Using Stable Diffusion with Core ML on Apple Silicon](https://swe.quest/articles/using-stable-diffusion-with-core-ml-on-apple-silicon-ec28c0373922e17b.md): Hugging Face · 2022-12-01 · Medium · 6 min read · Inference & serving, Computer vision, Swift, Python
  Stable Diffusion can run on Apple Silicon via Core ML using Apple's ml-stable-diffusion repo, with pre-converted checkpoints for v1.4, v1.5, v2 base and v2.1 base hosted on the Hugging Face Hub.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
