Repository navigation
Support nvidia/LocateAnything-3B - #28958
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
a2ae156 to
070b029
Compare
|
/tag-run-ci-label |
JustinTong0323
left a comment
There was a problem hiding this comment.
Native loading + forward verified end-to-end on a GB300 devbox (1×sm103): sglang resolves LocateAnythingForConditionalGeneration by architecture string with no transformers fallback, vision features route correctly (same prompt across 4 images → 4 distinct box coords, confirming MoonViT→mlp1→Qwen2 + <IMG_CONTEXT> embedding routing), all 4 grounding tasks finish=stop with no no-EOS runaway, 17 unit tests pass, and outputs align with the HF generation_mode='slow' reference (2/4 token-identical, 2/4 greedy argmax flips from trtllm_mha vs sdpa near-tie logits — backend numerical difference, not a correctness bug). Lint fixed (legacy docs/ row → docs_new/ + a hidden isort merge). Remaining findings below.
JustinTong0323
left a comment
There was a problem hiding this comment.
Re-reviewed at b396bc8b8c (after the review-feedback commit + black fix). The splitter image_grid_hws fallback is verified correct at runtime (real HF processor probe: pixel_values rows == sum(prod(hws)), so the feature_len guard passes and per-image split fires), and the projector/weight-loading matches the HF reference. Two new issues found by re-review (independently confirmed by codex) — both worth addressing before merge.
Add native support for nvidia/LocateAnything-3B, a visual grounding/detection model composed of a MoonViT vision encoder, an InternVL-style mlp1 projector, and a Qwen2 language-model backbone. The model emits structured grounding outputs such as <ref>label</ref><box>...</box> with coordinates normalized to [0, 1000], covering object detection, phrase grounding, scene-text detection, GUI grounding, and pointing. - Composite LocateAnythingConfig (MoonViT vision + Qwen2 text + grounding tokens) - LocateAnythingForConditionalGeneration reusing the existing MoonViT encoder and Qwen2 backbone, with an mlp1 projector (LayerNorm over the merged width) - Image processor expanding the chat template's <image-N> placeholders - Optional LocateAnythingBoxGrammarLogitProcessor that constrains decoding inside <box>...</box> to a valid none / point / bbox pattern - Unit tests for the config, projector shapes, and box-grammar logic - Docs entry under supported multimodal language models Closes sgl-project#27674
CI rejects legacy docs/ edits (migrated to docs_new/). Add the multimodal model row under docs_new/ and drop the legacy edit; merge the duplicated base_processor import in the processor so isort passes.
- Split bundled multi-image items per-image by recognizing `image_grid_hws` (MoonViT models) in get_new_expanded_mm_items, restoring per-image RadixAttention cache granularity and the chunked-prefill fast path. - Add LocateAnythingBoxGrammarLogitProcessor.build_sampling_params() so clients can wire custom_logit_processor + custom_params from the config token ids; document the opt-in/both-required contract in the docs row. - Soften the box-grammar comment to state the no-unclosed-box-in-prompt assumption explicitly (only output_ids are scanned). - Note unused ref_*/mlp_connector_layers config fields are kept for HF round-trip fidelity. - Add tests for the >4-coord, coord_end-boundary, missing-token-id, and build_sampling_params branches.
Fold build_sampling_params signature onto one line; CI black-jupyter failed on the prior review-feedback commit.
6f1ad6f to
f5c1cc2
Compare
… add splitter + forward-shape tests Address review feedback on the LocateAnything-3B port: - build_sampling_params: the docstring example spread both returned keys into sampling_params, but custom_logit_processor is a top-level GenerateReqInput field, not a SamplingParams field (SamplingParams is a strict msgspec.Struct, so the unknown kwarg raised TypeError). Rewrite the example to put custom_params inside sampling_params and pass custom_logit_processor as a top-level request field, mirroring the OpenAI to_sampling_params path. Note the --enable-custom-logit-processor server flag prerequisite. - get_new_expanded_mm_items: add a rank-2 guard before the per-image prod split. A flat 1-D grid (e.g. tensor([h, w]) with num_items==2) passed the length check but prod(dim=-1) collapsed it to a scalar and mis-split; now it falls back to the simple split instead. - Add test/registered/unit/managers/test_mm_utils_split.py: CPU-registered regression tests for the splitter covering image_grid_hws / image_grid_thw / numpy / tensor splits, missing-grid fallback, flat-1D rejection, and non-bundled passthrough. - Add forward-shape smoke tests for get_image_feature (CPU, MoonViT stubbed): pixel concat + projector wiring, multi-image ordering, numpy image_grid_hws coercion, and precomputed-embedding passthrough. The stub asserts on its inputs so a regression in the feature/grid wiring fails rather than passing on a fabricated shape. - Docs: state the --enable-custom-logit-processor prerequisite and the two-field split in the LocateAnything row.
f5c1cc2 to
82aa9dc
Compare
The 4 new TestGetImageFeatureWiring tests crashed at setup because _bare_model used __new__ (bypassing __init__), so _modules was never populated and the multi_modal_projector assignment raised AttributeError. Add nn.Module.__init__(model) after __new__.
|
/rerun-failed-ci |
Co-authored-by: Xinyuan Tong <[email protected]>
Co-authored-by: Xinyuan Tong <[email protected]>
Motivation
Add native support for
nvidia/LocateAnything-3B, requested in #27674. LocateAnything is a visual grounding / detection model that emits structured outputs such as<ref>label</ref><box><x1><y1><x2><y2></box>(coordinates normalized to[0, 1000]), covering object detection, phrase grounding, scene-text detection, GUI grounding, and pointing.The architecture is a MoonViT vision encoder + an InternVL-style
mlp1projector + a Qwen2 language-model backbone, so it reuses SGLang's existing MoonViT (kimi_vl_moonvit) and Qwen2 building blocks.Modifications
configs/locate_anything.py—LocateAnythingConfig, a composite ofMoonViTConfig(vision) +Qwen2Config(text) plus the grounding special-token ids. Registered inconfigs/__init__.py,utils/hf_transformers/common.py(_CONFIG_REGISTRY, keyed onmodel_type="locateanything"), and themultimodal_model_archslist inconfigs/model_config.py.models/locate_anything.py—LocateAnythingForConditionalGenerationreusingMoonVitPretrainedModelandQwen2ForCausalLM, withLocateAnythingMultiModalProjector(themlp1projector: LayerNorm over the merged widthhidden_size * merge_h * merge_w, then Linear → GELU → Linear). Includes weight remapping for the HF checkpoint prefixes and tied-embedding handling. Also adds an optionalLocateAnythingBoxGrammarLogitProcessorthat constrains decoding inside a<box>...</box>block to a validnone/ 2-coord point / 4-coord bbox pattern (opt-in viacustom_logit_processor).multimodal/processors/locate_anything.py—LocateAnythingImageProcessorthat splits the prompt on the chat template's<image-N>placeholders (which the HF processor expands into<img>+<IMG_CONTEXT>×N +</img>).Usage:
Clients should set
skip_special_tokens=falseso the<ref>/<box>grounding tokens survive in the output. The model's bundled chat template is used (do not override it).Accuracy Tests
Validated end-to-end on an NVIDIA L4 GPU (server loads,
/healthOK). Across the model's task suite, outputs are correct and non-degenerate, e.g.:Locate all the instances that matches the following description: remote control.<64><152><273><244>and<522><160><578><390>(two remotes)Locate a single instance that matches the following description: the cat on the right.<box><541><52><998><775></box>(right side)Point to: the remote control.…person</c>tv</c>chair.<ref>/<box>…description: elephant.(absent)<ref>elephant</ref><box>None</box>Unit tests:
17 passed(test/registered/unit/configs/test_locate_anything_config.py,test/registered/unit/models/test_locate_anything.py).Note: only the standard autoregressive decoding path is implemented. The model's HF-native
generation_mode="fast"/"hybrid"Parallel Box Decoding is not ported — it is a throughput optimization, not a correctness requirement.Speed Tests and Profiling
N/A — new model support; no changes to existing kernels or shared forward paths.
Checklist
Closes #27674
CI States
Latest PR Test (Base): ✅ Run #28312458017
Latest PR Test (Extra): 🚫 Run #28312985104