AXPY kernels for FP32: y = y + alpha * x. More...
#include <stdint.h>#include <stddef.h>#include <stdatomic.h>#include <string.h>#include <stdio.h>#include <stdlib.h>#include <math.h>#include "ckernel_engine.h"#include "ckernel_dtype.h"#include "ck_threadpool.h"#include "bf16_utils.h"Go to the source code of this file.
Typedefs | |
| typedef int(* | ck_moe_expert_workspace_fn) (const float *, const int *, const float *, const void *, const void *, const void *, float *, int, int, int, int, int, void *, size_t) |
| typedef int(* | ck_moe_shared_gated_workspace_fn) (const float *, const float *, const void *, const void *, const void *, const float *, float *, int, int, int, void *, size_t) |
| typedef int(* | ck_moe_shared_workspace_fn) (const float *, const float *, const void *, const void *, const void *, float *, int, int, int, void *, size_t) |
Enumerations | |
| enum | { CK_MOE_Q4K_Q5K_TASK_ROWS = 16 } |
| enum | ck_moe_down_kind_t { CK_MOE_DOWN_Q4_K , CK_MOE_DOWN_Q6_K , CK_MOE_DOWN_Q5_0 , CK_MOE_DOWN_Q8_0 } |
Functions | |
| void | axpy_2d_f32 (float *Y, const float *X, float alpha, int num_tokens, int dim, int y_stride, int x_stride) |
| Batched AXPY for 2D tensors: Y[t,:] += alpha * X[t,:]. | |
| void | axpy_f32 (float *y, const float *x, float alpha, int n) |
| In-place AXPY: y += alpha * x. | |
| void | axpy_zero_f32 (float *y, const float *x, float alpha, int n) |
| Zero output then accumulate: y = 0; y += alpha * x. | |
| static size_t | ck_moe_align64 (size_t value) |
| static float | ck_moe_bf16_round (float x) |
| static int | ck_moe_bucket_expert_for_position (const int *offsets, int n_experts, int position) |
| static int | ck_moe_bucket_layout (int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k, ck_moe_q4k_q5k_bucket_layout_t *layout) |
| static int | ck_moe_debug_enabled (void) |
| static void | ck_moe_debug_finite (const char *name, const float *x, size_t n) |
| static size_t | ck_moe_down_idx (int e, int h, int i, int hidden_dim, int intermediate_dim) |
| static float | ck_moe_dsilu_f32 (float x) |
| static void | ck_moe_llama_weighted_accumulate (float *output, const float *expert_output, float route_weight, int n) |
| static void | ck_moe_q4k_llama_projection (float *output, const void *weights, const void *input_q8, int output_dim, int input_dim, void *scratch) |
| static size_t | ck_moe_q4k_llama_projection_scratch_bytes (int output_dim, int input_dim) |
| static void | ck_moe_q4k_mixed_parallel_work (int ith, int nth, void *opaque) |
| static int | ck_moe_q4k_mixed_parallel_workspace (const float *hidden, const int *indices, const float *routing_weights, const void *expert_gate, const void *expert_up, const void *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k, void *workspace, size_t workspace_bytes, ck_moe_expert_workspace_fn serial_fn, ck_moe_down_kind_t down_kind) |
| static int | ck_moe_q4k_mixed_route_parallel (const float *hidden, const int *indices, const float *routing_weights, const void *expert_gate, const void *expert_up, const void *expert_down, float *output, int hidden_dim, int intermediate_dim, int n_experts, int top_k, void *workspace, size_t workspace_bytes, size_t workspace_stride, ck_threadpool_t *pool, ck_moe_down_kind_t down_kind) |
| static void | ck_moe_q4k_mixed_route_work (int ith, int nth, void *opaque) |
| static void | ck_moe_q4k_q5k_bucket_work (int ith, int nth, void *opaque) |
| static void | ck_moe_q4k_q5k_parallel_work (int ith, int nth, void *opaque) |
| static void | ck_moe_q4k_q5k_quantize_work (int ith, int nth, void *opaque) |
| static int | ck_moe_q4k_q5k_route_parallel (const float *hidden, const int *indices, const float *routing_weights, const void *expert_gate, const void *expert_up, const void *expert_down, float *output, int hidden_dim, int intermediate_dim, int n_experts, int top_k, void *workspace, size_t workspace_bytes, size_t workspace_stride, ck_threadpool_t *pool) |
| static void | ck_moe_q4k_q5k_route_work (int ith, int nth, void *opaque) |
| static int | ck_moe_shared_gated_parallel_workspace (const float *hidden, const float *routed, const void *shared_gate, const void *shared_up, const void *shared_down, const float *shared_gate_input, float *output, int rows, int hidden_dim, int intermediate_dim, void *workspace, size_t workspace_bytes, size_t stride, ck_moe_shared_gated_workspace_fn serial_fn) |
| static int | ck_moe_shared_q4k_gated_workspace (const float *hidden, const float *routed, const void *shared_gate, const void *shared_up, const void *shared_down, const float *shared_gate_input, float *output, int rows, int hidden_dim, int intermediate_dim, void *workspace, size_t workspace_bytes, void(*down_projection)(float *, const void *, const void *, int, int)) |
| static void | ck_moe_shared_q4k_parallel_work (int ith, int nth, void *opaque) |
| static int | ck_moe_shared_q4k_parallel_workspace (const float *hidden, const float *routed, const void *shared_gate, const void *shared_up, const void *shared_down, float *output, int rows, int hidden_dim, int intermediate_dim, void *workspace, size_t workspace_bytes, ck_moe_shared_workspace_fn serial_fn) |
| static void | ck_moe_shared_q8_0_parallel_work (int ith, int nth, void *opaque) |
| static float | ck_moe_sigmoid_f32 (float x) |
| static float | ck_moe_silu_f32 (float x) |
| static int | ck_moe_size_add (size_t a, size_t b, size_t *result) |
| static int | ck_moe_size_mul (size_t a, size_t b, size_t *result) |
| static int | ck_moe_swiglu_expert_forward_q4k_q5k_bucketed_impl (const float *hidden, const int *indices, const float *routing_weights, const void *expert_gate, const void *expert_up, const void *expert_down, const void *expert_gate_packed, const void *expert_up_packed, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k, void *workspace, size_t workspace_bytes) |
| static size_t | ck_moe_up_idx (int e, int i, int h, int intermediate_dim, int hidden_dim) |
| void | farskip_swiglu_shared_combine_bf16 (const float *hidden, const float *routed, const float *post_attn_residual, const uint16_t *shared_gate, const uint16_t *shared_up, const uint16_t *shared_down, float *main_output, float *routed_free_output, int rows, int hidden_dim, int intermediate_dim) |
| void | farskip_swiglu_shared_combine_bf16_row_range (const float *hidden, const float *routed, const float *post_attn_residual, const uint16_t *shared_gate, const uint16_t *shared_up, const uint16_t *shared_down, float *main_output, float *routed_free_output, int rows, int hidden_dim, int intermediate_dim, int row_begin, int row_end) |
| void | gemm_nt_q4_k_packed_meta_x8_q8_k_gemv_order (const void *input, const void *packed_weight, const float *bias, float *output, int rows, int output_dim, int input_dim) |
| void | gemm_nt_q4_k_q8_k_pairwise_split_min_parallel_dispatch (const void *input, const void *weight, const float *bias, float *output, int rows, int output_dim, int input_dim) |
| void | gemm_q4_k_q8_k_compact_rows4 (float *output, int output_stride, const void *weights, const void *const input_rows[4], int rows, int output_dim, int input_dim) |
| void | gemm_q4_k_q8_k_packed_vnni_x8_compact_order_rows4 (float *output, const void *weights_packed, const void *input_q8, int rows, int output_dim, int input_dim) |
| void | gemm_q5_k_q8_k_compact_rows4 (float *output, int output_stride, const void *weights, const void *const input_rows[4], int rows, int output_dim, int input_dim) |
| void | moe_accumulate_expert_f32 (float *output, const float *expert_output, float routing_weight, int hidden_dim) |
| Accumulate expert output: output += routing_weight * expert_output. | |
| void | moe_relu2_expert_backward_f32 (const float *d_output, const float *hidden, const int *indices, const float *routing_weights, const float *expert_up, const float *expert_down, float *d_hidden, float *d_routing_weights, float *d_expert_up, float *d_expert_down, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k) |
| void | moe_relu2_expert_forward_f32 (const float *hidden, const int *indices, const float *routing_weights, const float *expert_up, const float *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k) |
| void | moe_relu2_expert_forward_q5_0_q5_0 (const float *hidden, const int *indices, const float *routing_weights, const void *expert_up, const void *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k) |
| void | moe_relu2_expert_forward_q5_0_q8_0 (const float *hidden, const int *indices, const float *routing_weights, const void *expert_up, const void *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k) |
| void | moe_relu2_shared_forward_q5_1_q8_0 (const float *hidden, const float *routed, const void *shared_up, const void *shared_down, float *output, int rows, int hidden_dim, int intermediate_dim) |
| void | moe_swiglu_expert_backward_f32 (const float *d_output, const float *hidden, const int *indices, const float *routing_weights, const float *expert_gate, const float *expert_up, const float *expert_down, float *d_hidden, float *d_routing_weights, float *d_expert_gate, float *d_expert_up, float *d_expert_down, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k) |
| void | moe_swiglu_expert_forward_bf16 (const float *hidden, const int *indices, const float *routing_weights, const uint16_t *expert_gate, const uint16_t *expert_up, const uint16_t *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k) |
| void | moe_swiglu_expert_forward_bf16_row_range (const float *hidden, const int *indices, const float *routing_weights, const uint16_t *expert_gate, const uint16_t *expert_up, const uint16_t *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k, int row_begin, int row_end) |
| void | moe_swiglu_expert_forward_f32 (const float *hidden, const int *indices, const float *routing_weights, const float *expert_gate, const float *expert_up, const float *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k) |
| int | moe_swiglu_expert_forward_q4k_q4k_parallel_workspace (const float *hidden, const int *indices, const float *routing_weights, const void *expert_gate, const void *expert_up, const void *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_expert_forward_q4k_q4k_workspace (const float *hidden, const int *indices, const float *routing_weights, const void *expert_gate, const void *expert_up, const void *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_expert_forward_q4k_q5_0_parallel_workspace (const float *hidden, const int *indices, const float *routing_weights, const void *expert_gate, const void *expert_up, const void *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_expert_forward_q4k_q5_0_workspace (const float *hidden, const int *indices, const float *routing_weights, const void *expert_gate, const void *expert_up, const void *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_expert_forward_q4k_q5k_auto_workspace (const float *hidden, const int *indices, const float *routing_weights, const void *expert_gate, const void *expert_up, const void *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_expert_forward_q4k_q5k_bucketed_prepared_workspace (const float *hidden, const int *indices, const float *routing_weights, const void *expert_gate, const void *expert_up, const void *expert_down, const void *expert_gate_packed, const void *expert_up_packed, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_expert_forward_q4k_q5k_bucketed_workspace (const float *hidden, const int *indices, const float *routing_weights, const void *expert_gate, const void *expert_up, const void *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_expert_forward_q4k_q5k_parallel_workspace (const float *hidden, const int *indices, const float *routing_weights, const void *expert_gate, const void *expert_up, const void *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_expert_forward_q4k_q5k_workspace (const float *hidden, const int *indices, const float *routing_weights, const void *expert_gate, const void *expert_up, const void *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_expert_forward_q4k_q6k_parallel_workspace (const float *hidden, const int *indices, const float *routing_weights, const void *expert_gate, const void *expert_up, const void *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_expert_forward_q4k_q6k_workspace (const float *hidden, const int *indices, const float *routing_weights, const void *expert_gate, const void *expert_up, const void *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_expert_forward_q4k_q8_0_parallel_workspace (const float *hidden, const int *indices, const float *routing_weights, const void *expert_gate, const void *expert_up, const void *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_expert_forward_q4k_q8_0_workspace (const float *hidden, const int *indices, const float *routing_weights, const void *expert_gate, const void *expert_up, const void *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k, void *workspace, size_t workspace_bytes) |
| size_t | moe_swiglu_expert_q4k_q5k_bucketed_workspace_bytes (int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k) |
| size_t | moe_swiglu_expert_q4k_q5k_workspace_bytes (int hidden_dim, int intermediate_dim) |
| size_t | moe_swiglu_expert_q4k_q8_0_workspace_bytes (int hidden_dim, int intermediate_dim) |
| void | moe_swiglu_packed_expert_forward_bf16 (const float *hidden, const int *indices, const float *routing_weights, const uint16_t *expert_gate_up, const uint16_t *expert_down, float *output, int rows, int hidden_dim, int intermediate_dim, int n_experts, int top_k) |
| void | moe_swiglu_shared_backward_f32 (const float *d_output, const float *hidden, const float *shared_gate, const float *shared_up, const float *shared_down, float *d_hidden, float *d_routed, float *d_shared_gate, float *d_shared_up, float *d_shared_down, int rows, int hidden_dim, int intermediate_dim) |
| void | moe_swiglu_shared_forward_bf16 (const float *hidden, const float *routed, const uint16_t *shared_gate, const uint16_t *shared_up, const uint16_t *shared_down, float *output, int rows, int hidden_dim, int intermediate_dim) |
| void | moe_swiglu_shared_forward_bf16_gated (const float *hidden, const float *routed, const uint16_t *shared_gate, const uint16_t *shared_up, const uint16_t *shared_down, const uint16_t *shared_router, float *output, int rows, int hidden_dim, int intermediate_dim) |
| void | moe_swiglu_shared_forward_bf16_gated_row_range (const float *hidden, const float *routed, const uint16_t *shared_gate, const uint16_t *shared_up, const uint16_t *shared_down, const uint16_t *shared_router, float *output, int rows, int hidden_dim, int intermediate_dim, int row_begin, int row_end) |
| void | moe_swiglu_shared_forward_bf16_row_range (const float *hidden, const float *routed, const uint16_t *shared_gate, const uint16_t *shared_up, const uint16_t *shared_down, float *output, int rows, int hidden_dim, int intermediate_dim, int row_begin, int row_end) |
| void | moe_swiglu_shared_forward_f32 (const float *hidden, const float *routed, const float *shared_gate, const float *shared_up, const float *shared_down, float *output, int rows, int hidden_dim, int intermediate_dim) |
| int | moe_swiglu_shared_forward_q4k_q4k_parallel_workspace (const float *hidden, const float *routed, const void *shared_gate, const void *shared_up, const void *shared_down, float *output, int rows, int hidden_dim, int intermediate_dim, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_shared_forward_q4k_q4k_workspace (const float *hidden, const float *routed, const void *shared_gate, const void *shared_up, const void *shared_down, float *output, int rows, int hidden_dim, int intermediate_dim, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_shared_forward_q4k_q5_0_gated_parallel_workspace (const float *hidden, const float *routed, const void *shared_gate, const void *shared_up, const void *shared_down, const float *shared_gate_input, float *output, int rows, int hidden_dim, int intermediate_dim, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_shared_forward_q4k_q5_0_gated_workspace (const float *hidden, const float *routed, const void *shared_gate, const void *shared_up, const void *shared_down, const float *shared_gate_input, float *output, int rows, int hidden_dim, int intermediate_dim, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_shared_forward_q4k_q6k_parallel_workspace (const float *hidden, const float *routed, const void *shared_gate, const void *shared_up, const void *shared_down, float *output, int rows, int hidden_dim, int intermediate_dim, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_shared_forward_q4k_q6k_workspace (const float *hidden, const float *routed, const void *shared_gate, const void *shared_up, const void *shared_down, float *output, int rows, int hidden_dim, int intermediate_dim, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_shared_forward_q4k_q8_0_gated_parallel_workspace (const float *hidden, const float *routed, const void *shared_gate, const void *shared_up, const void *shared_down, const float *shared_gate_input, float *output, int rows, int hidden_dim, int intermediate_dim, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_shared_forward_q4k_q8_0_gated_workspace (const float *hidden, const float *routed, const void *shared_gate, const void *shared_up, const void *shared_down, const float *shared_gate_input, float *output, int rows, int hidden_dim, int intermediate_dim, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_shared_forward_q8_0_gated_parallel_workspace (const float *hidden, const float *routed, const void *shared_gate, const void *shared_up, const void *shared_down, const float *shared_gate_input, float *output, int rows, int hidden_dim, int intermediate_dim, void *workspace, size_t workspace_bytes) |
| int | moe_swiglu_shared_forward_q8_0_gated_workspace (const float *hidden, const float *routed, const void *shared_gate, const void *shared_up, const void *shared_down, const float *shared_gate_input, float *output, int rows, int hidden_dim, int intermediate_dim, void *workspace, size_t workspace_bytes) |
| size_t | moe_swiglu_shared_q4k_q8_0_gated_workspace_bytes (int hidden_dim, int intermediate_dim) |
| size_t | moe_swiglu_shared_q8_0_gated_workspace_bytes (int hidden_dim, int intermediate_dim) |
| void | pack_q4_k_to_packed_meta_x8 (const void *source, void *destination, int output_dim, int input_dim) |
| size_t | q4_k_packed_meta_x8_block_size (void) |
| size_t | q4_k_packed_vnni_x8_block_size (void) |
| void | scal_copy_f32 (float *y, const float *x, float alpha, int n) |
| Scaled copy: y = alpha * x. | |
| void | weighted_sum_f32 (float *y, const float **vectors, const float *weights, int k, int n) |
| Weighted sum of k vectors: y = sum_i(weights[i] * vectors[i]) | |
AXPY kernels for FP32: y = y + alpha * x.
After changes: make test && make llamacpp-parity-full
Classic BLAS Level-1 operation used in MoE expert output accumulation. When gathering expert outputs: output += weight[i] * expert_output[i]
Operations:
Definition in file axpy_kernels.c.
| typedef int(* ck_moe_expert_workspace_fn) (const float *, const int *, const float *, const void *, const void *, const void *, float *, int, int, int, int, int, void *, size_t) |
Definition at line 1541 of file axpy_kernels.c.
| typedef int(* ck_moe_shared_gated_workspace_fn) (const float *, const float *, const void *, const void *, const void *, const float *, float *, int, int, int, void *, size_t) |
Definition at line 2848 of file axpy_kernels.c.
| typedef int(* ck_moe_shared_workspace_fn) (const float *, const float *, const void *, const void *, const void *, float *, int, int, int, void *, size_t) |
Definition at line 1950 of file axpy_kernels.c.
| anonymous enum |
| Enumerator | |
|---|---|
| CK_MOE_Q4K_Q5K_TASK_ROWS | |
Definition at line 2265 of file axpy_kernels.c.
| enum ck_moe_down_kind_t |
| Enumerator | |
|---|---|
| CK_MOE_DOWN_Q4_K | |
| CK_MOE_DOWN_Q6_K | |
| CK_MOE_DOWN_Q5_0 | |
| CK_MOE_DOWN_Q8_0 | |
Definition at line 1545 of file axpy_kernels.c.
| void axpy_2d_f32 | ( | float * | Y, |
| const float * | X, | ||
| float | alpha, | ||
| int | num_tokens, | ||
| int | dim, | ||
| int | y_stride, | ||
| int | x_stride | ||
| ) |
Batched AXPY for 2D tensors: Y[t,:] += alpha * X[t,:].
| Y | Output tensor [num_tokens, dim] |
| X | Input tensor [num_tokens, dim] |
| alpha | Scalar multiplier |
| num_tokens | Number of tokens |
| dim | Hidden dimension |
| y_stride | Stride between Y rows (for alignment) |
| x_stride | Stride between X rows |
Definition at line 272 of file axpy_kernels.c.
References axpy_f32().
| void axpy_f32 | ( | float * | y, |
| const float * | x, | ||
| float | alpha, | ||
| int | n | ||
| ) |
In-place AXPY: y += alpha * x.
test_axpy.py::TestAXPY::test_axpy_f32
test_axpy.py::TestAXPY::test_axpy_vs_naive
In-place scaled vector addition: y += alpha * x BLAS-like axpy operation.
After changes: make test
Definition at line 105 of file axpy_kernels.c.
Referenced by axpy_2d_f32(), axpy_zero_f32(), ck_moe_q4k_mixed_route_parallel(), ck_moe_q4k_q5k_bucket_work(), ck_moe_q4k_q5k_route_parallel(), moe_accumulate_expert_f32(), moe_swiglu_expert_forward_q4k_q4k_workspace(), moe_swiglu_expert_forward_q4k_q5k_workspace(), moe_swiglu_expert_forward_q4k_q6k_workspace(), and weighted_sum_f32().
| void axpy_zero_f32 | ( | float * | y, |
| const float * | x, | ||
| float | alpha, | ||
| int | n | ||
| ) |
Zero output then accumulate: y = 0; y += alpha * x.
| y | Output vector [n], zeroed then accumulated |
| x | Input vector [n] |
| alpha | Scalar multiplier |
| n | Vector length |
Definition at line 239 of file axpy_kernels.c.
References axpy_f32().
|
static |
Definition at line 672 of file axpy_kernels.c.
Referenced by ck_moe_bucket_layout(), ck_moe_q4k_llama_projection_scratch_bytes(), ck_moe_q4k_mixed_route_parallel(), ck_moe_q4k_mixed_route_work(), ck_moe_q4k_q5k_bucket_work(), ck_moe_q4k_q5k_route_parallel(), ck_moe_q4k_q5k_route_work(), ck_moe_shared_q4k_gated_workspace(), moe_swiglu_expert_forward_q4k_q4k_workspace(), moe_swiglu_expert_forward_q4k_q5_0_workspace(), moe_swiglu_expert_forward_q4k_q5k_workspace(), moe_swiglu_expert_forward_q4k_q6k_workspace(), moe_swiglu_expert_forward_q4k_q8_0_workspace(), moe_swiglu_expert_q4k_q5k_workspace_bytes(), moe_swiglu_expert_q4k_q8_0_workspace_bytes(), moe_swiglu_shared_forward_q4k_q4k_workspace(), moe_swiglu_shared_forward_q4k_q6k_workspace(), moe_swiglu_shared_forward_q8_0_gated_workspace(), moe_swiglu_shared_q4k_q8_0_gated_workspace_bytes(), and moe_swiglu_shared_q8_0_gated_workspace_bytes().
|
inlinestatic |
Definition at line 439 of file axpy_kernels.c.
References bf16_to_float(), and float_to_bf16().
Referenced by moe_swiglu_packed_expert_forward_bf16(), and moe_swiglu_shared_forward_bf16_gated_row_range().
|
static |
Definition at line 2267 of file axpy_kernels.c.
References offsets.
Referenced by ck_moe_q4k_q5k_bucket_work().
|
static |
Definition at line 2116 of file axpy_kernels.c.
References CK_DT_Q8_K, ck_dtype_row_bytes(), ck_moe_align64(), ck_moe_size_add(), ck_moe_size_mul(), and CK_THREADPOOL_MAX_THREADS.
Referenced by ck_moe_swiglu_expert_forward_q4k_q5k_bucketed_impl(), and moe_swiglu_expert_q4k_q5k_bucketed_workspace_bytes().
|
static |
Definition at line 333 of file axpy_kernels.c.
Referenced by ck_moe_debug_finite(), moe_relu2_expert_forward_q5_0_q5_0(), moe_relu2_expert_forward_q5_0_q8_0(), and moe_relu2_shared_forward_q5_1_q8_0().
|
static |
Definition at line 339 of file axpy_kernels.c.
References ck_moe_debug_enabled().
Referenced by moe_relu2_expert_forward_q5_0_q5_0(), moe_relu2_expert_forward_q5_0_q8_0(), and moe_relu2_shared_forward_q5_1_q8_0().
|
inlinestatic |
Definition at line 328 of file axpy_kernels.c.
Referenced by moe_relu2_expert_backward_f32(), moe_relu2_expert_forward_f32(), moe_swiglu_expert_backward_f32(), moe_swiglu_expert_forward_bf16_row_range(), moe_swiglu_expert_forward_f32(), and moe_swiglu_packed_expert_forward_bf16().
|
inlinestatic |
Definition at line 444 of file axpy_kernels.c.
References ck_moe_sigmoid_f32().
Referenced by moe_swiglu_expert_backward_f32(), and moe_swiglu_shared_backward_f32().
|
static |
Definition at line 718 of file axpy_kernels.c.
Referenced by ck_moe_q4k_mixed_route_parallel(), moe_swiglu_expert_forward_q4k_q5_0_workspace(), and moe_swiglu_expert_forward_q4k_q8_0_workspace().
|
static |
Definition at line 695 of file axpy_kernels.c.
References gemm_nt_q4_k_packed_meta_x8_q8_k_gemv_order(), gemv_q4_k_q8_k(), and pack_q4_k_to_packed_meta_x8().
Referenced by ck_moe_q4k_mixed_route_work(), moe_swiglu_expert_forward_q4k_q5_0_workspace(), and moe_swiglu_expert_forward_q4k_q8_0_workspace().
|
static |
Definition at line 677 of file axpy_kernels.c.
References ck_moe_align64(), and q4_k_packed_meta_x8_block_size().
Referenced by moe_swiglu_expert_q4k_q8_0_workspace_bytes().
|
static |
Definition at line 1571 of file axpy_kernels.c.
References end.
Referenced by ck_moe_q4k_mixed_parallel_workspace().
|
static |
Definition at line 1781 of file axpy_kernels.c.
References CK_MOE_DOWN_Q5_0, CK_MOE_DOWN_Q8_0, ck_moe_q4k_mixed_parallel_work(), ck_moe_q4k_mixed_route_parallel(), ck_threadpool_dispatch_n(), ck_threadpool_global(), CK_THREADPOOL_MAX_THREADS, ck_threadpool_n_threads(), moe_swiglu_expert_q4k_q5k_workspace_bytes(), and moe_swiglu_expert_q4k_q8_0_workspace_bytes().
Referenced by moe_swiglu_expert_forward_q4k_q4k_parallel_workspace(), moe_swiglu_expert_forward_q4k_q5_0_parallel_workspace(), moe_swiglu_expert_forward_q4k_q6k_parallel_workspace(), and moe_swiglu_expert_forward_q4k_q8_0_parallel_workspace().
|
static |
Definition at line 1713 of file axpy_kernels.c.
References axpy_f32(), CK_DT_Q8_K, ck_dtype_row_bytes(), ck_moe_align64(), CK_MOE_DOWN_Q5_0, CK_MOE_DOWN_Q8_0, ck_moe_llama_weighted_accumulate(), ck_moe_q4k_mixed_route_work(), ck_threadpool_dispatch_n(), CK_THREADPOOL_MAX_THREADS, ck_threadpool_n_threads(), and quantize_row_q8_k().
Referenced by ck_moe_q4k_mixed_parallel_workspace().
|
static |
Definition at line 1616 of file axpy_kernels.c.
References CK_DT_Q4_K, CK_DT_Q5_0, CK_DT_Q6_K, CK_DT_Q8_0, CK_DT_Q8_K, ck_dtype_row_bytes(), ck_moe_align64(), CK_MOE_DOWN_Q5_0, CK_MOE_DOWN_Q6_K, CK_MOE_DOWN_Q8_0, ck_moe_q4k_llama_projection(), gemv_q4_k_q8_k(), gemv_q5_0_q8_0(), gemv_q6_k_q8_k(), gemv_q8_0_q8_0(), quantize_row_q8_0(), quantize_row_q8_k(), and swiglu_forward_ggml().
Referenced by ck_moe_q4k_mixed_route_parallel().
|
static |
Definition at line 2284 of file axpy_kernels.c.
References axpy_f32(), CK_DT_Q8_K, ck_dtype_row_bytes(), ck_moe_align64(), ck_moe_bucket_expert_for_position(), CK_MOE_Q4K_Q5K_TASK_ROWS, gemm_q4_k_q8_k_compact_rows4(), gemm_q4_k_q8_k_packed_vnni_x8_compact_order_rows4(), gemm_q5_k_q8_k_compact_rows4(), quantize_row_q8_k(), swiglu_forward_ggml(), and swiglu_forward_ggml_split().
Referenced by ck_moe_swiglu_expert_forward_q4k_q5k_bucketed_impl().
|
static |
Definition at line 1317 of file axpy_kernels.c.
References end, and moe_swiglu_expert_forward_q4k_q5k_workspace().
Referenced by moe_swiglu_expert_forward_q4k_q5k_parallel_workspace().
|
static |
Definition at line 2225 of file axpy_kernels.c.
References end, and quantize_row_q8_k().
Referenced by ck_moe_swiglu_expert_forward_q4k_q5k_bucketed_impl().
|
static |
Definition at line 1412 of file axpy_kernels.c.
References axpy_f32(), CK_DT_Q8_K, ck_dtype_row_bytes(), ck_moe_align64(), ck_moe_q4k_q5k_route_work(), ck_threadpool_dispatch_n(), CK_THREADPOOL_MAX_THREADS, ck_threadpool_n_threads(), and quantize_row_q8_k().
Referenced by moe_swiglu_expert_forward_q4k_q5k_parallel_workspace().
|
static |
Definition at line 1361 of file axpy_kernels.c.
References CK_DT_Q4_K, CK_DT_Q5_K, CK_DT_Q8_K, ck_dtype_row_bytes(), ck_moe_align64(), gemv_q4_k_q8_k(), gemv_q5_k_q8_k(), quantize_row_q8_k(), and swiglu_forward_ggml().
Referenced by ck_moe_q4k_q5k_route_parallel().
|
static |
Definition at line 2897 of file axpy_kernels.c.
References ck_moe_shared_q8_0_parallel_work(), ck_threadpool_dispatch_n(), ck_threadpool_global(), CK_THREADPOOL_MAX_THREADS, and ck_threadpool_n_threads().
Referenced by moe_swiglu_shared_forward_q8_0_gated_parallel_workspace().
|
static |
Definition at line 2709 of file axpy_kernels.c.
References CK_DT_Q8_0, CK_DT_Q8_K, ck_dtype_row_bytes(), ck_moe_align64(), gemm_nt_f32_llama_production(), gemm_nt_q4_k_q8_k_pairwise_split_min_parallel_dispatch(), moe_swiglu_shared_q4k_q8_0_gated_workspace_bytes(), quantize_row_q8_0(), quantize_row_q8_k(), and swiglu_forward_ggml_split().
Referenced by moe_swiglu_shared_forward_q4k_q5_0_gated_workspace(), and moe_swiglu_shared_forward_q4k_q8_0_gated_workspace().
|
static |
Definition at line 1970 of file axpy_kernels.c.
References end.
Referenced by ck_moe_shared_q4k_parallel_workspace().
|
static |
Definition at line 1996 of file axpy_kernels.c.
References ck_moe_shared_q4k_parallel_work(), ck_threadpool_dispatch_n(), ck_threadpool_global(), CK_THREADPOOL_MAX_THREADS, ck_threadpool_n_threads(), and moe_swiglu_expert_q4k_q5k_workspace_bytes().
Referenced by moe_swiglu_shared_forward_q4k_q4k_parallel_workspace(), and moe_swiglu_shared_forward_q4k_q6k_parallel_workspace().
|
static |
Definition at line 2869 of file axpy_kernels.c.
References end.
Referenced by ck_moe_shared_gated_parallel_workspace().
|
inlinestatic |
Definition at line 429 of file axpy_kernels.c.
Referenced by ck_moe_dsilu_f32(), ck_moe_silu_f32(), and moe_swiglu_shared_forward_bf16_gated_row_range().
|
inlinestatic |
Definition at line 434 of file axpy_kernels.c.
References ck_moe_sigmoid_f32().
Referenced by farskip_swiglu_shared_combine_bf16_row_range(), moe_swiglu_expert_backward_f32(), moe_swiglu_expert_forward_bf16_row_range(), moe_swiglu_expert_forward_f32(), moe_swiglu_shared_backward_f32(), moe_swiglu_shared_forward_bf16_gated_row_range(), moe_swiglu_shared_forward_bf16_row_range(), and moe_swiglu_shared_forward_f32().
|
static |
Definition at line 2102 of file axpy_kernels.c.
Referenced by ck_moe_bucket_layout().
|
static |
Definition at line 2109 of file axpy_kernels.c.
Referenced by ck_moe_bucket_layout().
|
static |
Definition at line 2419 of file axpy_kernels.c.
References CK_DT_Q4_K, CK_DT_Q5_K, ck_dtype_row_bytes(), ck_moe_bucket_layout(), ck_moe_q4k_q5k_bucket_work(), ck_moe_q4k_q5k_quantize_work(), CK_MOE_Q4K_Q5K_TASK_ROWS, ck_threadpool_dispatch_n(), ck_threadpool_global(), CK_THREADPOOL_MAX_THREADS, ck_threadpool_n_threads(), offsets, and q4_k_packed_vnni_x8_block_size().
Referenced by moe_swiglu_expert_forward_q4k_q5k_bucketed_prepared_workspace(), and moe_swiglu_expert_forward_q4k_q5k_bucketed_workspace().
|
inlinestatic |
Definition at line 323 of file axpy_kernels.c.
Referenced by moe_relu2_expert_backward_f32(), moe_relu2_expert_forward_f32(), moe_swiglu_expert_backward_f32(), moe_swiglu_expert_forward_bf16_row_range(), and moe_swiglu_expert_forward_f32().
| void farskip_swiglu_shared_combine_bf16 | ( | const float * | hidden, |
| const float * | routed, | ||
| const float * | post_attn_residual, | ||
| const uint16_t * | shared_gate, | ||
| const uint16_t * | shared_up, | ||
| const uint16_t * | shared_down, | ||
| float * | main_output, | ||
| float * | routed_free_output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim | ||
| ) |
Definition at line 3381 of file axpy_kernels.c.
References farskip_swiglu_shared_combine_bf16_row_range().
| void farskip_swiglu_shared_combine_bf16_row_range | ( | const float * | hidden, |
| const float * | routed, | ||
| const float * | post_attn_residual, | ||
| const uint16_t * | shared_gate, | ||
| const uint16_t * | shared_up, | ||
| const uint16_t * | shared_down, | ||
| float * | main_output, | ||
| float * | routed_free_output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | row_begin, | ||
| int | row_end | ||
| ) |
Definition at line 3328 of file axpy_kernels.c.
References bf16_to_float(), ck_moe_silu_f32(), and main().
Referenced by farskip_swiglu_shared_combine_bf16().
| void gemm_nt_q4_k_packed_meta_x8_q8_k_gemv_order | ( | const void * | input, |
| const void * | packed_weight, | ||
| const float * | bias, | ||
| float * | output, | ||
| int | rows, | ||
| int | output_dim, | ||
| int | input_dim | ||
| ) |
Definition at line 2055 of file gemm_kernels_q4k_q8k_vnni.c.
References accum_q4_k_packed_meta_x8_q8_k_gemv_block(), C, and QK_K.
Referenced by ck_moe_q4k_llama_projection().
| void gemm_nt_q4_k_q8_k_pairwise_split_min_parallel_dispatch | ( | const void * | input, |
| const void * | weight, | ||
| const float * | bias, | ||
| float * | output, | ||
| int | rows, | ||
| int | output_dim, | ||
| int | input_dim | ||
| ) |
Referenced by ck_moe_shared_q4k_gated_workspace().
| void gemm_q4_k_q8_k_compact_rows4 | ( | float * | output, |
| int | output_stride, | ||
| const void * | weights, | ||
| const void *const | input_rows[4], | ||
| int | rows, | ||
| int | output_dim, | ||
| int | input_dim | ||
| ) |
Definition at line 3615 of file gemm_kernels_q4k_q8k_vnni.c.
References gemv_q4_k_q8_k(), and QK_K.
Referenced by ck_moe_q4k_q5k_bucket_work().
| void gemm_q4_k_q8_k_packed_vnni_x8_compact_order_rows4 | ( | float * | output, |
| const void * | weights_packed, | ||
| const void * | input_q8, | ||
| int | rows, | ||
| int | output_dim, | ||
| int | input_dim | ||
| ) |
Definition at line 1123 of file gemm_kernels_q4k_q8k_vnni.c.
References dot_q4_k_packed_vnni_x8_q8_k_compact_order(), and QK_K.
Referenced by ck_moe_q4k_q5k_bucket_work().
| void gemm_q5_k_q8_k_compact_rows4 | ( | float * | output, |
| int | output_stride, | ||
| const void * | weights, | ||
| const void *const | input_rows[4], | ||
| int | rows, | ||
| int | output_dim, | ||
| int | input_dim | ||
| ) |
Definition at line 937 of file gemm_kernels_q5_k.c.
References gemv_q5_k_q8_k(), and QK_K.
Referenced by ck_moe_q4k_q5k_bucket_work().
| void moe_accumulate_expert_f32 | ( | float * | output, |
| const float * | expert_output, | ||
| float | routing_weight, | ||
| int | hidden_dim | ||
| ) |
Accumulate expert output: output += routing_weight * expert_output.
| output | Token output buffer [hidden_dim], accumulated in place |
| expert_output | Expert's output for this token [hidden_dim] |
| routing_weight | Softmax routing weight for this expert |
| hidden_dim | Hidden dimension |
Definition at line 307 of file axpy_kernels.c.
References axpy_f32().
| void moe_relu2_expert_backward_f32 | ( | const float * | d_output, |
| const float * | hidden, | ||
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const float * | expert_up, | ||
| const float * | expert_down, | ||
| float * | d_hidden, | ||
| float * | d_routing_weights, | ||
| float * | d_expert_up, | ||
| float * | d_expert_down, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k | ||
| ) |
Definition at line 3706 of file axpy_kernels.c.
References ck_moe_down_idx(), and ck_moe_up_idx().
| void moe_relu2_expert_forward_f32 | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const float * | expert_up, | ||
| const float * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k | ||
| ) |
Definition at line 374 of file axpy_kernels.c.
References ck_moe_down_idx(), and ck_moe_up_idx().
| void moe_relu2_expert_forward_q5_0_q5_0 | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const void * | expert_up, | ||
| const void * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k | ||
| ) |
Definition at line 3557 of file axpy_kernels.c.
References CK_DT_Q5_0, ck_dtype_row_bytes(), ck_moe_debug_enabled(), ck_moe_debug_finite(), and dequant_q5_0_row().
| void moe_relu2_expert_forward_q5_0_q8_0 | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const void * | expert_up, | ||
| const void * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k | ||
| ) |
Definition at line 3475 of file axpy_kernels.c.
References CK_DT_Q5_0, CK_DT_Q8_0, ck_dtype_row_bytes(), ck_moe_debug_enabled(), ck_moe_debug_finite(), dequant_q5_0_row(), and dequant_q8_0_row().
| void moe_relu2_shared_forward_q5_1_q8_0 | ( | const float * | hidden, |
| const float * | routed, | ||
| const void * | shared_up, | ||
| const void * | shared_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim | ||
| ) |
Definition at line 3638 of file axpy_kernels.c.
References CK_DT_Q5_1, CK_DT_Q8_0, ck_dtype_row_bytes(), ck_moe_debug_enabled(), ck_moe_debug_finite(), dequant_q5_1_row(), and dequant_q8_0_row().
| void moe_swiglu_expert_backward_f32 | ( | const float * | d_output, |
| const float * | hidden, | ||
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const float * | expert_gate, | ||
| const float * | expert_up, | ||
| const float * | expert_down, | ||
| float * | d_hidden, | ||
| float * | d_routing_weights, | ||
| float * | d_expert_gate, | ||
| float * | d_expert_up, | ||
| float * | d_expert_down, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k | ||
| ) |
Definition at line 3020 of file axpy_kernels.c.
References ck_moe_down_idx(), ck_moe_dsilu_f32(), ck_moe_silu_f32(), and ck_moe_up_idx().
| void moe_swiglu_expert_forward_bf16 | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const uint16_t * | expert_gate, | ||
| const uint16_t * | expert_up, | ||
| const uint16_t * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k | ||
| ) |
Definition at line 563 of file axpy_kernels.c.
References moe_swiglu_expert_forward_bf16_row_range().
| void moe_swiglu_expert_forward_bf16_row_range | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const uint16_t * | expert_gate, | ||
| const uint16_t * | expert_up, | ||
| const uint16_t * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k, | ||
| int | row_begin, | ||
| int | row_end | ||
| ) |
Definition at line 505 of file axpy_kernels.c.
References bf16_to_float(), ck_moe_down_idx(), ck_moe_silu_f32(), and ck_moe_up_idx().
Referenced by moe_swiglu_expert_forward_bf16().
| void moe_swiglu_expert_forward_f32 | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const float * | expert_gate, | ||
| const float * | expert_up, | ||
| const float * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k | ||
| ) |
Definition at line 450 of file axpy_kernels.c.
References ck_moe_down_idx(), ck_moe_silu_f32(), and ck_moe_up_idx().
| int moe_swiglu_expert_forward_q4k_q4k_parallel_workspace | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const void * | expert_gate, | ||
| const void * | expert_up, | ||
| const void * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 1881 of file axpy_kernels.c.
References CK_MOE_DOWN_Q4_K, ck_moe_q4k_mixed_parallel_workspace(), and moe_swiglu_expert_forward_q4k_q4k_workspace().
| int moe_swiglu_expert_forward_q4k_q4k_workspace | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const void * | expert_gate, | ||
| const void * | expert_up, | ||
| const void * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 1108 of file axpy_kernels.c.
References axpy_f32(), CK_DT_Q4_K, CK_DT_Q8_K, ck_dtype_row_bytes(), ck_moe_align64(), gemv_q4_k_q8_k(), moe_swiglu_expert_q4k_q5k_workspace_bytes(), quantize_row_q8_k(), and swiglu_forward_ggml().
Referenced by moe_swiglu_expert_forward_q4k_q4k_parallel_workspace().
| int moe_swiglu_expert_forward_q4k_q5_0_parallel_workspace | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const void * | expert_gate, | ||
| const void * | expert_up, | ||
| const void * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 1927 of file axpy_kernels.c.
References CK_MOE_DOWN_Q5_0, ck_moe_q4k_mixed_parallel_workspace(), and moe_swiglu_expert_forward_q4k_q5_0_workspace().
| int moe_swiglu_expert_forward_q4k_q5_0_workspace | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const void * | expert_gate, | ||
| const void * | expert_up, | ||
| const void * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 1027 of file axpy_kernels.c.
References CK_DT_Q4_K, CK_DT_Q5_0, CK_DT_Q8_0, CK_DT_Q8_K, ck_dtype_row_bytes(), ck_moe_align64(), ck_moe_llama_weighted_accumulate(), ck_moe_q4k_llama_projection(), gemv_q5_0_q8_0(), moe_swiglu_expert_q4k_q8_0_workspace_bytes(), quantize_row_q8_0(), quantize_row_q8_k(), and swiglu_forward_ggml().
Referenced by moe_swiglu_expert_forward_q4k_q5_0_parallel_workspace().
| int moe_swiglu_expert_forward_q4k_q5k_auto_workspace | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const void * | expert_gate, | ||
| const void * | expert_up, | ||
| const void * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 2595 of file axpy_kernels.c.
References moe_swiglu_expert_forward_q4k_q5k_bucketed_workspace(), and moe_swiglu_expert_forward_q4k_q5k_parallel_workspace().
| int moe_swiglu_expert_forward_q4k_q5k_bucketed_prepared_workspace | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const void * | expert_gate, | ||
| const void * | expert_up, | ||
| const void * | expert_down, | ||
| const void * | expert_gate_packed, | ||
| const void * | expert_up_packed, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 2569 of file axpy_kernels.c.
References ck_moe_swiglu_expert_forward_q4k_q5k_bucketed_impl().
| int moe_swiglu_expert_forward_q4k_q5k_bucketed_workspace | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const void * | expert_gate, | ||
| const void * | expert_up, | ||
| const void * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 2546 of file axpy_kernels.c.
References ck_moe_swiglu_expert_forward_q4k_q5k_bucketed_impl().
Referenced by moe_swiglu_expert_forward_q4k_q5k_auto_workspace().
| int moe_swiglu_expert_forward_q4k_q5k_parallel_workspace | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const void * | expert_gate, | ||
| const void * | expert_up, | ||
| const void * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 1470 of file axpy_kernels.c.
References ck_moe_q4k_q5k_parallel_work(), ck_moe_q4k_q5k_route_parallel(), ck_threadpool_dispatch_n(), ck_threadpool_global(), CK_THREADPOOL_MAX_THREADS, ck_threadpool_n_threads(), moe_swiglu_expert_forward_q4k_q5k_workspace(), and moe_swiglu_expert_q4k_q5k_workspace_bytes().
Referenced by moe_swiglu_expert_forward_q4k_q5k_auto_workspace().
| int moe_swiglu_expert_forward_q4k_q5k_workspace | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const void * | expert_gate, | ||
| const void * | expert_up, | ||
| const void * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 781 of file axpy_kernels.c.
References axpy_f32(), CK_DT_Q4_K, CK_DT_Q5_K, CK_DT_Q8_K, ck_dtype_row_bytes(), ck_moe_align64(), gemv_q4_k_q8_k(), gemv_q5_k_q8_k(), moe_swiglu_expert_q4k_q5k_workspace_bytes(), quantize_row_q8_k(), and swiglu_forward_ggml().
Referenced by ck_moe_q4k_q5k_parallel_work(), and moe_swiglu_expert_forward_q4k_q5k_parallel_workspace().
| int moe_swiglu_expert_forward_q4k_q6k_parallel_workspace | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const void * | expert_gate, | ||
| const void * | expert_up, | ||
| const void * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 1858 of file axpy_kernels.c.
References CK_MOE_DOWN_Q6_K, ck_moe_q4k_mixed_parallel_workspace(), and moe_swiglu_expert_forward_q4k_q6k_workspace().
| int moe_swiglu_expert_forward_q4k_q6k_workspace | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const void * | expert_gate, | ||
| const void * | expert_up, | ||
| const void * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 869 of file axpy_kernels.c.
References axpy_f32(), CK_DT_Q4_K, CK_DT_Q6_K, CK_DT_Q8_K, ck_dtype_row_bytes(), ck_moe_align64(), gemv_q4_k_q8_k(), gemv_q6_k_q8_k(), moe_swiglu_expert_q4k_q5k_workspace_bytes(), quantize_row_q8_k(), and swiglu_forward_ggml().
Referenced by moe_swiglu_expert_forward_q4k_q6k_parallel_workspace().
| int moe_swiglu_expert_forward_q4k_q8_0_parallel_workspace | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const void * | expert_gate, | ||
| const void * | expert_up, | ||
| const void * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 1904 of file axpy_kernels.c.
References CK_MOE_DOWN_Q8_0, ck_moe_q4k_mixed_parallel_workspace(), and moe_swiglu_expert_forward_q4k_q8_0_workspace().
| int moe_swiglu_expert_forward_q4k_q8_0_workspace | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const void * | expert_gate, | ||
| const void * | expert_up, | ||
| const void * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 946 of file axpy_kernels.c.
References CK_DT_Q4_K, CK_DT_Q8_0, CK_DT_Q8_K, ck_dtype_row_bytes(), ck_moe_align64(), ck_moe_llama_weighted_accumulate(), ck_moe_q4k_llama_projection(), gemv_q8_0_q8_0(), moe_swiglu_expert_q4k_q8_0_workspace_bytes(), quantize_row_q8_0(), quantize_row_q8_k(), and swiglu_forward_ggml().
Referenced by moe_swiglu_expert_forward_q4k_q8_0_parallel_workspace().
| size_t moe_swiglu_expert_q4k_q5k_bucketed_workspace_bytes | ( | int | rows, |
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k | ||
| ) |
Definition at line 2202 of file axpy_kernels.c.
References ck_moe_bucket_layout().
| size_t moe_swiglu_expert_q4k_q5k_workspace_bytes | ( | int | hidden_dim, |
| int | intermediate_dim | ||
| ) |
Definition at line 727 of file axpy_kernels.c.
References CK_DT_Q8_K, ck_dtype_row_bytes(), and ck_moe_align64().
Referenced by ck_moe_q4k_mixed_parallel_workspace(), ck_moe_shared_q4k_parallel_workspace(), moe_swiglu_expert_forward_q4k_q4k_workspace(), moe_swiglu_expert_forward_q4k_q5k_parallel_workspace(), moe_swiglu_expert_forward_q4k_q5k_workspace(), moe_swiglu_expert_forward_q4k_q6k_workspace(), moe_swiglu_shared_forward_q4k_q4k_workspace(), and moe_swiglu_shared_forward_q4k_q6k_workspace().
| size_t moe_swiglu_expert_q4k_q8_0_workspace_bytes | ( | int | hidden_dim, |
| int | intermediate_dim | ||
| ) |
Definition at line 742 of file axpy_kernels.c.
References CK_DT_Q8_0, CK_DT_Q8_K, ck_dtype_row_bytes(), ck_moe_align64(), ck_moe_q4k_llama_projection_scratch_bytes(), and QK8_0.
Referenced by ck_moe_q4k_mixed_parallel_workspace(), moe_swiglu_expert_forward_q4k_q5_0_workspace(), and moe_swiglu_expert_forward_q4k_q8_0_workspace().
| void moe_swiglu_packed_expert_forward_bf16 | ( | const float * | hidden, |
| const int * | indices, | ||
| const float * | routing_weights, | ||
| const uint16_t * | expert_gate_up, | ||
| const uint16_t * | expert_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | n_experts, | ||
| int | top_k | ||
| ) |
Definition at line 582 of file axpy_kernels.c.
References bf16_to_float(), ck_moe_bf16_round(), ck_moe_down_idx(), and swiglu_forward_pytorch_bf16_storage().
| void moe_swiglu_shared_backward_f32 | ( | const float * | d_output, |
| const float * | hidden, | ||
| const float * | shared_gate, | ||
| const float * | shared_up, | ||
| const float * | shared_down, | ||
| float * | d_hidden, | ||
| float * | d_routed, | ||
| float * | d_shared_gate, | ||
| float * | d_shared_up, | ||
| float * | d_shared_down, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim | ||
| ) |
Definition at line 3400 of file axpy_kernels.c.
References ck_moe_dsilu_f32(), and ck_moe_silu_f32().
| void moe_swiglu_shared_forward_bf16 | ( | const float * | hidden, |
| const float * | routed, | ||
| const uint16_t * | shared_gate, | ||
| const uint16_t * | shared_up, | ||
| const uint16_t * | shared_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim | ||
| ) |
Definition at line 3205 of file axpy_kernels.c.
References moe_swiglu_shared_forward_bf16_row_range().
| void moe_swiglu_shared_forward_bf16_gated | ( | const float * | hidden, |
| const float * | routed, | ||
| const uint16_t * | shared_gate, | ||
| const uint16_t * | shared_up, | ||
| const uint16_t * | shared_down, | ||
| const uint16_t * | shared_router, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim | ||
| ) |
Definition at line 3298 of file axpy_kernels.c.
References moe_swiglu_shared_forward_bf16_gated_row_range().
| void moe_swiglu_shared_forward_bf16_gated_row_range | ( | const float * | hidden, |
| const float * | routed, | ||
| const uint16_t * | shared_gate, | ||
| const uint16_t * | shared_up, | ||
| const uint16_t * | shared_down, | ||
| const uint16_t * | shared_router, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | row_begin, | ||
| int | row_end | ||
| ) |
Definition at line 3221 of file axpy_kernels.c.
References bf16_to_float(), ck_moe_bf16_round(), ck_moe_sigmoid_f32(), ck_moe_silu_f32(), and silu().
Referenced by moe_swiglu_shared_forward_bf16_gated().
| void moe_swiglu_shared_forward_bf16_row_range | ( | const float * | hidden, |
| const float * | routed, | ||
| const uint16_t * | shared_gate, | ||
| const uint16_t * | shared_up, | ||
| const uint16_t * | shared_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| int | row_begin, | ||
| int | row_end | ||
| ) |
Definition at line 3157 of file axpy_kernels.c.
References bf16_to_float(), and ck_moe_silu_f32().
Referenced by moe_swiglu_shared_forward_bf16().
| void moe_swiglu_shared_forward_f32 | ( | const float * | hidden, |
| const float * | routed, | ||
| const float * | shared_gate, | ||
| const float * | shared_up, | ||
| const float * | shared_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim | ||
| ) |
Definition at line 3116 of file axpy_kernels.c.
References ck_moe_silu_f32().
| int moe_swiglu_shared_forward_q4k_q4k_parallel_workspace | ( | const float * | hidden, |
| const float * | routed, | ||
| const void * | shared_gate, | ||
| const void * | shared_up, | ||
| const void * | shared_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 2071 of file axpy_kernels.c.
References ck_moe_shared_q4k_parallel_workspace(), and moe_swiglu_shared_forward_q4k_q4k_workspace().
| int moe_swiglu_shared_forward_q4k_q4k_workspace | ( | const float * | hidden, |
| const float * | routed, | ||
| const void * | shared_gate, | ||
| const void * | shared_up, | ||
| const void * | shared_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 1242 of file axpy_kernels.c.
References CK_DT_Q8_K, ck_dtype_row_bytes(), ck_moe_align64(), gemv_q4_k_q8_k(), moe_swiglu_expert_q4k_q5k_workspace_bytes(), quantize_row_q8_k(), and swiglu_forward_ggml().
Referenced by moe_swiglu_shared_forward_q4k_q4k_parallel_workspace().
| int moe_swiglu_shared_forward_q4k_q5_0_gated_parallel_workspace | ( | const float * | hidden, |
| const float * | routed, | ||
| const void * | shared_gate, | ||
| const void * | shared_up, | ||
| const void * | shared_down, | ||
| const float * | shared_gate_input, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 2999 of file axpy_kernels.c.
References moe_swiglu_shared_forward_q4k_q5_0_gated_workspace().
| int moe_swiglu_shared_forward_q4k_q5_0_gated_workspace | ( | const float * | hidden, |
| const float * | routed, | ||
| const void * | shared_gate, | ||
| const void * | shared_up, | ||
| const void * | shared_down, | ||
| const float * | shared_gate_input, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 2828 of file axpy_kernels.c.
References ck_moe_shared_q4k_gated_workspace(), and gemv_q5_0_q8_0().
Referenced by moe_swiglu_shared_forward_q4k_q5_0_gated_parallel_workspace().
| int moe_swiglu_shared_forward_q4k_q6k_parallel_workspace | ( | const float * | hidden, |
| const float * | routed, | ||
| const void * | shared_gate, | ||
| const void * | shared_up, | ||
| const void * | shared_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 2052 of file axpy_kernels.c.
References ck_moe_shared_q4k_parallel_workspace(), and moe_swiglu_shared_forward_q4k_q6k_workspace().
| int moe_swiglu_shared_forward_q4k_q6k_workspace | ( | const float * | hidden, |
| const float * | routed, | ||
| const void * | shared_gate, | ||
| const void * | shared_up, | ||
| const void * | shared_down, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 1185 of file axpy_kernels.c.
References CK_DT_Q8_K, ck_dtype_row_bytes(), ck_moe_align64(), gemv_q4_k_q8_k(), gemv_q6_k_q8_k(), moe_swiglu_expert_q4k_q5k_workspace_bytes(), quantize_row_q8_k(), and swiglu_forward_ggml().
Referenced by moe_swiglu_shared_forward_q4k_q6k_parallel_workspace().
| int moe_swiglu_shared_forward_q4k_q8_0_gated_parallel_workspace | ( | const float * | hidden, |
| const float * | routed, | ||
| const void * | shared_gate, | ||
| const void * | shared_up, | ||
| const void * | shared_down, | ||
| const float * | shared_gate_input, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 2978 of file axpy_kernels.c.
References moe_swiglu_shared_forward_q4k_q8_0_gated_workspace().
| int moe_swiglu_shared_forward_q4k_q8_0_gated_workspace | ( | const float * | hidden, |
| const float * | routed, | ||
| const void * | shared_gate, | ||
| const void * | shared_up, | ||
| const void * | shared_down, | ||
| const float * | shared_gate_input, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 2815 of file axpy_kernels.c.
References ck_moe_shared_q4k_gated_workspace(), and gemv_q8_0_q8_0().
Referenced by moe_swiglu_shared_forward_q4k_q8_0_gated_parallel_workspace().
| int moe_swiglu_shared_forward_q8_0_gated_parallel_workspace | ( | const float * | hidden, |
| const float * | routed, | ||
| const void * | shared_gate, | ||
| const void * | shared_up, | ||
| const void * | shared_down, | ||
| const float * | shared_gate_input, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 2957 of file axpy_kernels.c.
References ck_moe_shared_gated_parallel_workspace(), moe_swiglu_shared_forward_q8_0_gated_workspace(), and moe_swiglu_shared_q8_0_gated_workspace_bytes().
| int moe_swiglu_shared_forward_q8_0_gated_workspace | ( | const float * | hidden, |
| const float * | routed, | ||
| const void * | shared_gate, | ||
| const void * | shared_up, | ||
| const void * | shared_down, | ||
| const float * | shared_gate_input, | ||
| float * | output, | ||
| int | rows, | ||
| int | hidden_dim, | ||
| int | intermediate_dim, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 2642 of file axpy_kernels.c.
References CK_DT_Q8_0, ck_dtype_row_bytes(), ck_moe_align64(), gemm_nt_f32_llama_production(), gemv_q8_0_q8_0(), moe_swiglu_shared_q8_0_gated_workspace_bytes(), quantize_row_q8_0(), and swiglu_forward_ggml().
Referenced by moe_swiglu_shared_forward_q8_0_gated_parallel_workspace().
| size_t moe_swiglu_shared_q4k_q8_0_gated_workspace_bytes | ( | int | hidden_dim, |
| int | intermediate_dim | ||
| ) |
Definition at line 761 of file axpy_kernels.c.
References CK_DT_Q8_0, CK_DT_Q8_K, ck_dtype_row_bytes(), ck_moe_align64(), and QK8_0.
Referenced by ck_moe_shared_q4k_gated_workspace().
| size_t moe_swiglu_shared_q8_0_gated_workspace_bytes | ( | int | hidden_dim, |
| int | intermediate_dim | ||
| ) |
Definition at line 2625 of file axpy_kernels.c.
References CK_DT_Q8_0, ck_dtype_row_bytes(), and ck_moe_align64().
Referenced by moe_swiglu_shared_forward_q8_0_gated_parallel_workspace(), and moe_swiglu_shared_forward_q8_0_gated_workspace().
| void pack_q4_k_to_packed_meta_x8 | ( | const void * | source, |
| void * | destination, | ||
| int | output_dim, | ||
| int | input_dim | ||
| ) |
Definition at line 525 of file gemm_kernels_q4k_q8k_vnni.c.
References block_q4_K::d, block_q4_K::dmin, QK_K, block_q4_K::qs, block_q4_K::scales, and unpack_q4_k_scales().
Referenced by ck_moe_q4k_llama_projection().
| size_t q4_k_packed_meta_x8_block_size | ( | void | ) |
Definition at line 464 of file gemm_kernels_q4k_q8k_vnni.c.
Referenced by ck_moe_q4k_llama_projection_scratch_bytes().
| size_t q4_k_packed_vnni_x8_block_size | ( | void | ) |
Definition at line 267 of file gemm_kernels_q4k_q8k_vnni.c.
Referenced by ck_moe_swiglu_expert_forward_q4k_q5k_bucketed_impl().
| void scal_copy_f32 | ( | float * | y, |
| const float * | x, | ||
| float | alpha, | ||
| int | n | ||
| ) |
Scaled copy: y = alpha * x.
| y | Output vector [n] |
| x | Input vector [n] |
| alpha | Scalar multiplier |
| n | Vector length |
Definition at line 156 of file axpy_kernels.c.
Referenced by weighted_sum_f32().
| void weighted_sum_f32 | ( | float * | y, |
| const float ** | vectors, | ||
| const float * | weights, | ||
| int | k, | ||
| int | n | ||
| ) |
Weighted sum of k vectors: y = sum_i(weights[i] * vectors[i])
| y | Output vector [n] |
| vectors | Array of k input vector pointers, each [n] |
| weights | Array of k scalar weights |
| k | Number of vectors to combine |
| n | Vector length |
Definition at line 206 of file axpy_kernels.c.
References axpy_f32(), and scal_copy_f32().