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
414 lines
14 KiB
Plaintext
414 lines
14 KiB
Plaintext
// copied from
|
|
// https://github.com/vllm-project/vllm/blob/4492e3a55428e161ca8db381edc28263e5da4c8d/csrc/quantization/gguf/moe_vec.cuh
|
|
// copied and adapted from
|
|
// https://github.com/ggerganov/llama.cpp/blob/b2899/ggml-cuda/mmvq.cu
|
|
template <typename scalar_t, int qk, int qi, typename block_q_t, int vdr, vec_dot_q_cuda_t vec_dot_q_cuda>
|
|
static __global__ void moe_vec_q(
|
|
const void* __restrict__ vx,
|
|
const void* __restrict__ vy,
|
|
scalar_t* __restrict__ dst,
|
|
const int* topk_ids,
|
|
const int topk,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride) {
|
|
const auto row = blockIdx.x * blockDim.y + threadIdx.y;
|
|
|
|
const auto token = blockIdx.z / topk;
|
|
const auto expert = (topk_ids)[blockIdx.z];
|
|
|
|
if (row >= nrows) {
|
|
return;
|
|
}
|
|
|
|
const int blocks_per_row = ncols / qk;
|
|
const int blocks_per_warp = vdr * WARP_SIZE / qi;
|
|
|
|
// partial sum for each thread
|
|
float tmp = 0.0f;
|
|
|
|
const block_q_t* x = ((const block_q_t*)vx) + expert * nrows * blocks_per_row;
|
|
const block_q8_1* y = (const block_q8_1*)(((const int*)vy) + token * token_stride);
|
|
|
|
for (auto i = threadIdx.x / (qi / vdr); i < blocks_per_row; i += blocks_per_warp) {
|
|
const int ibx = row * blocks_per_row + i; // x block index
|
|
|
|
const int iby = i * (qk / QK8_1); // y block index that aligns with ibx
|
|
|
|
const int iqs = vdr * (threadIdx.x % (qi / vdr)); // x block quant index when casting the quants to int
|
|
|
|
tmp += vec_dot_q_cuda(&x[ibx], &y[iby], iqs);
|
|
}
|
|
|
|
// sum up partial sums and write back result
|
|
#pragma unroll
|
|
for (int mask = WARP_SIZE / 2; mask > 0; mask >>= 1) {
|
|
tmp += SGLANG_SHFL_XOR_SYNC(uint32_t(-1), tmp, mask);
|
|
}
|
|
|
|
if (threadIdx.x == 0) {
|
|
dst[blockIdx.z * nrows + row] = tmp;
|
|
}
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_q4_0_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK4_0, QI4_0, block_q4_0, VDR_Q4_0_Q8_1_MMVQ, vec_dot_q4_0_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_q4_1_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK4_0, QI4_1, block_q4_1, VDR_Q4_1_Q8_1_MMVQ, vec_dot_q4_1_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_q5_0_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK5_0, QI5_0, block_q5_0, VDR_Q5_0_Q8_1_MMVQ, vec_dot_q5_0_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_q5_1_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK5_1, QI5_1, block_q5_1, VDR_Q5_1_Q8_1_MMVQ, vec_dot_q5_1_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_q8_0_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK8_0, QI8_0, block_q8_0, VDR_Q8_0_Q8_1_MMVQ, vec_dot_q8_0_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_q2_K_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK_K, QI2_K, block_q2_K, VDR_Q2_K_Q8_1_MMVQ, vec_dot_q2_K_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_q3_K_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK_K, QI3_K, block_q3_K, VDR_Q3_K_Q8_1_MMVQ, vec_dot_q3_K_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_q4_K_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK_K, QI4_K, block_q4_K, VDR_Q4_K_Q8_1_MMVQ, vec_dot_q4_K_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_q5_K_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK_K, QI5_K, block_q5_K, VDR_Q5_K_Q8_1_MMVQ, vec_dot_q5_K_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_q6_K_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK_K, QI6_K, block_q6_K, VDR_Q6_K_Q8_1_MMVQ, vec_dot_q6_K_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_iq2_xxs_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK_K, QI2_XXS, block_iq2_xxs, 1, vec_dot_iq2_xxs_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_iq2_xs_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK_K, QI2_XS, block_iq2_xs, 1, vec_dot_iq2_xs_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_iq2_s_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK_K, QI2_S, block_iq2_s, 1, vec_dot_iq2_s_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_iq3_xxs_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK_K, QI3_XXS, block_iq3_xxs, 1, vec_dot_iq3_xxs_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_iq1_s_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK_K, QI1_S, block_iq1_s, 1, vec_dot_iq1_s_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_iq1_m_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK_K, QI1_M, block_iq1_m, 1, vec_dot_iq1_m_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_iq4_nl_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK4_NL, QI4_NL, block_iq4_nl, VDR_Q4_0_Q8_1_MMVQ, vec_dot_iq4_nl_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_iq4_xs_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK_K, QI4_XS, block_iq4_xs, 1, vec_dot_iq4_xs_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|
|
|
|
template <typename scalar_t>
|
|
static void moe_vec_iq3_s_q8_1_cuda(
|
|
const void* vx,
|
|
const void* vy,
|
|
scalar_t* dst,
|
|
const int* topk_ids,
|
|
const int top_k,
|
|
const int tokens,
|
|
const int ncols,
|
|
const int nrows,
|
|
const int token_stride,
|
|
cudaStream_t stream) {
|
|
const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
|
|
const dim3 block_nums(block_num_y, 1, tokens * top_k);
|
|
const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
|
|
moe_vec_q<scalar_t, QK_K, QI3_XS, block_iq3_s, 1, vec_dot_iq3_s_q8_1>
|
|
<<<block_nums, block_dims, 0, stream>>>(vx, vy, dst, topk_ids, top_k, ncols, nrows, token_stride);
|
|
}
|