mtmd: add NVIDIA LocateAnything-3B vision support#24749
Draft
sfallah wants to merge 2 commits into
Draft
Conversation
1ad84e5 to
5adaaaa
Compare
- MoonViT-SO-400M encoder (same as Kimi-K2.5) + Eagle MLP connector + Qwen2.5-3B text - locateanything graph reuses the Kimi-K2.5 path; only the connector LayerNorm differs (merged 4608-dim) - text auto-routes to Qwen2, no src/ changes
- HF rounds the resize up to a multiple of patch*merge; the shared preprocessor rounds to nearest - add opt-in image_resize_round_up flag (default off), set for LocateAnything
5adaaaa to
f8c60ee
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds support for NVIDIA LocateAnything-3B,
a visual grounding / detection VLM.
This PR covers the model itself (autoregressive decode). Its Parallel Box Decoding ("fast mode")
will come in a follow-up PR.
What it reuses
clip_graph_locateanythingsubclassesclip_graph_kimik25and only overridesbuild().LayerNorm(4608) → Linear → GELU → Linear) on the sharedmm_projectortensors. The LayerNorm runs over the merged 4608-dim feature (the one diff from Kimi-K2.5).Qwen2Model. Nosrc/changes.What's new
PROJECTOR_TYPE_LOCATEANYTHINGand its graph.conversion/locateanything.py: renamesvision_model.tovision_tower., maps theEagle MLP to
mm_projector.*, permutes the fusedwqkvto split Q/K, writes the pixel budgetfrom
in_token_limit.image_resize_round_uphparam (off by default, set only here): the HF processor rounds theresize up to a multiple of
patch*merge, butcalc_size_preserved_ratiorounds to nearest,which squished images and caused repeated-box loops.
Converting and running
Output is
<box><x1><y1><x2><y2></box>, or<box><x><y></box>for a point, or<box>None</box>for no match. Coordinates are control tokens
<0>..<1000>; convert to pixels withpx = coord / 1000 * image_dim.Testing
I compared the output against the HF reference (CPU sdpa, bf16, greedy) on a few images covering
detection, no-match, point, and natural-image detection. The boxes match token-for-token, apart
from a couple of coordinate tokens off by 1-2px on small boxes, which is bf16 backend noise.
License
The weights use NVIDIA's non-commercial license. The code here is MIT like the rest of llama.cpp.
Requirements