Repository navigation
Conversation
- Updated `mlx-swift-lm` dependency to a specific revision to address issues with vision model compatibility. - Modified localization strings in `Localizable.xcstrings` to include new entries and improve clarity. - Adjusted notes in `LocalLLMService` to reflect changes in model capabilities and memory requirements. - Updated `Config` to clarify the status of local agent usage. - Refreshed `Package.resolved` and CI scripts to align with the new dependency versions.
…ities - Introduced `swift-jinja` package with version 2.4.2 to project dependencies. - Updated `LocalLLMService` to reflect that Gemma 4 models now support vision capabilities. - Adjusted related tests to confirm the vision capability of Gemma 4 models. - Enhanced model handling in `LocalLLMService` to ensure proper routing for vision tasks.
- Updated `LLMService` to conditionally skip tool instructions and adjust history management based on image data presence. - Refined `LocalLLMService` to differentiate between photo and text turns, optimizing system prompts and history handling for multimodal interactions. - Improved comments for clarity on the implications of multimodal processing and memory management.
…gement - Introduced `otherStreamConsumersActive()` method to determine if other features are using the camera stream. - Added `stopStreamUnlessShared()` method to manage camera streaming based on active features. - Updated `saveToPhotoLibrary` and `saveVideoToPhotos` methods to utilize `GlassesPhotoAlbum` for album management, removing redundant album fetching logic. - Cleaned up code by removing the now-unnecessary `fetchGlassesAlbum()` method from both `CameraService` and `VideoRecordingService`.
…ccess - Removed redundant photo library access descriptions from Info.plist. - Updated `CameraService` and `VideoRecordingService` to utilize the new `GlassesPhotoAlbum` methods for saving images and videos, simplifying the code and improving error handling. - Enhanced `GlassesPhotoAlbum` with dedicated methods for saving images and videos, ensuring proper authorization checks and album management. - Adjusted `DwellCaptureService` to use the new image saving method, improving code clarity and maintainability.
…aving logic - Added a new usage description for saving photos to a dedicated Glasses album in the photo library. - Refactored `GlassesPhotoAlbum` to improve authorization handling and streamline the image and video saving process. - Updated methods to ensure proper album management and access permissions, enhancing user experience and code clarity.
- Simplified the authorization handling in `GlassesPhotoAlbum` by removing unnecessary parameters and streamlining the `ensureCanSave` method. - Enhanced album management by introducing dedicated methods for fetching and creating albums, improving code clarity and maintainability. - Updated image and video saving methods to utilize the new album management logic, ensuring a more efficient and user-friendly experience.
straff2002
left a comment
There was a problem hiding this comment.
Thanks for this — the Gemma 4 work is right, and I checked it against the checkpoint rather
than taking it on faith: tokenizer_config.json really does define sot_token = "<|turn>" /
eot_token = "<turn|>" with eos_token = "<eos>", and chat_template.jinja emits a genuine
system turn. So the hand-render is faithful and extraEOSTokens: ["<turn|>"] is genuinely
required, not belt-and-braces. The revision: pin with the "no tag carries #390" comment is
exactly the note I want on a pin like that.
Two mechanical blockers before anything else: the PR is CONFLICTING against main, and the
green test run predates main's tip, so it isn't evidence about the merged tree. Main landed
CameraStreamClaims (claim-based camera stream ownership) a few hours after your last commit,
which is where the conflict comes from.
The main ask
Reading through, a lot of this is one of two things welded together: something that helps
every user, and a workaround for the device you tested on. I want the first half of each,
and I want the second half kept but conditional — not applied to everyone. Three places:
1. Photos. The double permission prompt was caused by CameraService and
VideoRecordingService each carrying their own copy of the album code. Consolidating into
GlassesPhotoAlbum is the actual fix, and it's a clean win — please keep it. Dropping to
add-only is a separate decision, and I think it costs everyone the Glasses album:
resolveAlbum() validates its cached identifier via PHAssetCollection.fetchAssetCollections,
which needs read access. Under add-only that fetch returns empty, so the cached ID is
discarded on every save, findAlbumByTitle() also returns nil, and createAlbum() runs again —
either a new empty "Glasses" album per photo, or no album at all. Could you check that on a
fresh install with add-only granted? If it reproduces, I'd rather keep requesting readWrite and
just request it once, in the one place you've now created.
2. Camera warmup. The lastStreamError early-abort is a real improvement for everyone — it
turns a 20 s hang into a fast fail, and it's the right read of that field log. But it also makes
the shortened timeout unnecessary: waitForStreaming(timeout: attempt == 1 ? 10 : 20) sits
below the cold-start window recorded in the comment three lines above it (~15–18 s of
.stopped/.waitingForDevice churn), so a healthy cold start now always fails attempt 1,
tears down, sleeps, and rebuilds. With your abort in place a dead start already fails fast on
its own, so healthy starts can keep the full 20 s. Your good idea removes the need for the other
one.
Same section: action(consecutiveFailures: attempt - 1) can only ever see 0, which is always
.rebuildStream — the resetSession() branch is dead.
3. Gemma memory pressure. Vision working is the universal win. Stripping history, tools and
the system prompt is a workaround for a device that's tight on RAM — but it's applied
unconditionally, so a 12 GB phone pays for an 8 GB phone's problem. There's already machinery
for this: LocalLLMService.marketingRAMGB / fitsDevice (used today only for the download
gate) and LocalModelBudget.promptBudget(for:). Routing the stripping through a RAM-aware
budget instead of hardcoding it would serve both devices.
Two specifics inside that one:
- The
sendLocalchange (imageData == nilon tools + history) is redundant for Gemma 4 —
generateGemma4VLMTurnalready empties both downstream — so the only model whose behaviour
actually changes is SmolVLM2, which doesn't have the unchunked-prefill problem. It's a
straight loss for those users. Gate it onGemma4ChatPrompt.matchesor drop it. generateGemma4VLMTurnhard-replaces the system prompt with an English literal on photo
turns, so persona and language are dropped for non-English wearers every time they ask about
a photo. If it stays, it should derive from the wearer's configured language and live next to
the other prompts inConfig.swift.
One question
What device did you test on? It decides a lot of the above. If you're on 8 GB running E2B,
the memory workarounds are real and should be tiered; if you're on 12 GB+ and stripped
defensively, they can probably just go. It also decides whether removing the "vision caveat"
from the model notes is honest for every user or only true on your handset.
Relatedly — could you confirm Qwen 2.5, SmolVLM2 and LFM2.5 still load on 14414441? That's
the pin's cost to users who'll never touch Gemma, and it's the one part of this that everybody
carries.
Would you split this?
The camera/Photos changes and the Gemma changes touch disjoint files. The Gemma half I'd merge
quickly once the above is settled; the camera half needs a rebase onto CameraStreamClaims
anyway. Two PRs would stop the good half waiting on the uncertain half.
On that rebase: AppState.otherStreamConsumersActive() / stopStreamUnlessShared() is a fourth
ad-hoc copy of the rule CameraStreamClaims was written to centralise, and it doesn't consult
cameraService.hasStreamClaims — so ending a turn would stop a stream continuous narration is
holding. Going through claimStream(for:) / releaseStream(for:) gets you the "don't stop what
you didn't start" behaviour for free. Also note stopStreamUnlessShared() is hooked into
returnToWakeWord(), which fires after every turn rather than at the end of a session — with
the 15–18 s cold start that's a full cold start per photo question, and it doesn't know about an
open Live Preview.
Smaller things
visionModelIds' doc comment says Gemma 4 text turns MUST go throughGemma4Processor.prepare,
butgenerateGemma4VLMTurnhand-buildsLMInputfor text and its own inline comment says the
opposite (nilsetBytes→ Metal assert). Same claim is now onLocalModelRoutingTests. One of
them will walk the next reader into a crash.ci_scripts/Package.resolveddowngrades a pile of unrelated transitive deps (asn1 1.7→1.6,
collections 1.5.1→1.4.1, crypto 4.5→4.3, nio 2.100→2.96, transformers 1.3.3→1.2.1) and drops
the.gitsuffix from the swift-transformers URL, which no longer matchesproject.base.yml—
Xcode Cloud may then ignore the pin entirely. Please regenerate with
Scripts/update-package-resolved.shrather than editing by hand.swift-jinjais added as a direct dependency but nothing imports it, andPackage.swift
wasn't updated to match. If the exact2.4.2pin is what fixes the template parse, say so in
the comment.- Please drop the
Localizable.xcstringschurn — 1,461 lines, no view files changed, so it's all
build extraction.CLAUDE.mdasks for catalog updates on their own commit. GlassesPhotoAlbumis the one genuinely pure, headless-testable piece here and has no tests.
ensureCanSavealso no longer accepts.limited, which the old code did.- Orphaned
/// Name of the Photos album where recordings are saved.left above
recordingTranscriptinVideoRecordingService. isJinjaParserFailurematchesString(describing:)substrings, and its test uses a hand-rolled
struct Fake: Errorrather than a real Jinja error — it can't catch a change in the real error
shape.
|
@straff2002 Ok I'll look into fixing those, I do use an Iphone 15 Pro Max so 8GB ram. |
…xtraction) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…nly, claim the warmup keepers Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Closing this out with thanks — everything of value here has now landed on Gemma — merged in 4b71b1f:
Photos + camera warmup — merged in 113bfe3:
Really appreciate the contribution — the Gemma template work in particular shipped essentially as written. Sorry the merge conflict made this the long way round. |
|
@straff2002 Awesome thanks for sorting it out the regressions! |
Fix Gemma 4 VLM load: KV-shared layers must not declare k_proj/v_proj ml-explore/mlx-swift-lm#390