Open Source Models
How to Run Mistral on iPhone: A Ministral 3B Guide
If you want to run Mistral on iPhone, start with the specific variant.
What to try
- Confirm that your runtime supports the architecture and format.
- Compare a short prompt with a multi-turn exchange and see whether the model keeps following the initial instructions.
If you want to run Mistral on iPhone, start with the specific variant. A base model and an instruction-tuned model can share a family name while behaving differently in chat.
Ministral 3B vs. 8B: Architectural Decisions for Mobile Apple Silicon
Deploying foundation models on edge devices requires balancing parameter density against the physical memory bandwidth of mobile systems-on-chip. Ministral 3B and Ministral 8B reflect two distinct operational targets for local computing:
- Ministral 3B (Mobile Sweet Spot): Configured with 26 transformer layers, a hidden dimension (
d_model) of 3,072, and an intermediate SwiGLU feed-forward dimension of 9,216. It implements Grouped-Query Attention (GQA) with 32 query heads and 8 key-value heads (a 4:1 compression ratio) across an expanded 131,072-token vocabulary. In 4-bit affine quantization, the resident weights require 1.93 GB of DRAM, fitting comfortably inside the 4.8 GB memory budget of 8 GB iPhones. - Ministral 8B (Desktop and iPad Pro Class): Built with 36 transformer layers, a hidden dimension of 4,096, and 32 query heads with 8 KV heads. Even under 4-bit quantization, its resident weight footprint demands 4.65 GB of DRAM. When combined with runtime activations and system overhead, total memory pressure reaches 5.1 GB to 5.5 GB, exceeding the foreground memory limit of 8 GB iPhones and triggering immediate kernel termination. Ministral 8B is therefore reserved for M-series iPad Pro and Mac hardware with 16 GB or more of unified memory.
Because the iPhone 15 Pro (A17 Pro) and iPhone 16 Pro (A18 Pro) feature 8 GB of unified LPDDR5/LPDDR5X memory with 34.6 GB/s of bandwidth, Ministral 3B represents the optimal frontier checkpoint. It concentrates maximum reasoning capacity per byte of memory without triggering aggressive background task evictions.
To evaluate A18 Pro throughput against the A17 Pro and M-series chips, review the benchmark analysis for local LLMs on iPhone 16 Pro.
Interleaved Sliding Window Attention: Cutting the KV Cache Penalty
In standard transformer decoders with full self-attention, the memory footprint of the Key-Value (KV) cache grows linearly across all layers with sequence length (S):
Memory_KV = 2 * L * H_KV * D_head * S * P bytes
For a 26-layer model with 8 KV heads and a per-head dimension of 128 in 16-bit precision (P = 2 bytes), every token adds 106,496 bytes to DRAM. At an 8,192-token context length, a traditional full-attention KV cache absorbs 872 MB to 917 MB of RAM. In continuous multi-turn sessions or long technical document queries, this linear accumulation rapidly exhausts mobile memory margins.
Ministral addresses this bottleneck through Interleaved Sliding Window Attention (SWA). Rather than applying uniform full attention or uniform local attention across all layers, Ministral alternates layer topologies:
- Full Attention Layers (Every Second Layer): Odd transformer layers retain global self-attention across the complete conversational sequence. This ensures that needle-in-a-haystack retrieval, distant document context, and global semantic dependencies remain fully accessible to the model.
- Sliding Window Layers (Every Second Layer): Even transformer layers enforce a strict sliding window of
W = 4,096tokens. Attention activations older than 4,096 tokens are recycled in circular Metal memory buffers, bounding their KV memory footprint regardless of total sequence length.
At an 8,192-token sequence, this interleaved architecture reduces the effective KV cache memory from 917 MB down to 352 MB—a 61% reduction in dynamic memory overhead. Coupled with a RoPE base frequency of 10,000,000, Ministral preserves sharp positional discrimination up to 128k context windows without numerical drift or exponential cache growth.
To compare reasoning capabilities against Meta’s 3B architecture, review the analysis of Llama 3.2 on iPhone and its benchmarks.
How to test it on your device
Confirm that your runtime supports the architecture and format. Compare a short prompt with a multi-turn exchange and see whether the model keeps following the initial instructions.
To eliminate prefill latency in long-context prompts with sliding windows, see how prompt caching for local LLMs on Apple Silicon operates.
Memory Footprint, 4-Bit Quantization, and iOS Jetsam Boundaries
Operating local transformers on iOS requires strict adherence to Darwin's memory arbiter: the Jetsam subsystem. Unlike macOS, which utilizes dynamic NVMe virtual memory swap to handle memory spikes, iOS disables disk paging to prevent flash wear and eliminate UI stutter.
Jetsam monitors an application's anonymous dirty memory footprint (phys_footprint). If a foreground process crosses its hard allocation threshold, Jetsam issues an immediate, uncatchable EXC_RESOURCE (RESOURCE_TYPE_MEMORY) signal followed by SIGKILL (exit code 0x8badf00d):
- 6 GB iPhones (iPhone 13, 14, 15 base): Enforce a foreground ceiling of approximately 3.2 GB to 3.4 GB.
- On iOS, the memory budget available to an app depends on the device, OS version and memory pressure. Test on the target device with representative context and attachments.
At full 16-bit float precision, Ministral 3B's weights occupy 6.2 GB, causing instant process termination on an 8 GB iPhone upon allocation. By applying 4-bit affine quantization with a group size of 64 in Apple MLX, weight memory is compressed to 1.93 GB. Runtime allocations divide as follows:
- Quantized Weights: 1.93 GB resident DRAM.
- Metal Shader & Framework Runtime: ~120 MB dirty memory.
- Host Swift Application & Tokenizer: ~60 MB dirty memory.
- KV Cache (2,048 Tokens Context): ~240 MB dirty memory.
This yields a peak working memory footprint of 2.35 GB, leaving 2.45 GB to 2.85 GB of free operating margin before approaching Jetsam thresholds. Even as context expands to 8,192 tokens (raising total footprint to 2.55 GB), Ministral 3B remains well within safe operational limits, allowing concurrent background audio playback, push notifications, and UI animations without memory pressure warnings.
To understand DRAM budgets and jetsam subsystem ceilings across 8 GB devices, see the guide on how much RAM a local LLM needs.
Engineering Best Practices for Deploying Mistral on iOS via MLX
To deploy Ministral 3B safely and efficiently within iOS and iPadOS applications using Apple MLX, follow these core architectural guidelines:
- Utilize Metal Shared Storage for Zero-Copy Access: Allocate model weights and KV tensor buffers using
MTLResourceStorageModeShared. In Apple's Unified Memory Architecture, shared buffers allow the Swift orchestration layer and the GPU Metal compute shaders to access identical physical DRAM pages without serialization copies or inter-process IPC overhead. - Implement Circular Ring Buffers for SWA Layers: For the alternating sliding window attention layers, implement a circular ring buffer in Metal. As token generation advances past index 4,096, overwrite expired Key and Value slots directly rather than resizing or reallocating tensor memory, preventing runtime heap fragmentation.
- Pre-Allocate the 131k Vocabulary Logit Projection: Ministral uses a large 131,072-token vocabulary. Allocate the final output projection matrix (
lm_head) once during runtime initialization. Reallocating logit projection tensors during active token decoding causes memory churn and drops generation throughput by up to 15%. - Combine SWA with Prefix Prompt Caching: Pre-evaluate the Key-Value tensors for static system prompts and pinned instructions. Bypassing GEMM prefill computation on initial prompts reduces Time-To-First-Token (TTFT) from 140 milliseconds to under 12 milliseconds on multi-turn conversations.
- Continuously Query Memory Headroom via Darwin APIs: Integrate
os_proc_available_memory()checks before expanding conversation context. If system-wide memory headroom drops below 750 MB due to concurrent background system tasks, cap the KV cache window or evict earlier conversational turns to maintain a deterministic safety margin against Jetsam.
To evaluate the trade-off between perplexity and memory bandwidth, see the comparison of 4-bit and 8-bit quantization on mobile.
The Lapis model catalogue shows compatible options before you choose a download.
Sources and references
- Mistral 7B
Albert Q. Jiang, Alexandre Sablayrolles, Arthur Mensch, Chris Bamford, Devendra Singh Chaplot, Diego de las Casas, Florian Bressand, Gianna Lengyel, Guillaume Lample, Lucile Saulnier, Lélio Renard Lavaud, Marie-Anne Lachaux, Pierre Stock, Teven Le Scao, Thibaut Lavril, Thomas Wang, Timothée Lacroix, William El Sayed (arXiv:2310.06825, 2023)
- GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints
Joshua Ainslie, James Lee-Thorp, Michiel de Jong, Yury Zemlyanskiy, Federico Lebrón, Sumit Sanghai (arXiv:2305.13245, 2023)
- MLX
Apple Open Source
Local execution with Lapis
Chat with compatible models on iPhone, iPad and Mac. Download them once and use local inference offline; model size depends on your device’s resources.