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
122 lines
3.1 KiB
Python
122 lines
3.1 KiB
Python
import torch
|
|
import triton
|
|
import triton.language as tl
|
|
|
|
|
|
@triton.jit
|
|
def rotl32(x, r: tl.constexpr) -> tl.uint32:
|
|
"""
|
|
rotate left 32-bit integer x by r bits
|
|
e.g. x = 01110001, r = 2 -> 11000101
|
|
"""
|
|
x = x.to(tl.uint64)
|
|
return ((x << r) | (x >> (32 - r))) & 0xFFFFFFFF
|
|
|
|
|
|
@triton.jit
|
|
def fmix32(h: tl.uint32) -> tl.uint32:
|
|
"""
|
|
final mix of 32-bit hash value for MurmurHash
|
|
"""
|
|
h ^= h >> 16
|
|
h = (h * 0x85EBCA6B) & 0xFFFFFFFF
|
|
h ^= h >> 13
|
|
h = (h * 0xC2B2AE35) & 0xFFFFFFFF
|
|
h ^= h >> 16
|
|
return h
|
|
|
|
|
|
@triton.jit
|
|
def murmur3_mix(h: tl.uint32, k: tl.uint32) -> tl.uint32:
|
|
"""
|
|
Mixes a 32-bit key into the hash state.
|
|
"""
|
|
c1: tl.uint32 = 0xCC9E2D51
|
|
c2: tl.uint32 = 0x1B873593
|
|
r1: tl.constexpr = 15
|
|
r2: tl.constexpr = 13
|
|
mm: tl.uint32 = 5
|
|
nn: tl.uint32 = 0xE6546B64
|
|
|
|
k = (k * c1) & 0xFFFFFFFF
|
|
k = rotl32(k, r1)
|
|
k = (k * c2) & 0xFFFFFFFF
|
|
h ^= k
|
|
h = rotl32(h, r2)
|
|
h = (h * mm + nn) & 0xFFFFFFFF
|
|
return h
|
|
|
|
|
|
@triton.jit
|
|
def murmur_hash32_kernel(
|
|
seed_ptr,
|
|
positions_ptr,
|
|
col_indices_ptr,
|
|
output_ptr,
|
|
num_rows,
|
|
num_cols,
|
|
BLOCK_SIZE: tl.constexpr,
|
|
):
|
|
"""
|
|
MurmurHash 32-bit implementation for Triton.
|
|
Reference:
|
|
- https://medium.com/@thealonemusk/murmurhash-the-scrappy-algorithm-that-secretly-powers-half-the-internet-2d3f79b4509b
|
|
- https://en.wikipedia.org/wiki/MurmurHash
|
|
|
|
We treat 64-bit seed, 32-bit position, and 32-bit col_index as 4 4-byte blocks, and bit-blend them together.
|
|
"""
|
|
pid_row = tl.program_id(0)
|
|
pid_col = tl.program_id(1)
|
|
|
|
row_idx = pid_row
|
|
col_offsets = pid_col * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)
|
|
mask = col_offsets < num_cols
|
|
|
|
# Load inputs
|
|
seed = tl.load(seed_ptr + row_idx).to(tl.uint64)
|
|
pos = tl.load(positions_ptr + row_idx).to(tl.uint32)
|
|
col = tl.load(col_indices_ptr + col_offsets, mask=mask, other=0).to(tl.uint32)
|
|
|
|
h: tl.uint32 = 0 # hash accumulator
|
|
|
|
# Process seed_low
|
|
k: tl.uint32 = (seed & 0xFFFFFFFF).to(tl.uint32)
|
|
h = murmur3_mix(h, k)
|
|
|
|
# Process seed_high
|
|
k = ((seed >> 32) & 0xFFFFFFFF).to(tl.uint32)
|
|
h = murmur3_mix(h, k)
|
|
|
|
# Process position block starting from seed32
|
|
h = murmur3_mix(h, pos)
|
|
|
|
# Process col block
|
|
h = murmur3_mix(h, col)
|
|
|
|
# Finalize (len=16 for seed + pos + col)
|
|
h ^= 16
|
|
h = fmix32(h)
|
|
|
|
# Store result as uint32
|
|
tl.store(output_ptr + row_idx * num_cols + col_offsets, h, mask=mask)
|
|
|
|
|
|
def murmur_hash32(seed, positions, col_indices):
|
|
assert (
|
|
seed.shape == positions.shape
|
|
), "Seed and positions must have the same shape (n,)"
|
|
assert (
|
|
len(seed.shape) == 1 and len(col_indices.shape) == 1
|
|
), f"Inputs must be 1D tensors {seed.shape=} {col_indices.shape=}"
|
|
n = seed.shape[0]
|
|
m = col_indices.shape[0]
|
|
device = seed.device
|
|
hashed = torch.empty((n, m), dtype=torch.uint32, device=device)
|
|
|
|
BLOCK_SIZE = 1024
|
|
grid = (n, triton.cdiv(m, BLOCK_SIZE))
|
|
murmur_hash32_kernel[grid](
|
|
seed, positions, col_indices, hashed, n, m, BLOCK_SIZE=BLOCK_SIZE
|
|
)
|
|
return hashed
|