Skip to content

Adjust outlines version. - #200

Merged
hnyls2002 merged 3 commits into
mainfrom
cody/outlines
Feb 17, 2024
Merged

hnyls2002 merged 3 commits into
mainfrom
cody/outlines

Conversation

@hnyls2002

@hnyls2002 hnyls2002 commented Feb 17, 2024 •

Copy link
Copy Markdown
Collaborator

CI States

Latest PR Test (Base): ❌ Missing run-ci label -- add it to run CI tests.
Latest PR Test (Extra): ❌ Blocked -- run-ci is required first.

@hnyls2002
hnyls2002 merged commit 91e0363 into main Feb 17, 2024
@hnyls2002
hnyls2002 deleted the cody/outlines branch February 17, 2024 05:40
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
* ci: enable dsv3 cursor phoenix ut

* fix phoenix ci bug

---------

Co-authored-by: Junxiong <[email protected]>
IzacharyI added a commit to IzacharyI/sglang that referenced this pull request Mar 16, 2026
* [Feat] Optimize gamma rms norm kernel

* [Feat] Optimize silu_mul kernel

* Move and adaptation of GDN opt from Qwen3next to Qwen3.5 (sgl-project#199)

* rm 3*copy after casual conv, do q/k/v split in causal_conv1d_update_split_qkv kernel during decode time

* Add fused Sigmoid and mul triton kernel

* add fused gdn gating and  sigmoid func for prefill phase

* Add fused causal conv1d fwd split qkv kernel

* Add fused cumsum_kkt, solve_tril, and merge_recompute kernels for prefill optimization

* Increase parallel params for chunk_gated_delta_rule_fwd_kernel

* add chunk o kernel opt

* [Feat] Optimize fused_sigmoid_gating kernel

---------

Co-authored-by: root <[email protected]>
Co-authored-by: zachYao <[email protected]>
rucnyz added a commit to rucnyz/sglang that referenced this pull request Jun 7, 2026
…ytes_per_token

Assemble the DESIGN §8 forecast trajectory term (forecast_inflight_demand
+ pause_relief.future_inflight_savings) end-to-end, gated per input so it
stays exactly 0 until the live measurements land — activation-ready.

sglang: expose bytes_per_token_in_subpool. New
_aginfer_decode_bytes_per_token(ct) → per-token HBM DECODE growth
(attention = bytes/token, Mamba = 0, since Mamba state is allocated
per-sequence not per-token). Added as pool_usage[*].subpools[sp].
decode_bytes_per_token on every subpool. This is the one input the
daemon can't derive itself; the other two (decode throughput, E[remaining])
are T26/T11.

daemon:
- TierUsage.decode_bytes_per_token carried from the dump (default 0 for
  older sglang); flattened rank-0 in _flatten_per_rank.
- _program_inflight_growth: the per-program product
  min(E[remaining], horizon×decode_throughput) × decode_bytes_per_token,
  gated on decode_throughput>0 (T26) AND a real E[remaining] (T11) AND
  inflight[sp]>0 AND decode_bytes_per_token>0 (Mamba=0 excluded).
- forecast_inflight_demand sums it over programs; pause_relief adds it as
  future_inflight_savings; pause_candidates threads heartbeat_s.
- expected_remaining_tokens reads an optional per-program field and
  returns None (NOT the max_completion_tokens bootstrap) when absent —
  skipping the program rather than over-pausing ~5× (DESIGN §8 anti-
  pattern). The estimator's full priority is T11/sgl-project#126.

Production stays at forecast = used_bytes (decode_per_program / per-
program inflight are sglang placeholders) — behaviour-preserving.
verify/admission_controller trajectory stage pins the full product +
the T26/T11/Mamba/idle gating with synthetic inputs. integration_stress
7 flavors green on the real B300 stack (the additive dump field flows
through sglang→daemon without breaking).

Remaining activation gated on T26 (sgl-project#200: sglang decode-throughput /
prefill_bps / per-program inflight measurement) and T11 (sgl-project#126:
populate expected_remaining_tokens).
rucnyz added a commit to rucnyz/sglang that referenced this pull request Jun 7, 2026
…l_bps + inflight

The daemon's DESIGN §8 admission inputs shipped as sglang placeholders
(throughput_ema = {prefill_bps:0.0, decode_per_program:{}}, per-program
inflight = {}).  Wire real measurement so marginal_pause_cost + the
in-flight half of pause_relief go live.

sglang scheduler:
- new mem_cache/aginfer_metrics.py — pure helpers (ema_update,
  inflight_bytes_by_program, decode_tokens_by_program, running_program_
  view); unit-tested in verify/t26 (no GPU).
- _aginfer_record_throughput(batch), called from run_batch (NOT
  process_batch_result): under overlap scheduling the forward strips the
  batch's extend_num_tokens/input_ids, so prefill tokens are only on the
  fresh pre-forward batch; decode tokens come from batch.reqs (persist).
  Per-program decode tokens/sec EMA + prefill bytes/sec EMA.
- _aginfer_push_runtime_metrics(), called from get_aginfer_state (cold):
  assembles decode_per_program (live programs only), prefill_bps, and
  inflight_bytes_by_program(running_batch.reqs); prunes stale EMAs;
  pushes via cache.set_aginfer_runtime_metrics.

unified_radix_cache:
- _aginfer_runtime_metrics store + set_aginfer_runtime_metrics setter;
  _aginfer_throughput_ema returns the pushed EMAs (was hardcoded);
  _aginfer_overlay_program_states fills hbm.inflight (both dump paths).

Two corrections found by real-stack debugging (debug-log + run, not
static analysis):
1. inflight = kv_allocated_len × bpt, not allocated − committed —
   sglang commits each decoded token immediately so allocated −
   committed ≡ 0; the running req's current KV is what marginal_pause_
   cost wants.
2. prefill measured at run_batch — at process_batch_result the extend
   batch's token fields are all None (overlap scheduling).

Verified: verify/t26 (4 pure stages) + verify/integration_stress stage
T26 on the real B300 stack — prefill_bps≈9e8, decode≈700 tok/s × 4 tagged
programs, inflight populated in 81/93 polls.  Daemon side: marginal_
pause_cost + pause_relief inflight snapshot now LIVE; the forecast
trajectory term still waits on T11 (sgl-project#126: expected_remaining_tokens) by
design (the bootstrap over-pause gate).  Follow-on sgl-project#205: inflight∩
committed snapshot overlap in pause_relief (bounded over-count).
rucnyz added a commit to rucnyz/sglang that referenced this pull request Jun 7, 2026
…afety + tests

Adversarial audit confirmed the wiring sound (push paths, multi-rank
summing, div-by-zero guards) and found one real BUG + safety/test gaps.

BUG — spec-decode / MIXED batches polluted prefill_bps. is_extend() is
True for MIXED / TARGET_VERIFY / DRAFT_EXTEND, so under speculative
decoding the verify/draft steps (and a MIXED batch's running-decode
tokens) were counted as PREFILL, corrupting prefill_bps → marginal_pause
_cost; and decode_per_program stayed empty (is_decode() is pure DECODE
only). The verify deployment uses only pure EXTEND/DECODE so it never
bit. Fix: classify on the EXACT mode — only pure DECODE counts as
decode, only pure EXTEND as prefill — conservative (under-measured) on
spec/chunked, never wrong. Full spec/MIXED accounting tracked as sgl-project#206.

hot-path safety — _aginfer_record_throughput now runs inside a blanket
try/except (extracted _inner): a crash in this brand-new per-forward
instrumentation would kill the scheduler event loop; a lost sample is
harmless. The push path is guarded too (never breaks the state dump).

nit — the inflight overlay no longer resurrects a just-ENDED-GC'd pid
(a draining running req of an ended program must not reappear as
REASONING).

tests:
- verify/t26 stage_scheduler_routing: pins DECODE→decode, EXTEND→prefill,
  MIXED/TARGET_VERIFY/DRAFT_EXTEND→NEITHER, and the wrapper's raise-
  safety (the scheduler glue had zero unit coverage). + ema(prev=0.0)
  blends (not re-seeds).
- integration_stress stage T26 now requires ALL tagged programs measured
  for BOTH decode and inflight (was ≥1 / any()), tied to the specific
  tagged pids — a single stuck/misattributed program no longer passes.

Follow-ons: sgl-project#205 (inflight∩committed overlap — re-prioritized: can be
LARGE for long shared prefixes now that both terms are live), sgl-project#206
(spec/MIXED/chunked measurement + spec over-alloc inflight + chunked
running-set).

Re-verified: verify/t26 (5 stages) + integration_stress stage T26 on the
real B300 stack — prefill_bps≈2e9, decode 4/4 tagged, inflight 4/4
tagged; all 7 flavors green.
rucnyz added a commit to rucnyz/sglang that referenced this pull request Jun 7, 2026
T26 (sgl-project#200) only counted pure DECODE (1 tok/req) and pure EXTEND
(extend_num_tokens) — MIXED and spec batches were skipped, so
decode_per_program / prefill_bps were conservatively under-measured.
This accounts for all forward modes:

MIXED (chunked prefill + running decode): split the batch via
batch.decoding_reqs (sglang's own metrics discriminator) — the prefill
reqs' extend_input_len feeds prefill_bps, the decode reqs feed the
per-program decode EMA (1/req).  extend_num_tokens spans the whole batch
(1 per decode req) so it can't stand in for the prefill count.

spec decode: a verify step commits accept_lens[i] tokens/req, not 1.
That count is exposed only on the spec-v2 (overlap-on) path as
result.num_correct_drafts_per_req_cpu (= accept_lens-1; +1 = accepted),
resolved post-forward.  So for is_spec_v2 DECODE batches the pre-forward
branch skips and _aginfer_record_spec_decode (from process_batch_result,
raise-safe) records the real accepted count per program.  spec-v1 (ngram,
overlap off) doesn't expose accept_lens, so it keeps the conservative
1/req pre-forward count — never blanked, no regression.  The gate is
batch.is_spec_v2 on both sides.  DRAFT_EXTEND excluded (uncommitted
drafts).  MIXED decode is always counted 1/req here even under spec-v2,
since the post-forward hook only fires for is_decode() batches.

pure helpers: decode_tokens_by_program gains per_req_tokens (index-aligned
accept_lens); timing/EMA factored into _aginfer_update_decode/_prefill.

verify/t26: +mixed, +spec-decode pure stages (routing now pins spec-v1
vs v2); verify/t26/realstack_modes.py drives MIXED (--enable-mixed-chunk)
and spec-v1 (--speculative-algorithm NGRAM) on the real B300 stack.
harness: stack() gains sglang_extra_args.

Audit closed F1 (raise-safety test now binds the inner method so it hits
the real non-iterable path) + F2 (spec-v2 MIXED decode counts 1/req here,
not dropped).

Verified: pure 7/7; real-stack MIXED prefill_bps≈7.3e8 decode 4/4
inflight 4/4, spec-v1 decode 3/3, no suppressed warnings; full
integration_stress 7/7 flavors green (no hot-path regression).

The sgl-project#205 uncached-inflight relief term (per-unit holder attribution) is
split to sgl-project#207 (daemon pause_relief, a separate subsystem).
rucnyz added a commit to rucnyz/sglang that referenced this pull request Jun 7, 2026
…token

Discovered during the sgl-project#208 A3 campaign: the live /aginfer/state reported
cap_bytes=0 for EVERY subpool (HBM/DRAM/DISK) despite 754 units in the
tree, so occ_hbm≡0 the whole run and the daemon never detected HBM
pressure (18k kv_decide calls, ~1 real migrate/cycle).  Historical A3
showed occ→1.0, so this was a regression.

Root cause: _aginfer_bytes_per_token caches its result, but
`if cached is not None: return cached` treats 0 as a valid cache — so a
single early call that computes bpt=0 (kvcache not yet wired) poisons it
permanently, zeroing every `size * bpt` cap in _aginfer_pool_usage.
Before sgl-project#200/sgl-project#206 the FIRST caller was always the cold dump (kvcache
ready → bpt>0); the T26 throughput hooks added hot-path callers in
run_batch, which now hit this much earlier and cached their transient 0.
T26 never caught it because it only checks throughput, not pool_usage.

Fix: only cache a POSITIVE bpt; a 0 returns but recomputes next call
(self-healing — the dump then reads the real value the model exposes).

Guards:
* verify/t26 stage `bpt-cache` (pure, deterministic): transient 0 not
  cached, positive bpt cached + sticky.
* verify/integration_stress stage T26: asserts pool_usage HBM
  cap_bytes>0 on the real stack — the invariant that would have caught
  this.

Consequence for sgl-project#208: the daemon-specific arms (ours_full, const_vu)
ran with occ_hbm≡0 → an INACTIVE daemon, so their "does the daemon
help" comparison is void and the campaign's daemon arms must be re-run
post-fix.  The eviction-quality arms (ours_inline/lru/ta, via cache_hit%)
are unaffected.  parse_a3_campaign.py gained the multi-metric report
(cache_hit% / reprefill / e2e+queue latency / daemon activity) since
per-trial wall time is too high-variance to discriminate the arms.
rucnyz added a commit to rucnyz/sglang that referenced this pull request Jun 7, 2026
…-wins + union)

Second holistic audit pass on the cross-rank (TP>1) aggregation in
_flatten_per_rank found two more bugs of the same class as the sgl-project#210
leaf-flag merge — a per-program/per-unit field that diverges across ranks
in a transient window, where the merge picked the WRONG side. PUT
/aginfer/program_paused and per-rank session tagging both fan out per-rank
non-atomically, so a state dump can land mid-fan-out with ranks disagreeing.

1. per_program_usage[pid].state used most-active-wins
   (REASONING>ACTING>PAUSED>ENDED). If a lagging rank still reported a
   just-paused program as REASONING, the merge masked the pause →
   resume_candidates (which only considers state=="PAUSED") dropped it →
   the program (emits no events of its own) STARVED to AgentTimeout. The
   sgl-project#211 starvation class, here via cross-rank merge instead of dropped
   units. pre_pause_state followed the wrong (REASONING→None) rank too,
   which would restore a resumed program to the wrong state.
   Fix: PAUSED:4 > REASONING:3 > ACTING:2 > ENDED:0. PAUSED wins (the
   liveness-safe side, mirroring residence-union / leaf-AND); ENDED still
   loses so a lagging co-holder rank isn't driven to a premature ENDED that
   drops session_scoped KV.

2. holders/session_ids kept rank-0's set verbatim in the unit-dedupe
   collision branch → order-dependent. shared_aware_prog_scores' V_u
   divisor len(holders) and session_scoped_units' holders=={session}
   predicate skewed by rank ordering.
   Fix: UNION session_ids (colder superset, order-independent) alongside
   the existing residence-union / leaf-AND reconciliation.

verify/kv_scheduler_value_rule stages A1c (PAUSED-wins + pre_pause survives
+ ENDED-loses, order-independent) and A1d (holders union, order-independent)
pin both; mutation-tested RED→GREEN; suite 23/23. joint_decide +
admission_controller still green.

Follow-ons filed (not fixed here): decode_per_program SUM-vs-DESIGN-mean
(dormant until T11/T26); resume double-fire dedup on overlay lag (benign
waste); partial-drop resume HBM under-estimate; t21 verify stale vs
sgl-project#200's _aginfer_runtime_metrics.
rucnyz added a commit to rucnyz/sglang that referenced this pull request Jun 7, 2026
…trics in dump helpers

_aginfer_overlay_program_states (and _aginfer_throughput_ema) read
self._aginfer_runtime_metrics directly. The attribute is initialized in
__init__, but the dump-building helpers must not assume it exists: a
metrics-less object (test mock, or any partial-init path) AttributeErrors,
and conceptually the metrics may simply not be pushed yet at cold start
(before the scheduler's first set_aginfer_runtime_metrics). Guard both reads
with getattr(self, "_aginfer_runtime_metrics", {}). Fixes verify/t21 stages
B0/B2/B3/B4 (stale since sgl-project#200/T26 added the attribute), which now non-vacuously
pin the cold-start robustness (B0 builds the overlay on a metrics-less cache).
efschu added a commit to efschu/htsglang that referenced this pull request Jul 26, 2026
…the E2E win

Qwen3.6-27B-FP8, uneven 6,4,4,2 + capacity-DCP + NEXTN solo, slope
method, 3 content classes, reps 3; arms differ only in the 8 HTCCL
files (+1 env flag):

  A pre-L2 transport:   16.38 / 15.67 / 16.54 tok/s (code/prose/mixed)
  B L2 transport:       17.31 / 17.57 / 18.36  (B/A +5.7/+12.1/+11.0%)
  C B+overlap flag:     17.92 / 17.12 / 17.84  (C/B neutral in spread)
  D B+coupled KV split: 18.11 / 16.84 / 18.15  (neutral at short ctx)

spec_accept_length identical across arms per content (3.08/3.03/2.91),
zero degeneration. Overlap activation PROVEN via a once-per-rank INFO
log (added to htccl_mlp_ar_overlap_comm) on all 4 ranks -- the neutral
C/B is a measured negative result, not a dormant flag. Per-rank GPU
util sampled per arm: main rig 10-13%, 2080 Ti 50-55%, stable across
arms -- the slowest card paces the lock-step group; straggler compute,
not communication, is the next lever (sgl-project#103/sgl-project#200). Details persisted in
FEATURES_VS_UPSTREAM.md.
efschu added a commit to efschu/htsglang that referenced this pull request Jul 27, 2026
Chosen-David pushed a commit to Chosen-David/sglang that referenced this pull request Oct 10, 2026
TL-E119-PROBE-RECEIPT-VALIDATION-070(P2,GPT 2026-10-10 1528 审计
b12e313):完成探针对 pointer 候选只调 resolve_generation_pointer(明确
不校验回执内容)后数预测行数判 complete——「预测足量 + 回执存在但
无效(半写 JSON/未知 schema/非 complete/basename/SHA/行数失配)」被判
complete → run_ruler_e109.sh SKIP,正式汇总 score_ruler_formal.py 却
fail-closed 拒收:调度与交付的完成定义分裂,坏格永久 SKIP 且正式评分
永远拒绝(GPT CPU 复现:probe complete vs formal 拒收同一输入)。

修复(GPT 方案微调,主 AI 定口径):
1. yarn_receipt.validate_committed_generation 共享校验器(零重依赖):
   回执单一 bytes 快照(062①)→ JSON 解析失败即拒 →
   validate_producer_receipt(协议版本集 v1+v2 与 formal 现行接受集合
   同口径 + 060 严格 schema + 059 v2 绑定格式层)→ v2 同代字节绑定
   (实际预测 SHA256/行数 vs 回执声明逐位比对)。任一失败 raise
   SystemExit [GATE-FAIL](python -O 不失效)。v1 无绑定字段 → 跳过
   字节比对,与 formal 降级消费同口径(指针协议生产路径只产 v2)。
2. gen_completion_probe.py probe_task pointer 分支 resolve 后调用共享
   校验器——失败 SystemExit 穿透 → STATE=invalid 非零退出(PROBE-FAIL
   人工介入;与 068 invalid 语义/CLI 四态契约对齐,run_ruler_e109.sh
   零改动)。legacy-direct 分支行数语义零改动(不被 pointer 回执
   门禁误伤)。
3. score_ruler_formal._load_producer_yarn_receipt 重构为调用共享校验器
   (062①② 收编;062③ 三方一致与 v1 降级分支保留 formal 侧)——
   拒收/exit code 语义不变,完成定义自此单口径。
4. --audit-dir 只读预检模式:遍历目录全部 .tli_gen 指针逐格验证回执
   绑定,输出 OK/INVALID 清单(invalid → exit 2),全程零写。
   本机 E109 输出根实测:零 pointer 产物(全部 legacy-direct 代),
   预检无对象,已收口数据零改动零 invalid。

红绿测试:
- test_e119_pointer_consumer_068_069.py 追加 G8(真实提交代破坏六
  负例:非 JSON/{}/status/basename/SHA/行数 → 全 STATE=invalid +
  [GATE-FAIL] + PROBE-FAIL;合法 v2 代零误伤仍 SKIP;破坏前红、修
  复后绿——G8a 红输出 complete 即审计复现闭合)+ A1(audit 只读
  预检:3 OK + 1 invalid → rc=2 清单;valid-only rc=0;零 pointer
  如实 total=0;目录快照逐位一致零写)。全套 13/13 python±-O。
- test_e119_yarn_binding B2 注入点随重构迁移(SF.validate_producer_
  receipt 缝隙已收进共享校验器 → 改 SF._file_sha256 源三方校验读取
  点,路径条件触发),窗口语义(快照后/源校验前提交 B 代 → 三方
  一致门禁「冻结窗口…062」拒收)与断言不变:31/31 python±-O。
- 回归全绿:binding 31/31 ±-O、057 10/10 ±-O、crossarm 20/20 ±-O、
  E116f 12/12 ±-O、E116d 9/10(D9 既知 SKIP)、E116e 12/13(D9
  既知 SKIP);生产代码零裸 assert。
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