chore: import upstream snapshot with attribution
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

This commit is contained in:
wehub-resource-sync
2026-07-13 12:38:16 +08:00
commit 94057c3d3e
7152 changed files with 2120455 additions and 0 deletions
@@ -0,0 +1 @@
# AMD-specific DeepSeek common model helpers.
@@ -0,0 +1,158 @@
import logging
from typing import Optional, Tuple
import torch
import triton
from sglang.srt.environ import envs
logger = logging.getLogger(__name__)
_FUSED_HC_POST_PRE_M_THRESHOLD = 64
_FUSED_HC_POST_PRE_CACHE: dict[tuple, dict[str, torch.Tensor]] = {}
_TRITON_MHC_POST_PRE_OPS = None
_TRITON_MHC_POST_PRE_RUNTIME_DISABLED = False
def _get_triton_mhc_post_pre_ops():
global _TRITON_MHC_POST_PRE_OPS
if _TRITON_MHC_POST_PRE_OPS is not None:
return _TRITON_MHC_POST_PRE_OPS
try:
from aiter.ops.triton.fusions.mhc import mhc_post_pre
from aiter.ops.triton.utils.mhc_config_utils import get_mhc_config
except Exception as err:
logger.warning(
"Triton fused mHC (mhc_post_pre) is unavailable, falling back: %s", err
)
return None
_TRITON_MHC_POST_PRE_OPS = (mhc_post_pre, get_mhc_config)
return _TRITON_MHC_POST_PRE_OPS
def _get_fused_hc_post_pre_buffers(
num_tokens: int,
hidden_size: int,
hc_mult: int,
dtype: torch.dtype,
device: torch.device,
) -> Optional[dict[str, torch.Tensor]]:
ops = _get_triton_mhc_post_pre_ops()
if ops is None:
return None
_, get_mhc_config = ops
key = (num_tokens, hidden_size, hc_mult, dtype, device.type, device.index)
bufs = _FUSED_HC_POST_PRE_CACHE.get(key)
if bufs is not None:
return bufs
try:
cfg, _ = get_mhc_config("MHC_FUSED", num_tokens, hidden_size, mode="sinkhorn")
except Exception as err:
logger.warning("Failed to initialize fused mHC config, falling back: %s", err)
return None
n_total = 2 * hc_mult + hc_mult * hc_mult
k_dim = hc_mult * hidden_size
block_k = cfg.get("BLOCK_K", min(512, triton.next_power_of_2(k_dim)))
block_k = min(block_k, triton.next_power_of_2(k_dim))
block_c_split = max(block_k // hc_mult, 1)
num_ksplit = triton.cdiv(hidden_size, block_c_split)
bufs = {
"residual_out": torch.empty(
num_tokens, hc_mult, hidden_size, dtype=dtype, device=device
),
"layer_input_out": torch.empty(
num_tokens, hidden_size, dtype=dtype, device=device
),
"h_post": torch.empty(num_tokens, hc_mult, dtype=torch.float32, device=device),
"h_res": torch.empty(
num_tokens, hc_mult, hc_mult, dtype=torch.float32, device=device
),
"acc_partial": torch.empty(
num_ksplit, num_tokens, n_total, dtype=torch.float32, device=device
),
"acc_sq_partial": torch.empty(
num_ksplit, num_tokens, dtype=torch.float32, device=device
),
}
_FUSED_HC_POST_PRE_CACHE[key] = bufs
return bufs
def try_fused_hc_post_pre(
x: torch.Tensor,
residual: torch.Tensor,
post: torch.Tensor,
comb: torch.Tensor,
hc_fn_t: torch.Tensor,
hc_scale: torch.Tensor,
hc_base: torch.Tensor,
hc_mult: int,
norm_eps: float,
hc_eps: float,
hc_post_mult: float,
sinkhorn_iters: int,
is_gfx95_supported: bool,
) -> Optional[Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, bool]]:
global _TRITON_MHC_POST_PRE_RUNTIME_DISABLED
if (
_TRITON_MHC_POST_PRE_RUNTIME_DISABLED
or not envs.SGLANG_OPT_USE_TRITON_FUSED_MHC.get()
or not is_gfx95_supported
or x.shape[0] == 0
or x.shape[0] > _FUSED_HC_POST_PRE_M_THRESHOLD
or x.dim() != 2
or residual.dim() != 3
):
return None
ops = _get_triton_mhc_post_pre_ops()
if ops is None:
return None
mhc_post_pre, _ = ops
bufs = _get_fused_hc_post_pre_buffers(
x.shape[0], x.shape[1], hc_mult, residual.dtype, x.device
)
if bufs is None:
return None
try:
_, _, layer_input_out, new_residual = mhc_post_pre(
x,
residual,
post,
comb,
hc_fn_t,
hc_scale,
hc_base,
hc_mult,
norm_eps,
hc_eps,
hc_post_mult,
sinkhorn_iters,
# Match sglang's exp-domain asymmetric Sinkhorn used in hc_pre.
asymmetric_exp_domain=True,
hc_sinkhorn_eps=hc_eps,
residual_out=bufs["residual_out"],
h_post=bufs["h_post"],
h_res=bufs["h_res"],
layer_input_out=bufs["layer_input_out"],
acc_partial=bufs["acc_partial"],
acc_sq_partial=bufs["acc_sq_partial"],
)
except Exception as err:
logger.warning(
"Triton fused mHC kernel failed, disabling fallback path: %s", err
)
_TRITON_MHC_POST_PRE_RUNTIME_DISABLED = True
return None
return new_residual, layer_input_out, bufs["h_post"], bufs["h_res"], False