feat(flutter): 0.9.0 iOS, macOS, and Android support - #110
Conversation
…nistic dispose & context shift support Consolidate mobile & Apple ecosystem enhancements for llama_cpp_dart 0.9.0 release: - Platform Support: Declare Flutter ffiPlugin support for iOS and macOS in pubspec.yaml and ios/llama_cpp_dart.podspec. - Apple XCFramework: Build script fixes for self-contained dynamic Llama.xcframework (universal simulator arm64+x86_64, universal macos arm64+x86_64, executable name fix, bundle id normalization). - Mobile-First API: Added ContextParams.mobile preset, estimateVramBytes(), model.isDisposed, and engine worker chat cancel. - Resource Safety: Deterministic C++ VRAM teardown for model, context, and multimodal instances on isolate shutdown. - Reasoning Models: Exposed ContextShiftPolicy in EngineChat.generate() for auto context sliding on reasoning/thinking models.
|
Thanks @sebasbad could you review the latest release (0.9.0-dev.12) and check whether it covers the features you requested? Note the packaging landed differently from your PR: Android libraries are bundled through a native-assets build hook rather than checked-in jniLibs/ + Gradle, and Apple uses a SwiftPM manifest rather than a vendored podspec (I've opted out of CocoaPods). The API additions, ContextParams.mobile, estimateVramBytes(), isDisposed, chat-level shiftPolicy/shift, and deterministic native teardown are all in Let me know if anything else is needed |
|
Thanks @netdur! I tested upgrading to One quick note: Would it be possible to adjust the SDK lower bound constraint in |
|
Thanks @netdur! We upgraded our local toolchain to Flutter stable / Dart 3.12.2 to support the native-assets prerelease. Testing integration now. |
|
Closing in favor of draft PR #111. Context: We synced with |
Summary
Consolidates all fixes and enhancements required for seamless mobile & desktop (iOS, macOS, and Android NDK) integration, resource safety, and long-reasoning model support in
llama_cpp_dart0.9.0 into a single unified pull request.Key Changes
1. Platform & Plugin Declarations (
pubspec.yaml,ios/llama_cpp_dart.podspec,android/build.gradle)ffiPluginplatform configuration forios,macos, andandroid.Llama.xcframeworkwith module definitions and pod target xcconfigs.android/build.gradle,android/src/main/AndroidManifest.xml) with AGP 8.0+ namespace resolution fallback.2. Native C++ Binaries & Toolchains (
android/src/main/jniLibs/,tool/build_apple_xcframework.sh)arm64-v8a&x86_64for emulators):libllama.so,libggml-base.so,libggml-cpu.so,libmtmd.so,libggml.so) using Android NDK toolchain (API level 26 / Oreo floor).llvm-stripto keep binary footprint lightweight.Llama.xcframeworkwith universal iOS simulator (arm64+x86_64) and universal macOS (arm64+x86_64) slices.Llama.framework/Llama) andCFBundleIdentifierformat.3. Mobile-First API Extensions (
lib/src/)ContextParams.mobilepreset tuned for memory constraints on mobile devices.estimateVramBytes()helper toLlamaModel.isDisposedflag for status checks.EngineChat.4. Deterministic C++ VRAM Teardown (
lib/src/isolate/)LlamaModel,LlamaContext,MultiModalInstance) to prevent memory/VRAM leaks.5. Context Shift Support for Reasoning Models (
lib/src/isolate/)shiftPolicyandshiftnamed parameters inEngineChat.generate()andGenerateChatCommand, enabling opt-in auto context sliding for models with high token output.6. Documentation (
example/README.md)engine_stream.dart,chat_two_turn.dart,version_info.dart).Verification & Testing
example/probes/engine_stream.dartandexample/probes/chat_two_turn.dartusing Qwen2.5-0.5B model; verified multi-turn conversation memory, Jinja template rendering, token streaming, and clean VRAM deallocation.