Docs

Mobile

Android and iOS use the phone preset through the C API. Success is peak RSS and the process staying up.

Preset

About 2 GiB, one staging buffer, 4 threads, KV window 512 plus 4 sink tokens. The budget is then half of what the OS can still give this process. Details and the laptop rule are on Memory.

OSFree RAM
WindowsGlobalMemoryStatusEx
Linux / Android/proc/meminfo MemAvailable
iOSos_proc_available_memory()
macOSfree + inactive pages

GPU

iOS Metal runs MatMul. Android Vulkan runs mapped f32 MatMul, including transpose_b. Attention and RoPE stay on CPU. Q4_K stays in the CPU quant GEMM, which uses NEON on arm64. The sample selects the backend with auto.

C API

uaii_memory_preset_info info;
memset(&info, 0, sizeof info);
info.struct_size = sizeof info;
uaii_resolve_memory_preset("phone", 0, &info);

uaii_session_options opts;
uaii_session_options_init(&opts);
uaii_session_options_apply_preset(&opts, &info);
opts.backend = "auto";

uaii_session_set_background(session, 1) makes generate and run return paused: app backgrounded. uaii_session_request_cancel returns cancelled. Generate clears cancel when it starts. uaii_session_memory_warning drops KV and keeps the longrope scale length. Callers built against 0.3.0 keep working: new fields are appended.

Android

cmake -S examples/mobile -B build-android -G Ninja \
  -DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK/build/cmake/android.toolchain.cmake" \
  -DANDROID_ABI=arm64-v8a \
  -DANDROID_PLATFORM=android-24 \
  -DANDROID_STL=c++_static \
  -DCMAKE_BUILD_TYPE=Release
cmake --build build-android --target uaii_phone

Ship libuaii_capi.so next to the binary. uaii_phone with no arguments prints the resolved budget. uaii_phone model.q4_k.gguf generates a few tokens from ids 1, 2, 3.

iOS

cmake -S examples/mobile -B build-ios -G Xcode \
  -DCMAKE_SYSTEM_NAME=iOS \
  -DCMAKE_OSX_ARCHITECTURES=arm64 \
  -DCMAKE_OSX_DEPLOYMENT_TARGET=15.0 \
  -DCMAKE_BUILD_TYPE=Release

Embed libuaii_capi.dylib. On device, uaii doctor prints platform: ios or platform: android.