Skip to content

[Fix] Fixing the multi-images error for llava-onevision - #1205

Merged
merrymercy merged 4 commits into
sgl-project:mainfrom
EvolvingLMMs-Lab:dev/fix_multi_images
Aug 25, 2024
Merged

merrymercy merged 4 commits into
sgl-project:mainfrom
EvolvingLMMs-Lab:dev/fix_multi_images

Conversation

@kcz358

@kcz358 kcz358 commented Aug 25, 2024

Copy link
Copy Markdown
Contributor

Motivation

This PR is to fix the image processing error in llava-onevision when encountering multi-images

Modifications

  • Add convert('RGB') when processing image_aspect_ratio=='pad'
  • Add a multi-image stream test in examples

Checklist

  • Format your code according to the Contributor Guide.
  • Add unit tests as outlined in the Contributor Guide.
  • Update documentation as needed, including docstrings or example tutorials.

@merrymercy
merrymercy enabled auto-merge (squash) August 25, 2024 17:13
@merrymercy
merrymercy disabled auto-merge August 25, 2024 17:27
@merrymercy
merrymercy merged commit 66e7dca into sgl-project:main Aug 25, 2024
timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 4, 2026
… question than their label

E1 -- THE STALE-GATE BUSY PROBE WAS A CONSTANT, and #861e's own stated
arithmetic was never in the tree. `_busy = bool(write_queue or load_queue or
ack_backup_queue)`: the first two are lists (cache_controller.py:716-717) and
are honestly falsy, but `ack_backup_queue` is a `queue.Queue`
(cache_controller.py:801) and `Queue` defines neither `__bool__` nor `__len__`,
so with storage enabled the chain ended on a constant True. The comment above
it says "count a zero-streak only while the controller reports device-tier work
in flight"; the only thing that shipped was the threshold 2 -> 4.

Repairing it to an honest depth alone would be WORSE, not better: the probe
runs one statement after `_quiesce_hicache` (phase_flip_runtime.py :11938 ->
:11949) with `hicache_seam_active` refusing new I/O, so a depth reading there
is ~always 0 and a depth-only gate is permanently silent -- the false all-clear
that let W37-C log checked=0 on eighteen flips with nobody woken. New
`controller_device_queue_depth` counts (qsize/len, None when unmeasured) and
new `stale_gate_zero_streak` takes the traffic term from the heartbeat's OWN
history: a process that has reached the gate once has proved it reachable, so
zeroes after that are a disconnection, not #861e's legitimate idle stretch.

E2 -- THE POOL CENSUS LABELS NAMED THE WRONG POPULATIONS, in both directions,
on the first line a post-mortem reads. `cur_slot_reqs` carried
`len(_live_reqs(scheduler))` -- the WIDE count across every slot, the opposite
of what the label says. `resident_reqs` summed `len(mb.reqs)` with no dedup
while `_live_reqs` dedups by `id()`, so one request resident in two slots
printed `cur_slot_reqs=1 resident_reqs=2`: a count of list entries, not of
requests. Now `live_reqs=` / `resident_slot_entries=`. The four docstring and
comment sites that quote the old labels are boot-log quotations and are kept
verbatim, each now marked as the PRE-FIX reading -- no shipped code emits them.

E3 -- SEAM-REFUSED WRITES HAD NO SENTINEL. `hicache_phase_guard` warns once per
direction per process by design, so from the second flip on the seam refusal is
invisible, and the fence tallies it together with the other six `write_backup`
zero-return paths as `refused_silently`. Added `_SEAM_REFUSALS` + `seam_refusals()`
/ `reset_seam_refusals()`, and `FlipWritebackReport.seam_refused` measured as a
delta across the fence run (-1 / `?` when unmeasured, never spelled 0).

RED FIRST, at parent 5a78890: E1 red as ImportError (the helpers did not
exist); E2/E3 red on a copy with the E1 imports stubbed -- 6 failed, 15
deselected, and the failure text printed the defect itself
("'live_reqs=1' not found in '... cur_slot_reqs=1 resident_reqs=2
resident_slots=[0, 1] ...'"). Green now: 21 passed in the new file.

MUTANTS -- five planted in scratch copies, all killed, four on the dangerous
(corrupt-rather-than-refuse) direction:
  M1 traffic term reduced to `bool(depth)` -> the false all-clear
     killed by test_a_workload_that_HAS_reached_the_gate_makes_zeroes_evidence
  M2 depth probe returns truthiness (the original sgl-project#1205 defect restored)
     killed by test_the_replacement_reports_zero_on_that_same_controller
     and test_it_sums_all_three_queues
  M3 seam counter moved inside the once-per-process `_WARNED` guard
     killed by test_every_seam_refusal_is_counted_not_just_the_first_logged_one
  M4 census log arguments swapped onto the other label
     killed by test_one_request_in_two_slots_prints_one_request_and_two_entries
  M5 unreadable heartbeat parsed as a measured (0, 0)
     killed by test_an_unreadable_heartbeat_is_not_a_zero

VERIFIED: sibling parity is exact. managers set 25 failed / 134 passed at
parent vs 25 failed / 155 passed here (+21 = the new file), IDENTICAL failure
name set (23 FAILED + 2 SUBFAILED, all pre-existing `_rank` / source-text
assertions). mem_cache set 4 failed / 200 passed on both sides, identical
names. ruff check clean; `ruff format --diff` over the two pre-existing
unformatted files yields byte-identical hunks (same md5, 8 hunks) at parent and
here, so no new format finding; the guard and the new test file are formatted.
The %-arity of every `logger.*` format call in phase_flip_runtime.py was
checked by AST (154 calls, 1 mismatch at :3441 which is a starred-arg false
positive of the checker and is pre-existing at HEAD).

NOT VERIFIED: no boot, no GPU, no metal. The seam-refusal sentinel's DELTA
wiring inside `flip_writeback` is exercised only through the report dataclass
and the guard counter, not through a real fence run -- the first boot that
reads `seam_refused=` is its execution proof. Anchor drift: every file:line in
the brief had moved (E1 :9071-9075 -> :9436-9448, E2 :6557 -> :6880,
quiesce :11553 -> :11938); all three claims were confirmed at the tree.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 4, 2026
…ee adversarial lenses found in the six cuts

WHAT WAS RED, and every finding was re-verified at the tree before it was
acted on. Two of the eleven reported were REFUTED and are named at the end.

1. sgl-project#1202 added `mbs` to the residency AUTHORITY and not to the retirer.
   `_live_reqs` walks `mbs`; `consume_retracted_from_live_universe` did not.
   That is the W30 asymmetry re-opened, and it is the W27 death: the release
   frees a request the authority then re-enumerates, and
   `resident_mamba_slots` (gdn_flip_mover.py:620) raises KvReshardError on a
   live request with no mamba slot -- inside the no-return region, where the
   only outcome is a dead rank. The mbs-only shape is ordinary, not exotic:
   under event_loop_pp a freshly planned prefill batch sits in `mbs[slot]`
   while `running_mbs[slot]` holds the decode set.
   RED: the property test "authority and retirer walk the same containers"
   reported authority-only = ['mbs']; the concrete test read
   "0 != 1 : the mbs route retired no reference".
   Pinned as a PROPERTY over the two walks, so the next route added cannot
   reintroduce it. The stale present-tense collateral at
   scheduler_pp_mixin.py:5121 ("_live_reqs does NOT enumerate mbs", dated
   2026-09-04) is rewritten as the dated fact it now is.

2. sgl-project#1203 A5 spent three ESCALATION budgets in the group's abandon currency.
   A5's premise is right and is kept: a rank-local counter that zeroes itself
   when this rank's own objection clears can never reach its limit while
   ranks take turns objecting. But `flip_host_headroom_verdict` and
   `flip_seam_budget_verdict` do not merely stop deferring at the limit --
   they return (allow=True, escalated=True), "PROCEEDING WITH EYES OPEN"
   under a failed sgl-project#721 host floor -- and the writeback arm proceeds with an
   incomplete sgl-project#703 fence. `_seam_abandons_in_a_row` is incremented on EVERY
   reduced-fit abandon or frame divergence, so three unrelated abandons
   disarmed all three guards and the next GENUINE shortfall escalated on its
   first firing, having deferred zero times. A bound may be widened to the
   group's currency; an escalation that permits the hazard may not.
   REPAIR: each guard is bounded by its own count again, and that count is
   refunded ONLY by a completed flip (beside the abandon book, whose own
   comment already states the rule) or by the guard's own escalation. The
   whole reset policy is `flip_defer_budget_after`, one pure function, so the
   three copies cannot drift again.
   RED: 8 of 10 A5 tests failed at the parent.
   Three instruments that named the wrong counter are corrected with it:
   "consecutive" becomes "in this abandon run", and the host-RAM defer is
   booked BEFORE its own log line instead of after.

3. sgl-project#1204's abstain discarded a term the rank had successfully read. Both
   reads shared one `try`, so a rank whose `backed_rows()` succeeded and whose
   `live_floor_rows()` then raised contributed `_UNBOUNDED_ROWS` in slot 0 --
   the MIN identity, i.e. "I am not the poorest". Slot 0's MIN becomes the
   level the peers cap to and the ceiling `book_deferred_grow` clamps to, so
   erasing a poor rank makes the group agree an id level it cannot map, which
   `backed_rows`' docstring calls a cudaErrorIllegalAddress that kills every
   rank. The hang the commit removed would have been traded for a wrong group
   answer -- the corrupting direction bought to avoid the refusing one.
   REPAIR: abstain PER SLOT. Each slot carries this rank's own measurement or
   that slot's neutral, unchanged for a wholly unreadable relief.
   RED: "30 != 1099511627776".

4. sgl-project#1205's `seam_refused` measured a population its label does not name --
   the sgl-project#1205 defect class, committed inside the sgl-project#1205 fix. The fence read
   `seam_refusals()` with NO direction, summing "load" refusals raised on the
   controller's own background threads while the fence runs, and printed the
   delta as "of refused_silently, the share the FLIP SEAM refused".
   REPAIR: `seam_refusals("write")`, and the log line and the field comment
   now say what it is: process-wide write-direction refusals during the fence,
   not a subset of `refused_silently` and not per-node (consume_gate refuses a
   whole queue and counts one).
   RED: "1 != 3" when the direction-less read is put back.

5. `assert_future_map_identity` was REACHED and CANNOT-FAIL. Measured: four
   combinations of (algo NONE|EAGLE) x (pool pp|tp), ZERO fires.
   `create_future_map` passes `self` as `spec_algo` and the scheduler's pool
   straight into `ConfidenceRelay`, so both stamp arms are construction
   invariants at a call site 57 lines after the rebuild; the two suite tests
   that are green hand-mutate a map no code path produces.
   REPAIR: the registry's obligation is "a probe proving the rebuild ran", so
   the probe now takes `previous` -- the map held BEFORE the rebuild -- and
   refuses when the rebuild did not replace it. A memoised build, a deleted
   assignment or a rebuild moved out of the cutover all land there and none of
   them are visible to the stamp arms. The tautology is pinned as a fact so
   the green is not read as coverage.

6. MambaRadixCache got the sgl-project#1201 assertion but not the sgl-project#1201 fix. It caches
   `req_to_token_pool` as a plain attribute and has no `bind_req_pool_owner`,
   so `_restamp_phase_handles`' hasattr guard skipped it and the handle stayed
   on the outgoing pool -- and `assert_req_pool_identity`, added to both
   classes, then raises ReqPoolRebindRefused at the END of every cutover.
   Reachable: registry.py hands back this class for a hybrid-SSM model WITHOUT
   hierarchical cache. The boot went from flipping wrongly to not flipping.
   REPAIR: the same owner property and bind hook UnifiedRadixCache got.

7. The sgl-project#1203 A1 group vote moved a non-pure function onto a new cadence.
   `seam_transport_premise_holds_locally` writes the edge-triggered
   `_seam_premise_refused_announced` latch and emits SEAM TRANSPORT REFUSED;
   the vote runs once per loop iteration while the consumer returns at
   `_active_phase != PHASE_TP` before it asks. The latch was therefore set in
   the PP phase, swallowing the gate's own first engagement in TP.
   REPAIR: `announce=False` for the vote; the gate's own read still announces.

Also: the anchor at overlap_utils.py:81-83 had drifted onto the line that
REFUTES its sentence -- scheduler.py:13174-13177 is now the overlap call
inside `if self.enable_overlap:`, while the non-overlap spec branch is the
sibling `elif not batch.spec_algorithm.is_none():` arm. The claim is true; the
number sent the next reader to the wrong branch. Named by branch, no number.

WHAT KILLED WHICH MUTANT (planted in place, restored by sha256):
  M1 retirer over-clears (frees a row a live req owns, the corrupting
     direction) -> test_an_mbs_only_resident_is_retired_by_the_retraction
  M2 host bound back on the group abandon book (disarms sgl-project#721)
     -> test_the_host_headroom_bound_reads_its_own_defer_count
  M3 a cleared vote refunds its own budget (the A5 wedge)
     -> test_this_rank_clearing_does_not_refund_the_budget
      + test_a_taking_turns_run_still_reaches_the_limit
  M4 refund moved back into the gate's cleared-vote branch
     -> test_a_completed_flip_returns_every_budget_beside_the_abandon_book
  M5 sgl-project#1204 discards a measured backing again (claims not-poorest, the
     fleet-death direction)
     -> test_a_readable_backing_reaches_the_group_min
  M6 MambaRadixCache loses the rebind hook
     -> test_both_classes_expose_the_rebind_hook
      + test_the_handle_follows_the_owner_and_falls_back_without_one
  M7 the seam stops handing the probe the outgoing map
     -> test_the_seam_hands_the_probe_the_outgoing_map
  M8 the A1 vote announces again
     -> test_the_vote_leaves_the_announcement_latch_alone
8 planted, 8 killed, 0 survived.

VERIFIED: 146 passed + 7 subtests over the six touched test files plus
test_1157_seam_witness.py and test_seam_census_double_905.py (the joint pin
over both sgl-project#1202 functions), hermetic, CUDA_VISIBLE_DEVICES="" with the serving
venv. Import smoke over all seven edited modules. ruff parity with the parent
on the touched files: 31 findings both sides, all pre-existing.

NOT VERIFIED: nothing on metal. No boot, no GPU claimed, no collective. The
sgl-project#1204 and A5 repairs are DESK-PROVEN only -- neither has run against a real
reduce or a real host-RAM shortfall.

REFUTED, and left untouched: (a) `assert_req_pool_identity`'s tree-cache arm
is not decorative -- it is a construction invariant for UnifiedRadixCache
BECAUSE the owner property is the fix there, and a live check for every other
holder class, which is exactly what caught finding 6; (b) `seam_refused` was
already read as a delta across the fence run (hicache_flip_writeback.py:700),
not as an absolute, so only its direction and its label were wrong.
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