cd /news/ai-tools/fitting-gemma-4-e2b-and-an-sdxl-mode… · home › topics › ai-tools › article
[ARTICLE · art-164782] src=discuss.huggingface.co ↗ pub= topic=ai-tools verified=true sentiment=↑ positive

Fitting Gemma 4 E2B and an SDXL model on one iPhone: notes from building Anvil

A developer building an iPhone app that runs Stable Diffusion through Core ML reported that Apple's ml-stable-diffusion guidance makes the biggest difference for fitting large models on-device, citing 6-bit palettization as Apple's recommended floor for SD weights and Mixed-Bit Palettization recipes that mix 1/2/4/6/8-bit layers to average around 4 bits. The developer noted Apple publishes precomputed mixed-bit recipes for SDXL base on Hugging Face at apple/coreml-stable-diffusion-mixed-bit-palettization, and that Apple's FAQ puts the peak-RAM saving from 16-bit to 4-bit weights at up to 75% on iOS 17 and later, where palettized weights can be decompressed just in time. The notes also cover Apple's SPLIT_EINSUM attention recommendation for the Neural Engine, its advice against SPLIT_EINSUM_V2 for SDXL because compilation takes too long, shipping .mlmodelc over .mlpackage for caching, and reduceMemory loading and unloading the text encoder, UNet and VAE just in time.

read1 min views2 publishedNov 5, 2026

Congrats on 4.1, and thanks for writing up the memory side. I work on an iPhone app that also runs Stable Diffusion through Core ML, and these are the parts of Apple’s ml-stable-diffusion README that made the most difference:

  • 6-bit palettization is the floor Apple recommends for SD weights. Going lower without visible damage needs their Mixed-Bit Palettization recipes, which mix 1/2/4/6/8-bit layers to land around 4 bits on average; they publish precomputed recipes for SDXL base on Hugging Face (apple/coreml-stable-diffusion-mixed-bit-palettization).
  • On iOS 17 and later, palettized weights can be decompressed just in time instead of at load. Their FAQ puts the peak-RAM saving from 16-bit to 4-bit at up to 75%.
  • For the Neural Engine on iPhone they recommend SPLIT_EINSUM attention. Their SD 1.x/2.x iPhone benchmarks use SPLIT_EINSUM_V2, but they advise against V2 for SDXL because compilation takes far too long.
  • Ship .mlmodelc rather than .mlpackage: the compiled model gets cached, while an .mlpackage re-runs model preparation on every load.
  • reduceMemory on StableDiffusionPipeline loads and unloads the text encoder, UNet and VAE just in time, which is the same idea as your chat/image model swap, one level down.

Have you noticed quality differences between Neural Engine and GPU output at 1024? Apple mentions small differences across compute units and I’ve wondered how visible they get with SDXL.

── more in #ai-tools 4 stories · sorted by recency
── more on @apple 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/fitting-gemma-4-e2b-…] indexed:0 read:1min 2026-11-05 · —