Skip to content

Fix vertexai - #633

Merged
Ying1123 merged 1 commit into
mainfrom
fix-vertexai
Jul 16, 2024
Merged

Ying1123 merged 1 commit into
mainfrom
fix-vertexai

Conversation

@hnyls2002

Copy link
Copy Markdown
Collaborator

The main branch break after #624. The package vertexai is not installed by default. Should we just remove the type hint or make vertexai a dependency? @merrymercy @AidanCooper

@Ying1123
Ying1123 merged commit 5ff60ed into main Jul 16, 2024
@hnyls2002
hnyls2002 deleted the fix-vertexai branch July 16, 2024 23:07
@AidanCooper

Copy link
Copy Markdown
Contributor

Dropping the type hint makes sense — thanks for catching this.

timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
efschu added a commit to efschu/htsglang that referenced this pull request Aug 7, 2026
…adlock fix (forward-first in all three PP loops)
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…e pipeline's dependency chain

THE DEADLOCK. `_count_ready_acks` MIN-reduced a ready count across the group,
and that reduction sat inside `check_hicache_events` ->
`_get_new_batch_prefill_raw` -- the PER-MICROBATCH path of a pipeline, whose
stages are at DIFFERENT offsets by construction. Measured 2026-08-17: PP0/PP1
inside the drain while PP2 was blocked in `_pp_recv_proxy_tensors`, waiting for
data PP1 would only send after leaving the collective PP1 could not leave
without PP2. A circular wait between adjacent stages -- the sgl-project#633 shape one level
up, with a collective in place of a handler.

The bug was PLACEMENT, not participation: every stage calls the function, just
never on the same tick.

WHAT THE REDUCTION PROVIDED, and where each part went:
* OP-SEQUENCE UNIFORMITY -- concerned the TP all_reduce, which ran only on
  pp_rank 0. With no reduction there is no op left to keep in sequence.
* THE EMPTY-QUEUE SENTINEL (sgl-project#581: one idle rank froze the drain on ALL ranks and
  `protected` ratcheted until the state pool died). Rank-local counting removes
  that failure mode BY CONSTRUCTION -- an idle rank cannot freeze a peer that no
  longer waits on it.
* THE THROTTLE. Pacing, not correctness, and the one thing genuinely lost.

CORRECTNESS IS OWNED BY THE MARKER, NOT BY ACK LOCKSTEP. The cross-rank hazard
was publishing a shared content key incomplete on some stage. sgl-project#706's
`PageCompleteness` bounds that per page: production is layer-sharded while
storage is token-sharded, so slots arrive from several PP stages and
`is_complete()` gates use. Ranks arbitrarily far apart therefore yield an
INCOMPLETE page -- a MISS, never wrong bytes. The docstring now says this so
nobody resurrects the collective for a service the marker owns.

THE THROTTLE IS FILED, NOT GUESSED. No backpressure bound is shipped: one chosen
without an operating point is another shipped-number-without-evidence (#505c).
Instead a rate-limited drain-depth line (per-rank ready/pending at drain) makes
the first real fast-rank host-pressure specimen attributable when it appears.

TESTS  test_rank_local_ack_drain_737.py, 8 passed, both arms:
  (i)  deadlock -- ranks answer independently and may differ; an idle stage
       cannot freeze a busy one; and a CAN-FAIL that stubs torch.distributed to
       raise on ANY access, so a future edit that reintroduces a group op here
       fails loudly. Mutation-proven: adding one torch.distributed reference
       turns it red.
  (ii) divergence -- through the REAL `PageCompleteness`: worst-order arrival
       (PP2, PP1, then PP0) stays a miss until every slot is marked; order and
       tick are irrelevant, only completeness; a fast rank racing ahead cannot
       complete a page alone; double-writing a slot is refused.

THREE PRE-EXISTING TESTS CORRECTED, both causes recorded rather than absorbed:
* two sgl-project#734 fallouts I had missed -- the timeout stubs raised INSTANTLY, which
  the new dead-peer discriminator rightly reads as transport failure rather than
  expiry. A real timeout raises AT its deadline, so the stubs now sleep the
  bound. That keeps both the discriminator and the tests' original intent.
* the sgl-project#581 throttle test asserted exactly the property this change withdraws. It
  is rewritten to the new contract -- a slow rank no longer holds the others,
  which is what sgl-project#581 actually needed -- with the withdrawal stated in the
  docstring, not silently deleted.

Also: the sgl-project#580 comment at scheduler.py:6253 now states its ACTUAL guarantee --
uniform entry WITHIN the function once a rank calls it, which says nothing about
all ranks calling it on the same tick. The ack collective leaned on it and
deadlocked; anything added there needing GROUP agreement needs a
pipeline-aligned point, not that one.

REGRESSION  mem_cache + managers: 19 failed / 3696 passed against a captured
baseline of 19 -- ZERO new failures. Ruff: unified_radix_cache clean,
scheduler.py 96 before and after (pre-existing).
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 20, 2026
…ion, not before the exchange

A boot reached serving, one admissible queued request was never served, and the
process died. The wedge detector reported "1 queued, 0 running, NO first token
for 340-370s and no prefill chunk either" and named its own gap in the same
line -- "no phase-policy corroboration seen -- the wedge class is broader than
that path". It was right: this is not an admission defect at all.

EVIDENCE OF RECORD. py-spy on the specimen (WEDGE_788_specimen.log:732/915/1083)
catches all three ranks in a circular wait:

  PP0, PP1  gloo waitSend   _pp_commit_comm_work (scheduler_pp_mixin.py:2465)
                            from _pp_forward_and_process_input_requests:1007
  PP2       gloo waitRecv   _pp_recv_typed_dict:2709
                            from _pp_recv_proxy_tensors:2803

The request chain was flushed at the TOP of the pass, before the rank had
posted anything else it owed its peers that iteration -- the proxy tensor-dict
send and the output-ring send both come later in _event_loop_pp_body. A
downstream whose progress needs one of those was therefore waiting on a rank
that was itself waiting on that downstream. The chain recv is posted only at
the top of a pass (:420) and nowhere else in the loop body, so a rank parked in
the proxy receive cannot drain the message its upstream is blocked flushing.

THE FIX IS ONE ADDITION. _pp_forward_and_process_input_requests is byte-identical
to before: it still commits send_req_work, then posts the async forward, then
runs process_input_requests. What is new is _pp_commit_pending_req_work, called
once per iteration from _event_loop_pp_body after the proxy isend and the output
commit and BEFORE the phase-flip round hook. By the time that loop returns to
the top-of-pass commit, the handle has already been waited on and cleared, so
the old call site is a no-op there -- and the two disaggregation loops (:618,
:765), which do not call the new method, keep their previous behaviour exactly.

Deleting rather than moving the old call site is deliberate on both counts: it
keeps the sgl-project#633 ordering contract literally intact (commit, then forward, then
process, with send_req_work holding this pass's handle on return -- pinned by
test_scheduler_pp_request_order_633), and it avoids a second staging slot. An
earlier shape of this fix did stage the send separately; it broke that contract
and left the two disagg loops overwriting a live P2PWork handle every pass.

Precedent: a7ff250 "[sgl-project#753] Flush the output sends after the exchange, not
before it" made the same move for the OUTPUT channel. This is that fix for the
REQUEST channel, ungated -- the hazard is not gapped-specific.

NEGATIVE FINDING, RECORDED RATHER THAN BURIED. A deterministic 3-process gloo
reproduction of the specimen deadlock was attempted and NOT achieved under a
faithful model of the loop. Two candidate mechanisms were tested and refuted:

  - Eager-send asymmetry. Hypothesis: an empty request list puts one 8-byte
    tensor on the wire and completes eagerly, so only a large first request can
    block. MEASURED FALSE: a 2-process probe with a 2.0s-delayed matching recv
    blocked for the full delay at every payload size from 8 B to 1 MiB in this
    build. No eager completion at any size.
  - Schedule asymmetry. A linear chain+proxy relay that flushes the old handle
    before dispatching the new one is deadlock-free by induction (each rank's
    flush needs only its immediate downstream one pass behind), and dozens of
    real 3-process runs across depths and offset combinations all completed.

So the reduced two-channel model cannot close a cycle. The production graph has
an edge that model lacks: the output ring closes last-rank -> rank 0
(_pp_send_recv_and_preprocess_output_tensors:3038, last-rank branch :3012-3014,
via next_first_rank_mb_id at :416/:608/:754). That, and real GPU compute skew,
are the two named unconfirmed candidates for the missing ingredient. Neither is
built into the test, and the gap is stated in its docstring rather than papered
over. The mechanism's evidence of record therefore remains the py-spy trace
above plus the sgl-project#753 precedent, and the survival boot is the integration proof.

RECOVERY RUNG. The detector gains one bounded action: after a wedge stays
continuously alarming past a threshold well above the report threshold (default
3x, env SGLANG_ADMISSION_WEDGE_RECOVERY_SECONDS; non-positive values fall back
to the default rather than firing every poll), it makes ONE forced-admission
attempt per episode through the existing corridor_admission actuator and logs it
loudly either way. Its own docstring is explicit that it relieves VRAM pressure
at the admission site and will NOT move a comms deadlock like this one, and that
calling an actuator from the watchdog thread is a new cross-thread shape over
CUDA allocator state.

TESTS
  test_pp_chain_flush_deadlock_788.py (new; 3 real gloo processes, CPU only)
    - load-bearing: runtime ordering pin. The SHIPPED _pp_commit_pending_req_work
      is wrapped and the observed sequence asserted to be
      proxy_send -> chain_flush -> round_hook for every pass and every non-last
      rank, so the flush cannot drift back past the collective and cost it the
      "last blocking op of the iteration" property its own comment relies on.
    - can-fail: the same run with the flush relocated to the top records a
      different sequence, so the pin discriminates placement.
    - the honest negative case described above, in place of the deleted
      hang-repro. A test that is green or red for the wrong reason is worse
      than no test.
  test_pp_flip_leftover_proxy_757.py: harness-only repair, no assertion touched.
    It was silently DEAD on this branch -- its _GlooWire predated
    rank_in_group/world_size and the src positional recv_typed_tensor_dict now
    passes, so it errored 3/3 before reaching an assertion. Now 3 passed and a
    working regression check again.

  Verified green with this diff: test_pp_chain_flush_deadlock_788 and
  test_scheduler_pp_request_order_633 (8 passed), test_phase_policy (90 passed),
  test_pp_flip_leftover_proxy_757 (3 passed).

PRE-EXISTING FAILURES, MEASURED NOT ASSUMED. The managers slice reads 43F/2707P
here against 39F/2705P at a pristine detached ff5651a worktree. Every delta
is accounted for: -3 (the 757 repair above now passes), +5 stub drift and +1
ordering-contract break, both introduced by the earlier staging-slot shape and
both gone with it, +1 test_pp_drain_completeness_787 which is INTENTIONALLY RED
here -- that file's fix lives on fix/787-drain-completeness and it flips green
at the merge, which makes it a free integration can-fail. The residual 39 are
the same interface-drift family (rank_in_group, _pp_gapped_wire) plus one stale
constant, all present at base with no part of this diff.

DEBTS
  sgl-project#789                the two disaggregation PP loops keep the top-of-pass
                      flush and therefore still carry this hazard
  sgl-project#757-harness-drift  repaired here; the same drift still blinds
                      test_pp_proxy_stamp_631 and test_pp_slot_last_batch_631
  sgl-project#753-stale-constant 10.923 != 11.923 in the gapped entry protocol test
  sgl-project#766-pointer-stale  the register points sgl-project#766 at ARM_defaultfull7.log, which
                      is a 26-line host-ledger snapshot with no
                      Bar1CollectiveAborted and no proxy/drain lines
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.

3 participants