← Back to Reading
ByteByteGo 2026-10-27

How Apple Fits an LLM on Your iPhone

Running large language model inference on a mobile device introduces significant resource and architectural challenges. First, memory capacity is heavily constrained, as a 3-billion-parameter model at 16-bit precision requires nearly 6GB just for weights, competing with the operating system and temporary calculation storage. Second, memory bandwidth limits performance because the processor frequently stalls while waiting to fetch weights from memory during token generation. Engineering teams, such as Apple's iPhone team, must also manage battery drain, thermal throttling, and multi-app multitasking to avoid device unresponsiveness. Apple optimizes model storage requirements through weight quantization, primarily leveraging a technique called palettization where weights reference representative values in small lookup tables. An earlier model combined 2-bit and 4-bit representations for an average of 3.7 bits per weight, storing 3 billion weights in approximately 1.39 GB. Later models adopted more aggressive compression by assigning 2 bits to main decoder weights and 4 bits to embedding tables. To maintain output quality despite precision loss, Apple relies on quantization-aware training to adapt weights to these constraints during the training phase. Beyond compressing model weights, handling request memory during inference requires optimizing intermediate state storage. While the KV cache saves computation by preserving past key-value representations for subsequent token predictions, it scales significantly with context length and leads to high memory overhead. Apple addresses this constraint using cross-layer KV sharing, partitioning model layers across a 5:3 depth ratio so subsequent layers reuse keys and values from earlier layers. This optimization reduces overall KV-cache memory usage by 37.5%.

Read the original ↗
Contents 7 sections
  1. 01The Problems of Running an LLM on a Phone
  2. 02How Apple Makes the Weights Cheaper to Store
  3. 03How Apple Made Repeated Calculations Faster
  4. 04How Adapters Help Features Share the Foundation
  5. 05How Apple Optimizes the Hardware Running the Model
  6. 06How Does the System Decide When to Use the Cloud
  7. 07Conclusion

The Problems of Running an LLM on a Phone

Running large language model inference on a mobile device introduces significant resource and architectural challenges. First, memory capacity is heavily constrained, as a 3-billion-parameter model at 16-bit precision requires nearly 6GB just for weights, competing with the operating system and temporary calculation storage. Second, memory bandwidth limits performance because the processor frequently stalls while waiting to fetch weights from memory during token generation. Engineering teams, such as Apple's iPhone team, must also manage battery drain, thermal throttling, and multi-app multitasking to avoid device unresponsiveness.

  • At 16-bit precision, a 3-billion-parameter model occupies approximately 6GB of memory, excluding temporary calculation overhead and operating system usage.
  • Memory bandwidth presents a major bottleneck during generation because processors frequently wait for model weights to transfer from memory.
  • Apple faced memory capacity and memory bandwidth constraints when deploying its LLM to the iPhone.
  • Mobile on-device LLM inference must mitigate secondary constraints such as high battery consumption and device overheating to ensure overall system responsiveness.

How Apple Makes the Weights Cheaper to Store

Apple optimizes model storage requirements through weight quantization, primarily leveraging a technique called palettization where weights reference representative values in small lookup tables. An earlier model combined 2-bit and 4-bit representations for an average of 3.7 bits per weight, storing 3 billion weights in approximately 1.39 GB. Later models adopted more aggressive compression by assigning 2 bits to main decoder weights and 4 bits to embedding tables. To maintain output quality despite precision loss, Apple relies on quantization-aware training to adapt weights to these constraints during the training phase.

  • Quantization reduces model size by using fewer bits to represent weight values, balancing memory footprint against numerical precision.
  • Apple applies palettization, grouping similar weight values into a lookup table where individual weights store short index references.
  • An earlier 3-billion-weight model achieved an average of 3.7 bits per weight by mixing 2-bit and 4-bit precisions, fitting into about 1.39 GB.
  • Mixed precision allows sensitive components to retain higher bit representations while less sensitive parts undergo deeper compression.
  • A later model uses 2 bits per weight for main decoder weights and 4 bits for the embedding table, enabled by quantization-aware training.

How Apple Made Repeated Calculations Faster

Beyond compressing model weights, handling request memory during inference requires optimizing intermediate state storage. While the KV cache saves computation by preserving past key-value representations for subsequent token predictions, it scales significantly with context length and leads to high memory overhead. Apple addresses this constraint using cross-layer KV sharing, partitioning model layers across a 5:3 depth ratio so subsequent layers reuse keys and values from earlier layers. This optimization reduces overall KV-cache memory usage by 37.5%.

  • Model inference memory demands stem not only from model weights but also from processing requests via intermediate calculation caches.
  • A KV cache stores past intermediate results to avoid recalculating earlier tokens when generating new tokens, but its size increases with text length.
  • Comprehensive memory optimization requires both compressing model weights and shrinking KV cache size.
  • Apple utilizes cross-layer KV sharing by splitting model depth into two blocks with a 5:3 ratio, allowing layers in the second block to reuse keys and values from the final layer of the first block.
  • Cross-layer KV sharing reduces KV-cache memory consumption by 37.5%.

How Adapters Help Features Share the Foundation

Adapters allow multiple task-specific features to share a single base language model, avoiding the redundancy and expense of duplicating entire models. By freezing the base model's weights and modifying only a small set of parameters, techniques like LoRA (Low-Rank Adaptation) make specialization significantly cheaper. Apple uses this approach by attaching rank-16, 16-bit adapters to attention and feed-forward layers. These compact adapters require only tens of megabytes of memory and can be dynamically loaded, cached, or swapped as needed.

  • Adapters eliminate the need to duplicate core language capabilities across multiple task-specific models.
  • LoRA (Low-Rank Adaptation) freezes base model weights and only updates small adapter weights during training.
  • Specializing models with adapters is significantly cheaper than deploying independent base models for each feature.
  • Apple applies adapters to attention matrices, attention-output projections, and feed-forward layers.
  • Apple's rank-16 adapters use 16-bit values, take up tens of megabytes, and can be loaded, cached, or swapped on demand.

How Apple Optimizes the Hardware Running the Model

Deploying even small machine learning models requires efficient hardware execution to achieve optimal performance. Apple iPhones manage workloads using a combination of a general-purpose CPU, a parallel numerical GPU, and the specialized Apple Neural Engine (ANE). However, hardware acceleration alone is insufficient without software-level optimizations. Selecting proper data layouts, splitting large arrays, and minimizing memory copies are essential steps to improve execution speed and reduce memory consumption.

  • Efficient hardware implementations are necessary to maximize model performance, regardless of model size.
  • Apple iPhones distribute computation across CPUs, GPUs, and the Apple Neural Engine (ANE).
  • The CPU manages general-purpose operations, while the GPU handles parallel numerical processing.
  • The Apple Neural Engine is specifically designed for running machine learning workloads efficiently.
  • Hardware accelerators still require software optimizations such as appropriate data layouts and array chunking.
  • Minimizing memory copy operations directly enhances processing speed and reduces memory usage.

How Does the System Decide When to Use the Cloud

Apple Intelligence evaluates whether a user's request can be fulfilled by its on-device model or requires Private Cloud Compute (PCC) for complex tasks. Requests routed to PCC are encrypted end-to-end so that only validated PCC nodes within an authorized boundary can decrypt and process the data. This architecture ensures that outside infrastructure, external parties, and even Apple's own staff cannot access the request content. Once in the cloud, a separate server model employs parallel processing tracks and mixture-of-experts computation to process the query.

  • Apple's on-device model handles tasks like summarization, extraction, and classification, but offloads more complex requests to Private Cloud Compute (PCC).
  • PCC establishes a protected environment where only authorized software is permitted to process user data.
  • Data sent to PCC is encrypted on-device for validated nodes, ensuring external infrastructure and Apple personnel cannot access or decrypt the contents.
  • In the cloud, requests are handled by a dedicated server model leveraging mixture-of-experts computation and parallel processing tracks.

Conclusion

Apple launched AFM 3 Core, a 3-billion-parameter model, alongside AFM 3 Core Advanced, a 20-billion-parameter sparse model that activates only 1 to 4 billion parameters at runtime. AFM 3 Core Advanced optimizes local system memory by storing the full model on flash storage and dynamically loading only the relevant expert weights into RAM per prompt. Additionally, Apple expanded its cloud infrastructure to support Private Cloud Compute (PCC) workloads on NVIDIA GPUs hosted within Google Cloud. These developments reflect Apple's core design philosophy of tailoring model capability to real-time hardware resource availability.

  • In 2026, Apple introduced the AFM 3 Core, a 3-billion-parameter model generation.
  • Apple also launched AFM 3 Core Advanced, a sparse 20-billion-parameter model that selectively activates 1 to 4 billion parameters depending on Apple Silicon capabilities.
  • AFM 3 Core Advanced stores full weights on flash storage and loads only prompt-selected expert weights into RAM, avoiding per-token flash drive fetches.
  • Apple expanded its Private Cloud Compute (PCC) architecture to execute workloads on NVIDIA GPUs in Google Cloud.
  • Apple adheres to the design principle of sizing model capabilities dynamically to runtime system resources.