Skip to content

perf: reduce ttft and itl with stream_interval 1 - #658

Merged
Ying1123 merged 1 commit into
sgl-project:mainfrom
zhyncs:interval
Jul 19, 2024
Merged

Ying1123 merged 1 commit into
sgl-project:mainfrom
zhyncs:interval

Conversation

@zhyncs

@zhyncs zhyncs commented Jul 19, 2024

Copy link
Copy Markdown
Contributor

Motivation

as titled cc @merrymercy @Ying1123 @hnyls2002

Modification

as titled

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.

@Ying1123
Ying1123 merged commit ac971ff into sgl-project:main Jul 19, 2024
@zhyncs
zhyncs deleted the interval branch July 19, 2024 16:17
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 Aug 11, 2026
…cut is pressure

Register C18 recorded two floor models that had never met: the sgl-project#330 dial
derives its own card-level floor (NVML used minus VMM-backed KV) and spends
budget - floor on KV, with no reference to CorridorGuard or law_floor_bytes.
Inert only because --enable-vram-dial is absent from the ship config.

Two joins, both minimal:

1. THE LAW IS A TERM IN THE DIAL'S FLOOR (C18). corridor_law_floor_bytes()
   imports DEFAULT_FLOOR_MIB from the guard rather than restating 1024, and
   _measure_local_floor_bytes adds it. Every consumer -- unit cap, budget
   rows, minimum viable budget, effective ceiling, the below-floor refusal --
   inherits the reserve without knowing it exists. The boot state is
   bit-identical: the natural budget is floor + backed, so raising the floor
   raises the natural budget by the same amount and budget - floor does not
   move. The term bites only on an ABSOLUTE budget, which is exactly when an
   external tenant is taking bytes off the card.

2. A BUDGET REDUCTION IS CORRIDOR PRESSURE. The dial's own answer to a lowered
   budget was to arm a KV capacity cut that flushes the radix cache and
   commits only at a fully-idle group boundary -- no bounded-latency relief
   under load, and "a smaller pool as the fix" as the FIRST resort.
   apply_budget_request now spends the guard's relief ladder for the
   reduction first (local cache -> park -> host; the REBALANCE tier is empty
   by standing verdict), and leaves the residual to the capacity arithmetic.
   ensure_headroom is the exact equivalent: a reduction of D bytes is someone
   else taking D bytes of this card. refusal_is_fatal stays FALSE -- unlike
   the pp->tp leg this caller has a survivable path, so it may not force host
   RAM onto an unlevel fleet.

Not N39's trap: the decision arrives already replicated (the dial request is
broadcast and every rank computes identical budgets), nothing runs on a
rank-local clock, and what the ladder spends is rank-local PAYLOAD, never
replicated scheduler state. The KV pool still changes only through the
existing MIN-reduced consensus boundary.

The hook is injected (relief_fn) like commit_fn and ledger_report_fn, so the
runtime stays a pure-math object; None is supported and a raising ladder is
swallowed -- an external tenant asking for its own memory must never fail on
an optimisation.

TESTS: test_vram_dial_corridor_658.py, 8 new, red first (import error, then
the ladder assertion). Can-fail proven: disabling the hook fails exactly
test_a_reduction_asks_the_relief_ladder_first and nothing else. Existing
suites green: test_vram_dial + test_corridor_guard_631 + test_corridor_
admission_631 + test_kv_vmm_dial = 96 passed. ruff clean.

Metal not yet run: the dial has never booted on the ship recipe.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 11, 2026
…wo register entries

Three boot-harness defects, each of which cost or would have cost a boot:

1. ARGV_SET could not express a BARE flag. put(flag, "") appended
   ["--flag", ""], handing argparse an empty POSITIONAL. Every store_true
   option (--enable-vram-dial, --enable-dynamic-chunking) was unreachable
   through the capture path, and it fails in a way that reads like a config
   error rather than a quoting one.

2. THE SOURCE MAY NOT BE THE SINK. s33_boot_from_capture.sh writes the
   prepared argv to /tmp/s33_argv.txt, and callers pointed ARGV_SRC at that
   same file, so each boot inherited the previous boot's edits. A failed
   sgl-project#658 attempt left --enable-vram-dial in the file; the next boot, which
   had deliberately dropped the flag, picked it up again and died with the
   identical error -- which reads as "my edit did nothing", not "my source
   is poisoned". Now refused loudly with the fix in the message.

3. s40_window.sh therefore boots from a pristine copy, and its flags are
   settable (S40_ARGV_SET) rather than baked.

Also: s40_extract.sh (the window's verdict greps -- the server log is never
cat'd) and s40_budget_cycle.py (an EXTERNAL tenant driving POST /vram_budget
down and back up; it imports no sglang symbol, because a probe that reached
inside would prove the mechanism to itself).

REGISTER: C18 marked resolved (the corridor law is now a term in the dial's
floor). C23 opened -- two independent drivers of pool.runtime_set_backing_rows
(KvBackingRelief from the law at the seam behind a MAX reduction;
KvCapacityRuntime from the budget vector at a fully-idle boundary behind a MIN
reduction) which have never run together under load. Law 13 added: name the
LATENCY class of a relief mechanism before calling it relief -- a mechanism
that returns memory EVENTUALLY cannot fund an allocation happening NOW.
efschu added a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
… stub under the bugs-first order

Neither verdict is finished; the absorption mapping both turn on is the
undone part. Parked rather than polished so the resume starts from the
evidence instead of from scratch.

Two findings worth not losing: sgl-project#363's own ACT verdict R3 postdates the
sgl-project#656/sgl-project#657/sgl-project#658 successors and still did not close, and the per-rank ms/round
ladder floated as its successor scope already exists and already answered
NEGATIVE (-3.16 % inside a 4.43 % band). For sgl-project#584, auto-measurement and a
mechanically enforced single authority look delivered; dynamic recalculation
is the unresolved pillar.

Both qwen sweeps were stopped by the same order before returning findings, so
this is desk evidence only.
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