94057c3d3e
PR Test (NPU) / check-changes (push) Has been cancelled
PR Test (NPU) / pr-gate (push) Has been cancelled
PR Test (NPU) / set-image-config (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-4-npu-a3 (push) Has been cancelled
PR Test (NPU) / stage-b-test-16-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-1-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-2-npu-a3 (push) Has been cancelled
PR Test (Arm64) / pr-gate (push) Has been cancelled
PR Test (Arm64) / check-changes (push) Has been cancelled
PR Test (Arm64) / build-test (push) Has been cancelled
PR Test (sgl-router) / gate (push) Has been cancelled
PR Test (sgl-router) / tier-1 — lint (push) Has been cancelled
PR Test (sgl-router) / tier-2 — build + test (push) Has been cancelled
PR Test (sgl-router) / tier-3 — docker (placeholder) (push) Has been cancelled
PR Test (sgl-router) / tier-3 — k8s integration (push) Has been cancelled
PR Test (sgl-router) / tier-3 — e2e (push) Has been cancelled
PR Test (sgl-router) / finish (push) Has been cancelled
PR Test (NPU) / single-node-poc (map[name:qwen3_6_27b_w8a8_1p_in64k_out1k_50ms runner:linux-aarch64-a3-2 test_case:test/registered/ascend/performance/qwen3_6_27b/test_npu_qwen3_6_27b_w8a8_1p_in64k_out1k_50ms.py test_type:perf]) (push) Has been cancelled
PR Test (NPU) / pr-test-npu-finish (push) Has been cancelled
PR Test (Xeon) / pr-gate (push) Has been cancelled
PR Test (Xeon) / check-changes (push) Has been cancelled
PR Test (Xeon) / build-test (, xeon-gnr, base-b-test-cpu) (push) Has been cancelled
PR Test (XPU) / check-changes (push) Has been cancelled
PR Test (XPU) / pr-gate (push) Has been cancelled
PR Test (XPU) / stage-a-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / wait-for-stage-a (push) Has been cancelled
PR Test (XPU) / stage-b-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / finish (push) Has been cancelled
CI Model Inventory / build-inventory (push) Has been cancelled
Lint / lint (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Compilation Check (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Manual Policy (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Request Processing (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Summary (push) Has been cancelled
PR Test (SMG) / build-wheel (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on windows (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (x86_64 - auto) (push) Has been cancelled
PR Test (SMG) / python-unit-tests (push) Has been cancelled
PR Test (SMG) / unit-tests (push) Has been cancelled
PR Test (SMG) / benchmarks (push) Has been cancelled
PR Test (SMG) / chat-completions (push) Has been cancelled
PR Test (SMG) / chat-completions-4gpu (push) Has been cancelled
PR Test (SMG) / e2e (push) Has been cancelled
PR Test (SMG) / docker-build-test (push) Has been cancelled
PR Test (SMG) / k8s-integration (push) Has been cancelled
PR Test (SMG) / finish (push) Has been cancelled
PR Test (SMG) / summarize-benchmarks (push) Has been cancelled
Release SGLang Model Gateway Docker Image / publish (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Build SDist (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Upload to PyPI (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (aarch64, 12.9, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (x86_64, 12.9, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu129 (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (aarch64, 13.0, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (x86_64, 13.0, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu130 (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 700) (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 720) (push) Has been cancelled
Release SGLang Kernels / release-rocm700 (push) Has been cancelled
Release SGLang Kernels / release-rocm720 (push) Has been cancelled
Release SGLang Kernels / build-musa43 (43, 3.10) (push) Has been cancelled
Release SGLang Kernels / release-musa43 (push) Has been cancelled
118 lines
4.7 KiB
Python
118 lines
4.7 KiB
Python
from __future__ import annotations
|
|
|
|
import math
|
|
from dataclasses import dataclass
|
|
from typing import TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
from sglang.srt.server_args import ServerArgs
|
|
|
|
|
|
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
class CanaryLaunchCapacities:
|
|
"""Pre-allocation sizes for the per-forward tensors a SingleForwardManager owns. Computed
|
|
once at install_canary from ServerArgs + ModelRunner metadata; all fields are upper
|
|
bounds - actual per-step usage may be smaller but never larger.
|
|
|
|
Fields:
|
|
per_forward_verify_capacity: VerifyPlan row capacity for the per-forward HEAD/TAIL
|
|
launches. Sized to pool_slot_count * 3 (3x headroom; radix prefix sharing across
|
|
running reqs can cause sum_r prefix_lens[r] to exceed the pool slot count). When
|
|
the per-step actual count exceeds this, the plan kernel sets VerifyPlan.enable=0
|
|
and the verify kernel skips the step; host logs a warn (no install-time raise).
|
|
per_forward_write_req_capacity: WritePlan row capacity for per-forward writes, also used
|
|
to size the static PlanInput buffers (= max batch size under cuda graph).
|
|
per_forward_write_entry_capacity: Capacity for the expected_input_* placeholder tensors,
|
|
one entry per token written in a single forward.
|
|
"""
|
|
|
|
per_forward_verify_capacity: int
|
|
per_forward_write_req_capacity: int
|
|
per_forward_write_entry_capacity: int
|
|
|
|
def __post_init__(self) -> None:
|
|
for name, value in (
|
|
("per_forward_verify_capacity", self.per_forward_verify_capacity),
|
|
("per_forward_write_req_capacity", self.per_forward_write_req_capacity),
|
|
("per_forward_write_entry_capacity", self.per_forward_write_entry_capacity),
|
|
):
|
|
if value <= 0:
|
|
raise ValueError(f"kv-canary: {name} must be positive, got {value}")
|
|
|
|
@classmethod
|
|
def from_args(
|
|
cls,
|
|
*,
|
|
server_args: ServerArgs,
|
|
req_to_token_pool_size: int,
|
|
max_seq_len_per_req: int,
|
|
pool_slot_count: int,
|
|
) -> CanaryLaunchCapacities:
|
|
if req_to_token_pool_size <= 0:
|
|
raise ValueError(
|
|
"kv-canary: req_to_token_pool_size must be positive, "
|
|
f"got {req_to_token_pool_size}"
|
|
)
|
|
if max_seq_len_per_req <= 0:
|
|
raise ValueError(
|
|
"kv-canary: max_seq_len_per_req must be positive, "
|
|
f"got {max_seq_len_per_req}"
|
|
)
|
|
if pool_slot_count <= 0:
|
|
raise ValueError(
|
|
f"kv-canary: pool_slot_count must be positive, got {pool_slot_count}"
|
|
)
|
|
|
|
cuda_graph_config = server_args.cuda_graph_config
|
|
cuda_graph_max_bs = (
|
|
cuda_graph_config.decode.max_bs if cuda_graph_config is not None else 0
|
|
) or 0
|
|
if cuda_graph_max_bs < 0:
|
|
raise ValueError(
|
|
f"kv-canary: cuda_graph_max_bs must be non-negative, got {cuda_graph_max_bs}"
|
|
)
|
|
|
|
spec_num_draft_tokens = server_args.speculative_num_draft_tokens
|
|
if spec_num_draft_tokens is None:
|
|
spec_num_draft_tokens = 0
|
|
if spec_num_draft_tokens < 0:
|
|
raise ValueError(
|
|
"kv-canary: speculative_num_draft_tokens must be non-negative, "
|
|
f"got {spec_num_draft_tokens}"
|
|
)
|
|
|
|
max_prefill_tokens = server_args.max_prefill_tokens
|
|
if max_prefill_tokens <= 0:
|
|
raise ValueError(
|
|
f"kv-canary: max_prefill_tokens must be positive, got {max_prefill_tokens}"
|
|
)
|
|
|
|
num_tokens_per_bs = 1
|
|
if spec_num_draft_tokens:
|
|
num_tokens_per_bs = max(num_tokens_per_bs, spec_num_draft_tokens)
|
|
|
|
max_bs = max(cuda_graph_max_bs, req_to_token_pool_size)
|
|
|
|
chunked_prefill_size = server_args.chunked_prefill_size
|
|
chunked_limit = (
|
|
chunked_prefill_size
|
|
if chunked_prefill_size is not None and chunked_prefill_size >= 0
|
|
else math.inf
|
|
)
|
|
max_extend_tokens_per_forward = min(max_prefill_tokens, chunked_limit)
|
|
|
|
write_entry_capacity = max(
|
|
max_bs * num_tokens_per_bs, max_extend_tokens_per_forward
|
|
)
|
|
|
|
# Radix prefix sharing lets sum_r prefix_lens[r] exceed pool_slot_count; observed up to ~2x
|
|
# on 20 parallel token-oracle prompts. 3x headroom keeps the partial-fallback path
|
|
# (plan kernel enable=0 + host warn) exceptional. Overflow does not raise at install time.
|
|
per_forward_verify_capacity = int(pool_slot_count * 3)
|
|
|
|
return cls(
|
|
per_forward_verify_capacity=per_forward_verify_capacity,
|
|
per_forward_write_req_capacity=max_bs,
|
|
per_forward_write_entry_capacity=write_entry_capacity,
|
|
)
|