Skip to content

Improve Chinese character streaming when the last char is half Chinese word. - #95

Merged
Ying1123 merged 1 commit into
sgl-project:mainfrom
haotian-liu:improve-cjk
Jan 24, 2024
Merged

Ying1123 merged 1 commit into
sgl-project:mainfrom
haotian-liu:improve-cjk

Conversation

@haotian-liu

Copy link
Copy Markdown
Contributor

Currently when the last word is Chinese, but only the first-half, the streaming will be delayed until the next chunk containing a full word -- occasionally delayed by three chunks or more.

Add a check if the penultimate token is a full Chinese word and stream the full words in that case.

@haotian-liu haotian-liu changed the title Improve Chinese character streaming when the last char is half-word. Improve Chinese character streaming when the last char is half Chinese word. Jan 24, 2024
@Ying1123
Ying1123 merged commit d3fc86a into sgl-project:main Jan 24, 2024
timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
pi314ever pushed a commit to pi314ever/sglang that referenced this pull request Aug 1, 2025
apinge referenced this pull request in apinge/sglang Dec 15, 2025
* add fused set kv

* fix bug

* comp with qwen235moe

* format lint
vschandramourya pushed a commit to vschandramourya/sglang that referenced this pull request Feb 3, 2026
efschu added a commit to efschu/htsglang that referenced this pull request Jul 18, 2026
…rve default (sgl-project#95)

All 4 errors were red at the base commit: sgl-project#68 changed the
--rank-auto-reserve-mib default from the flat 2048 MiB to the
demand-derived 'auto' sentinel without updating this test.

- test_defaults now asserts the 'auto' sentinel
  (ServerArgs.AUTO_RANK_MEMORY_RESERVE_MIB) instead of int(...) == 2048.
- The three TestAutoRatio arithmetic tests pin rank_auto_reserve_mib=2048
  explicitly: their documented budget math (min(total - 2048, free -
  1024)) is exact and device-independent that way, while the 'auto'
  default would route through the capacity-tier derivation (which needs
  the device capacity and cuda_graph_config the short-circuited
  ServerArgs stub lacks).
- New test_auto_reserve_auto_derives_from_demand completes the stub for
  the 'auto' path (real default CudaGraphConfig, mocked
  get_device_memory_capacity, capture term disabled) and asserts the
  wiring: budgets == min(total - derived_rank_auto_reserve_mib(...),
  free - 1024), uniform cards still collapse to the even split.

No production code touched; the auto-derive path behaves correctly on a
minimal ServerArgs once the stub is complete. File green: 63/63 (was
59/63 at base).
efschu added a commit to efschu/htsglang that referenced this pull request Jul 18, 2026
…rve default (sgl-project#95)

All 4 errors were red at the base commit: sgl-project#68 changed the
--rank-auto-reserve-mib default from the flat 2048 MiB to the
demand-derived 'auto' sentinel without updating this test.

- test_defaults now asserts the 'auto' sentinel
  (ServerArgs.AUTO_RANK_MEMORY_RESERVE_MIB) instead of int(...) == 2048.
- The three TestAutoRatio arithmetic tests pin rank_auto_reserve_mib=2048
  explicitly: their documented budget math (min(total - 2048, free -
  1024)) is exact and device-independent that way, while the 'auto'
  default would route through the capacity-tier derivation (which needs
  the device capacity and cuda_graph_config the short-circuited
  ServerArgs stub lacks).
- New test_auto_reserve_auto_derives_from_demand completes the stub for
  the 'auto' path (real default CudaGraphConfig, mocked
  get_device_memory_capacity, capture term disabled) and asserts the
  wiring: budgets == min(total - derived_rank_auto_reserve_mib(...),
  free - 1024), uniform cards still collapse to the even split.

No production code touched; the auto-derive path behaves correctly on a
minimal ServerArgs once the stub is complete. File green: 63/63 (was
59/63 at base).
efschu added a commit to efschu/htsglang that referenced this pull request Jul 22, 2026
…rve default (sgl-project#95)

All 4 errors were red at the base commit: sgl-project#68 changed the
--rank-auto-reserve-mib default from the flat 2048 MiB to the
demand-derived 'auto' sentinel without updating this test.

- test_defaults now asserts the 'auto' sentinel
  (ServerArgs.AUTO_RANK_MEMORY_RESERVE_MIB) instead of int(...) == 2048.
- The three TestAutoRatio arithmetic tests pin rank_auto_reserve_mib=2048
  explicitly: their documented budget math (min(total - 2048, free -
  1024)) is exact and device-independent that way, while the 'auto'
  default would route through the capacity-tier derivation (which needs
  the device capacity and cuda_graph_config the short-circuited
  ServerArgs stub lacks).
- New test_auto_reserve_auto_derives_from_demand completes the stub for
  the 'auto' path (real default CudaGraphConfig, mocked
  get_device_memory_capacity, capture term disabled) and asserts the
  wiring: budgets == min(total - derived_rank_auto_reserve_mib(...),
  free - 1024), uniform cards still collapse to the even split.

No production code touched; the auto-derive path behaves correctly on a
minimal ServerArgs once the stub is complete. File green: 63/63 (was
59/63 at base).
efschu added a commit to efschu/htsglang that referenced this pull request Jul 22, 2026
…city/feasibility/split, never tok/s

Pure-library planner over the fork's EXISTING parse-time sizing math -- no
formula is re-implemented:

* PlanInputs (uneven_perf.py): the small boot-free input contract of
  PerfCostModel (design sgl-project#97 §2.1), incl. per-card effective_vram_mib
  budgets (§2.5) and manual-edit override fields (§2.6).
  PerfCostModel now takes PlanInputs; the boot path builds it via
  PlanInputs.from_server_args at its single call site, so server and
  offline planner run identical sizing code (the §5 sync guarantee).
* sglang/srt/planner/: hardware.py (HardwareSpec; NVML via the
  rig-dashboard sample_nvml -> nvidia-smi -> MANUAL spec fallback -- fully
  offline-capable), model.py (HF config.json / .gguf / hub-config-only
  resolution, never weights), plan.py (derive_auto_plan: pure lift of
  _resolve_auto_rank_tp_ratio; reserve formulas called UNBOUND from the
  real ServerArgs methods), capacity.py (predict_capacity wrapper),
  feasibility.py (auto + manual-edit validation mirroring
  _handle_uneven_tp; fail-loud naming card/ranks/limit), advantage.py
  (stock-even-TP contrast: feasibility reasons + capacity-% RANGE;
  measured scores cache-only, gated to live-NVML specs).
* python -m sglang.planner CLI: fit verdict, split + launch flags,
  per-rank VRAM breakdown, max-KV estimate, advantage vs stock.
* Honesty is structural (§3.4): no planner dataclass carries a
  throughput-shaped field; a CPU test enforces it.

Tests: test/registered/unit/planner/test_planner_core.py -- 33 passed
(CPU-only; manual 5090+2x3080 rig, synthetic sparse checkpoints).
Regression: test_uneven_tp_args / _mlp_solver / _partition / _memory
identical pass/fail sets before and after the refactor (the 8 failures
are pre-existing on integration/r1, the sgl-project#95 testfix lives on other
branches); mlp_solver+partition (direct PerfCostModel consumers) fully
green. Manual CLI runs: Qwen3.6-27B-AWQ TP=3 (fits, stock cannot shard
4 KV heads / 544-unit FFN across 3), TP=4 co-location 0,0,1,2 with
--plan-free-reserve-gb, dense GGUF Q3_K_M (68-unit grid), physical
impossibility rejection 2x20000 MiB on the 32607-MiB card.
efschu added a commit to efschu/htsglang that referenced this pull request Jul 22, 2026
…rve default (sgl-project#95)

All 4 errors were red at the base commit: sgl-project#68 changed the
--rank-auto-reserve-mib default from the flat 2048 MiB to the
demand-derived 'auto' sentinel without updating this test.

- test_defaults now asserts the 'auto' sentinel
  (ServerArgs.AUTO_RANK_MEMORY_RESERVE_MIB) instead of int(...) == 2048.
- The three TestAutoRatio arithmetic tests pin rank_auto_reserve_mib=2048
  explicitly: their documented budget math (min(total - 2048, free -
  1024)) is exact and device-independent that way, while the 'auto'
  default would route through the capacity-tier derivation (which needs
  the device capacity and cuda_graph_config the short-circuited
  ServerArgs stub lacks).
- New test_auto_reserve_auto_derives_from_demand completes the stub for
  the 'auto' path (real default CudaGraphConfig, mocked
  get_device_memory_capacity, capture term disabled) and asserts the
  wiring: budgets == min(total - derived_rank_auto_reserve_mib(...),
  free - 1024), uniform cards still collapse to the even split.

No production code touched; the auto-derive path behaves correctly on a
minimal ServerArgs once the stub is complete. File green: 63/63 (was
59/63 at base).
ihciah pushed a commit to ihciah/sglang that referenced this pull request Nov 25, 2026
…iled on (sgl-project#95)

Two gaps between this router and the SGLang servers it fronts.

/health: SGLang engines and sgl-model-gateway answer liveness on
/health; this router only on /healthz, so a probe or script written for
either got 404 here. /health now routes to the same liveness handler as
/healthz (always 200) and is logged like the other infra probes (DEBUG
on success).

POST /flush_cache: the fan-out to every registered worker (plain,
prefill and decode) was correct, but a refusing worker was reported only
as "HTTP 400 Bad Request", and neither the response message nor the
warning line said which worker refused. SGLang answers 400 without
flushing while it has running or waiting requests, so a flush sent
while a prefill/decode pair is serving returns 502 with no way to tell
which side refused or why. Each failed worker's error now carries the
start of its answer (at most 512 bytes, whitespace collapsed:
"HTTP 400 Bad Request: Flush cache failed."), and the message and the
warning list every failed worker with its error. Status codes are
unchanged: 200 when every worker flushed, 502 otherwise.

Tests:
- routes/health.rs health_is_served_as_liveness: GET /health is 200.
- routes/cache.rs refused_flush_names_the_worker_and_its_answer: one
  worker flushes, one answers 400 "Flush cache failed."; the 502 names
  the refusing worker with its answer and does not list the other.
- routes/cache.rs refusal_answer_is_bounded: an 8 KiB answer is cut.
All three fail on the release line before this change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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