Skip to content

Require llama.swift 2.10549.0 and free the lazy bitmap for rejected video input - #222

Merged
mattt merged 1 commit into
mainfrom
llama-swift-floor
Sep 10, 2026
Merged

mattt merged 1 commit into
mainfrom
llama-swift-floor

Conversation

@mattt

@mattt mattt commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Two follow-ups to #213.

  • Package.swift still allowed llama.swift from 2.7484.0, but the four-argument mtmd_helper_bitmap_init_from_buf that returns mtmd_helper_bitmap_wrapper first appears in llama.cpp b10549 (b7484 has the three-argument form returning mtmd_bitmap *). A consumer resolving an older 2.x with the Llama trait would fail to compile, so the floor moves to 2.10549.0, which Package.resolved already pins.
  • When the helper decodes a buffer as video, it returns a lazily initialized bitmap alongside the video context. The rejected-video path freed only the context, so the bitmap leaked. Free both before throwing.

…ideo input

The four-argument mtmd_helper_bitmap_init_from_buf that returns
mtmd_helper_bitmap_wrapper first appears in llama.cpp b10549,
so older 2.x releases of llama.swift can no longer build the Llama trait.
When the helper decodes a buffer as video,
it returns a lazily initialized bitmap alongside the video context;
free both before rejecting the input.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The dependency floor change matches the pinned resolved version and the added bitmap free cleanly addresses a confirmed leak in the rejected-video path without altering other control flow.

Pull request overview

This PR tightens the minimum supported llama.swift version to match the required mtmd helper API and fixes a resource leak when video input is detected but rejected, ensuring proper cleanup in the Llama mtmd integration.

Changes:

  • Raise the llama.swift dependency floor to 2.10549.0 to ensure the expected mtmd_helper_bitmap_init_from_buf wrapper signature is available.
  • Free the lazily-initialized bitmap when the decoded input turns out to be video and the code throws unsupportedFeature, preventing a bitmap leak.
File summaries
File Description
Sources/AnyLanguageModel/Models/LlamaLanguageModel.swift Frees wrapper.bitmap before freeing the video context and throwing on rejected video input.
Package.swift Updates the minimum llama.swift version to 2.10549.0 to match the required mtmd helper API surface.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mattt
mattt merged commit 7954aee into main Sep 10, 2026
12 checks passed
@mattt
mattt deleted the llama-swift-floor branch September 10, 2026 14:00
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.

2 participants