Skip to content

Carry llama.cpp#31437: vm_allocate host buffers on iOS (llamadart#2004) - #44

Merged
leehack merged 1 commit into
mainfrom
lane-2004-vm-allocate
Nov 14, 2026
Merged

leehack merged 1 commit into
mainfrom
lane-2004-vm-allocate

Conversation

@leehack

@leehack leehack commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Fixes the iOS host-buffer footprint behind llamadart#2004. ggml's CPU and Metal host buffers use posix_memalign/free on non-macOS Apple platforms, and libmalloc keeps the freed pages in the app footprint. Backport of llama.cpp ea24b952c (ggml-org/llama.cpp#31437) as two carried patches; retire when the pinned ggml includes it.

  • ggml_apple_vm_allocate.patch (ggml.c, target ggml-base) and ggml_metal_apple_vm_allocate.patch (ggml-metal-device.m, target ggml-metal, Apple only).
  • sd_native_carry_patch takes an optional TARGET (default stable-diffusion); target sources are matched as absolute paths.
  • tools/validate_artifacts.py: an iOS library must not import _posix_memalign. Unit case in tests/test_tools.py.
  • patches/README.md row, README mention. No CHANGELOG exists in this repo.

macOS is unchanged (already vm_allocate).

Validation

Check Result
python3 -m unittest discover -s tests 113 tests OK (18 skipped)
ios-arm64 build + validate_artifacts.py ok; library imports _vm_allocate/_vm_deallocate, not _posix_memalign; no object in the build imports _posix_memalign
macos-arm64 build + validate_artifacts.py ok
Mutation: drop ggml.c patch ios-arm64 fails: imports _posix_memalign
Mutation: drop metal patch ios-arm64 fails: imports _posix_memalign
Mutation: drop both (unpatched pin) ios-arm64 fails: imports _posix_memalign

CI proof: the build (ios-arm64), build (ios-arm64-sim) and build (ios-x64-sim) jobs each run the new rule (target os ios); it fails on the unpatched pin.

Device footprint evidence is a separate llamadart-side run. No release or tag in this PR.

…tform

iOS host buffers came from posix_memalign, whose freed pages libmalloc keeps in
the app footprint (llamadart#2004). The iOS artifact check now rejects a
_posix_memalign import.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant