Skip to content

[Feat] add llava-onevision, with support for (1) siglip encoder, (2) qwen2 decoder (3) openai api compatible server. - #1003

Closed
Luodian wants to merge 9 commits into
sgl-project:mainfrom
EvolvingLMMs-Lab:main
Closed

Luodian wants to merge 9 commits into
sgl-project:mainfrom
EvolvingLMMs-Lab:main

Conversation

@Luodian

@Luodian Luodian commented Aug 9, 2024

Copy link
Copy Markdown
Contributor

This is a working PR and I'm putting here to see the changes and welcome any suggestions.

Motivation

With this PR, we wish to add support for LLaVA-OneVision. A new model that accepts multi-type inputs, including single-image with anyres_max_N and multi-image, and video.

Modification

  1. add support for siglip
  2. add support for qwen2 (nothing change from previous llava-next).
  3. handle single-image with anyres_max_N (at max 729 * (N + 1) tokens) strategy, multi-image with base token strategy (729 tokens per image), video with bilinear interpolation token strategy (196 tokens per frame).
  4. add openai compatible server for launching a backend service for llava-onevision model. for above mentioned multi-type inputs, we all use the same interface as OpenAI's GPT format as the input format (the image-text can also be interleaved).

Checklist

  1. Ensure pre-commit pre-commit run --all-files or other linting tools are used to fix potential lint issues.
  2. Confirm that modifications are covered by complete unit tests. If not, please add more unit tests for correctness.
  3. Modify documentation as needed, such as docstrings or example tutorials.

@Luodian Luodian closed this Aug 9, 2024
chx96642264 pushed a commit to chx96642264/sglang that referenced this pull request Jul 14, 2026
Update test_npu_streaming_session.py
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 29, 2026
…sed as if it had one

Boot 54 reached six clean flips -- the collective correction in #1002d held --
and then died on PP0 at batch_result_processor.py:225, `result.copy_done` with
`result` None, four minutes in. PP1 logged "#968b REHOME-ON-DISPLACE ...
route=void-output-cross-slot" immediately before: the void consumed the slot
and the (batch, result) pair travelled on anyway with the result unset.

Same class as boot 52's `d2h_event` deref, and the lesson is the same one this
window keeps paying for: a void is a statement that the pass did not run, and
every consumer downstream has to learn that from the ABSENCE, not from a
half-built object handed on as if it were whole. Two consumers have now been
found this way, so the drop is named and counted rather than silent -- a drop
that stops being visible is the quiet token loss the whole window is chasing.

No result is fabricated. `_pp_make_skip_output_result` is deliberately not
reused: its zero placeholder is legitimate only for a chunk that really ran
and produced no token, which is not this case.

Also recorded, because it clears my own change of suspicion: the torch p2p
pair '0:2' that PP2 was building is NOT on the void route. The traceback runs
_pp_send_output_to_next_stage -> _pp_send_dict_to_next_stage ->
pp_group.send_tensor_dict -- the ordinary last-rank output wrap from rank 2
home to rank 0, the same wire the six good flips used. Whatever opens it
lazily there is a separate question and not this commit's.

Evidence: desk, executed. py_compile; the guard precedes every dereference in
the function and emits rid and batch size, so a non-zero count names the void
whose consumers were not all told. Belegstufe: DESK-BEWIESEN.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 29, 2026
…s run

The precondition guarding result processing asks only half its question:
`self.mbs[next_mb_id] is not None` says the slot HOLDS a batch, never that the
batch has RUN. On a PP=3 box carrying a single short request the two come
apart inside one iteration -- the slot is filled by this round's admission and
the result step for that same slot runs before any forward has happened, so
`next_batch_result` is still None and absence is consumed as a result.

Boot 68 measured it inside one second at 07:50:17: ADMIT on all three ranks
(rid 43452758, prefix_lens=0 fill_lens=3 out_lens=0), then sgl-project#1003 on PP0 AND
PP1, then sgl-project#1008 holding the request. No forward in between. And no void
anywhere -- 797/798/951/984 all zero -- so nothing had been cancelled; the
pass had simply not run yet.

That single gap produced the whole ladder this window has been climbing. The
prefill result is consumed as absent, so out_lens stays 0; with sgl-project#1008 in place
the request is then held for ever and the instance dies idle on the 120s ring
budget; without sgl-project#1008 it was decoded instead, which is exactly where the
DECODE-labelled 3-token extend, the [1]-vs-[3] graph copy and the
causal_conv1d_update bounds failure all came from.

Not a consumer guard: a slot's result exists only after its pass ran, and this
writes that precondition down where it is used. Nothing is dropped -- the
batch stays in the slot and is processed when its result lands. The counter is
bounded in output but cumulative in value, because "settles after the first
rounds" (the pipeline filling) and "grows with traffic" (passes not
completing) are different diagnoses.

Two corrections ride along. sgl-project#1003's own text blamed a void for the absent
result; boot 68 measured the entire void machinery at zero, so that
attribution was mine, wrong, and is retracted in the message itself -- the
instrument said more than it had measured, which is the class this window
keeps finding in other people's code. And a nested duplicate
`if d2h_event is not None:` left by an over-broad replacement in #1002d is
removed; it was harmless but it was noise at a line that matters.

Evidence: desk, executed. py_compile on both files; the precondition appears
once, no nested duplicate survives, and sgl-project#1003 no longer claims a void.
Belegstufe: DESK-BEWIESEN -- BOOT-BEWIESEN needs the probe to return tokens.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 2, 2026
…sed as if it had one

Boot 54 reached six clean flips -- the collective correction in #1002d held --
and then died on PP0 at batch_result_processor.py:225, `result.copy_done` with
`result` None, four minutes in. PP1 logged "#968b REHOME-ON-DISPLACE ...
route=void-output-cross-slot" immediately before: the void consumed the slot
and the (batch, result) pair travelled on anyway with the result unset.

Same class as boot 52's `d2h_event` deref, and the lesson is the same one this
window keeps paying for: a void is a statement that the pass did not run, and
every consumer downstream has to learn that from the ABSENCE, not from a
half-built object handed on as if it were whole. Two consumers have now been
found this way, so the drop is named and counted rather than silent -- a drop
that stops being visible is the quiet token loss the whole window is chasing.

No result is fabricated. `_pp_make_skip_output_result` is deliberately not
reused: its zero placeholder is legitimate only for a chunk that really ran
and produced no token, which is not this case.

Also recorded, because it clears my own change of suspicion: the torch p2p
pair '0:2' that PP2 was building is NOT on the void route. The traceback runs
_pp_send_output_to_next_stage -> _pp_send_dict_to_next_stage ->
pp_group.send_tensor_dict -- the ordinary last-rank output wrap from rank 2
home to rank 0, the same wire the six good flips used. Whatever opens it
lazily there is a separate question and not this commit's.

Evidence: desk, executed. py_compile; the guard precedes every dereference in
the function and emits rid and batch size, so a non-zero count names the void
whose consumers were not all told. Belegstufe: DESK-BEWIESEN.

(cherry picked from commit 9b06986)
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 2, 2026
User order 2026-08-29: the ring-commit and admission-congruence apparatus
exists only for the retired second HiCache implementation and is left out, not
rebuilt. The kill criterion agreed at boot 52 -- two further ring-family
deaths -- is met five times over: 53, 55, 56, 57, 58, 59, 68, 69, 70, 71, with
boot 58 flip-free, so the family was never the flip's (sgl-project#990).

And the last measurement says the same thing from the other side. Boot 71,
three py-spy stacks at one instant: PP0 and PP1 both blocked in
`_pp_commit_admission_send_work` waiting for their admission-decision send to
be taken, PP2 blocked in the output wrap 2->0 that PP0 would have taken next.
A closed three-arc send cycle in which every arc belongs to this apparatus.
Plain upstream PP has no admission-decision ring at all, which is why
upstream does not have this deadlock. De-cyclising it would have been an
eleventh fix to a mechanism with no remaining purpose.

So three things are gated off when enable_phase_flip is false, each at its
definition so no call site can slip past:
  * _pp_commit_admission_send_work -- the reap that PP0/PP1 died in
  * _pp_send_admission_decision    -- the send it reaps
  * the HiCacheCollectiveTimeout bound in _pp_commit_comm_work, which falls
    back to the raw `work.wait()` the code already documents as the escape
    hatch of SGLANG_HICACHE_COLLECTIVE_TIMEOUT_S.

Dropping the bound removes a deadline, not a guarantee: `bounded_wait` takes a
single torch Work handle and its label only names the parked thread -- it is
not a collective, which I had claimed earlier and retracted on reading the
function.

Also recorded, because the branch does not do what its name says: before this
commit strip/minimal-flip-hicache stripped NOTHING. Against its base it was
+58/-3 lines in three commits, two of them mine (#1002d, sgl-project#1003) plus a census
line, and `pp-ring-commit` stood untouched at scheduler_pp_mixin.py:7160.

Evidence: desk, executed. py_compile; three gates present, each behind the
same predicate. Belegstufe: DESK-BEWIESEN.
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