interplane.Get Omega
Read in your language

ggml

[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)

Brought by drakestapleton

branch master Branches Tags History

ggml / src / ggml-opencl / kernels / moe_reorder_b.cl

32 lines · 872 bytes Raw Blame History
1#pragma OPENCL EXTENSION cl_khr_fp16 : enable
2
3#define QK4_0 32
4
5kernel void kernel_moe_reorder_b(
6 global float4 * src,
7 global uint * router,
8 global float4 * dst,
9 global int * total_tiles,
10 uint K,
11 ushort map_ratio,
12 uint tile_size
13) {
14 uint k_4 = get_global_id(0);
15 uint post_router_idx = get_global_id(1);
16
17 if ((k_4 >= (K / 4)) || (post_router_idx >= total_tiles[0] * tile_size)) {
18 return;
19 }
20
21 uint router_idx = router[post_router_idx];
22
23 // Padded slots need not be written at all. The MoE GEMMs accumulate per output
24 // column and scatter only the real columns, so whatever sits in a padded slot
25 // never reaches dst
26 if (router_idx == 0xFFFFFFFF) {
27 return;
28 }
29
30 ushort activation_idx = router_idx / map_ratio;
31 dst[post_router_idx * K / 4 + k_4] = src[activation_idx * K / 4 + k_4];
32}