Skip to content

Fix addr reuse in check_port - #253

Merged
hnyls2002 merged 1 commit into
mainfrom
socket-fix
Mar 3, 2024
Merged

hnyls2002 merged 1 commit into
mainfrom
socket-fix

Conversation

@hnyls2002

Copy link
Copy Markdown
Collaborator

What does this PR do?

After a socket is closed, it comes into TIME_WAIT status and refuses other socket listeners to bind it. TIME_WAIT normally lasts 30s and causes troubles when we want to fix the HTTP server port between frequently shutdown/starting SRT.

Add a SO_REUSEADDR option when checking the port to fix this, which allows binding to a just-released port with the same address.

@hnyls2002 hnyls2002 changed the title Fix reuse_addr in Fix addr reuse in check_port Mar 3, 2024
@hnyls2002
hnyls2002 merged commit dfb13ac into main Mar 3, 2024
@hnyls2002
hnyls2002 deleted the socket-fix branch March 3, 2024 09:09
timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
vschandramourya pushed a commit to vschandramourya/sglang that referenced this pull request Feb 3, 2026
liuxianglong17 pushed a commit to shun8686/sglang that referenced this pull request Apr 7, 2026
IzacharyI pushed a commit to IzacharyI/sglang that referenced this pull request Apr 21, 2026
Refresh the MI308 Qwen3.5 workflow defaults, keep GSM8K on the non-thinking CI path, and add nested benchmark model aliases so the nightly external load tests can resolve their hard-coded tokenizer directories.
rucnyz added a commit to rucnyz/sglang that referenced this pull request Jun 18, 2026
…contained in-engine package + do-no-harm fixes

Move all aginfer logic out of the two large upstream files into a self-contained
python/sglang/srt/mem_cache/aginfer/ package, leaving only thin delegators/hooks.

- cache_policy.py / cache_hooks.py / metrics_hooks.py: the pluggable eviction
  scorer + write-through resolution, hint table, apply_aginfer_migrations, and the
  scheduler EMA/throughput hooks, as free functions over cache/sched.
- unified_radix_cache.py (-790) / scheduler.py (-296) now carry only thin (*a,**k)
  delegators + re-import hooks + callsites + session_ids tags.
- The 14 daemon-policy modules (joint_decide/program_tracker/eta_estimator/...)
  moved from dev/aginfer into the package; the old dev paths are sys.modules shims.

do-no-harm fixes surfaced by a 4-round adversarial review:
- sgl-project#253: full_component eviction now honors --radix-eviction-policy on the default
  path (was hardwired LRU via the value-scorer default); lru + value-aware paths are
  byte-identical no-ops. New gate verify/radix_eviction_policy (12/12).
- restored the orphaned _AGINFER_VALID_STATES class attribute (was swept to module
  scope by the migrate extraction); fixed the _fatal.py forensic data-dir path after
  the move; deduped the T5 webhook block; trimmed dead re-imports + a dead import os;
  added from __future__ import annotations / TYPE_CHECKING to the split-out modules.

Also folds in the value-aware SWA eviction + reuse-based p_hat WIP (sgl-project#248/sgl-project#249).

Default path (no aginfer env, no daemon) is byte-for-byte stock sglang. Green:
radix_eviction_policy t21 t26 t27 t28 t38 s2_holder_scorer kv_scheduler_value_rule
joint_decide program_tracker admission_controller; full `import scheduler` (no
circular import). Experiment logs/results (36G) intentionally excluded.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…de a solved phase layout

Builds the piece the remainder determination (af2b34e) rescoped: solve the
layout ONCE per phase and say where each family lands inside it. The runtime
per-family flip stays closed -- it needs ~17,500 rounds to repay a whole-arena
refill -- but placement inside a flip that is already happening is free.

## No second solver, which was the acceptance condition

planner/boot_layout.py does not search, price or re-derive anything. It
consumes a PPCutSolution that solve_pp_cut already produced and re-presents it
per family. A test pins that the module's source contains no call to
solve_pp_cut and no _price_stage, so the cut can only change if the SOLVER
changed.

The composition was cheap because the solver already carried the family axis:
PPCutSolution.attention_counts is a per-stage family placement in all but name,
and layer_families tags every layer. What was missing was a named shape, the
other families, and one authority for the emitted flags.

## One authority for the printed remedy

server_args already computes the paste-ready --pp-attn-stage-ratio when a
snapped cut needs announcing (sgl-project#713, 88a0d78): "the full-attention counts of
the operator's own requested ranges ARE the --pp-attn-stage-ratio that realizes
them". The chooser emits that SAME quantity from the SAME field
(solution.attention_counts), so the printed remedy and the solved layout cannot
drift. --pp-layer-ratio comes from as_layer_ratio() VERBATIM; a test pins it
byte-identical, and the mutation that re-derives it as an even split turns
exactly that pin red.

## The enumeration gap: closed where funded, NAMED where not (sgl-project#253)

PPCutInputs carries measured terms for exactly TWO families -- attention
(attn_layer_weight_bytes, attn_layer_flops_per_token,
attn_core_flops_per_token_pair) and linear (linear_layer_weight_bytes,
linear_layer_flops_per_token). Both are now emitted as placements.

Every other family in the sgl-project#485 law has NO input in this cost model, so none got
one invented. UNFUNDED_FAMILIES records each with the measurement that would
fund it, in the module that omits them rather than in a doc:

  kv_heads              not a PP-layer family at all -- a TP-axis quantity, so
                        per-STAGE placement is the wrong shape
  vocab                 embed/lm_head are not per-layer, so layer_families
                        never tags them; needs measured bytes AND stage affinity
  experts               no MoE family in this checkpoint's layer_types
  nonlinear_kernels     folded into per-family layer FLOPs; needs a decomposed
                        measurement
  linear_per_quant_lane linear_layer_weight_bytes is ONE scalar for the family;
                        needs per-lane bytes measured from the checkpoint

A test asserts every entry names a measurement, and another asserts no
speculative term (expert_layer_weight_bytes, vocab_weight_bytes, ...) appears
in the source.

## ABSENT is not ZERO (sgl-project#606)

Families are derived from layer_families, so a family the checkpoint lacks
produces no entry -- and asking for it RAISES with that reason rather than
returning a zero vector. The mutation that pre-seeds both families (zero-filling
a model that has only one) turns exactly that pin red.

## Refusals

An INFEASIBLE solution emits no flags at all ("do not paste this layout") --
flags for a cut the solver already rejected are how an operator pastes a boot
that cannot come up. A layer_families vector that does not match the cut's depth
is refused as describing a different model. The phase is NAMED
(PHASE_PP_PREFILL), not assumed: sgl-project#485's matrix has a decode column and this
solver does not solve it.

## Tests

test/registered/unit/planner/test_boot_layout_485.py -- 18, driven by the REAL
solver through the existing sgl-project#485 fixture rather than a stand-in, because a stub
would let chooser and solver drift (sgl-project#624).

  mutations, one per contract:
    zero-fill absent families              -> 1 red (the sgl-project#606 pin)
    re-derive the layer ratio as an even split -> 1 red (the byte-identity pin)
    restored                               -> 18 passed

  test/registered/unit/planner: 2 failed / 2529 passed. Both failures are
  PpWithSpecEvidenceTest, the stale-register drift I diagnosed and fixed in
  54ffc4d, which has not reached this base -- pre-existing and unrelated,
  and a merge-train item.

A vacuous assertion of my own, caught by re-reading rather than by a failure:
the gap-funding test asserted `assertIn("Would need", why + "would need")`,
concatenating the needle onto the haystack so it could never fail. Fixed to
check the actual value.
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.

1 participant