#include <stddef.h>#include <stdint.h>#include "ckernel_audio.h"#include "cpu_features.h"#include "ckernel_quant.h"#include "mega_fused_attention.h"Go to the source code of this file.
Data Structures | |
| struct | CKMathBackend |
Functions | |
| void | adamw_clip_update_multi_f32 (float *const *grads, float *const *weights, float *const *m_states, float *const *v_states, const size_t *numels, int tensor_count, float lr, float beta1, float beta2, float eps, float weight_decay, float max_grad_norm, int step) |
| void | adamw_update_f32 (const float *grad, float *weight, float *m, float *v, size_t numel, float lr, float beta1, float beta2, float eps, float weight_decay, int step) |
| void | add_backward_bf16 (const uint16_t *d_y, uint16_t *d_a, uint16_t *d_b, size_t n) |
| void | add_forward_2d_bf16 (const uint16_t *a, const uint16_t *b, uint16_t *y, int tokens, int dim, int aligned_dim) |
| void | add_forward_bf16 (const uint16_t *a, const uint16_t *b, uint16_t *y, size_t n) |
| void | add_forward_f32 (const float *a, const float *b, float *y, size_t n) |
| void | add_inplace_bf16 (uint16_t *a, const uint16_t *b, size_t n) |
| void | add_inplace_f32 (float *a, const float *b, size_t n) |
| void | add_scaled_forward_bf16 (const uint16_t *a, const uint16_t *b, uint16_t *y, float alpha, size_t n) |
| void | add_scaled_inplace_bf16 (uint16_t *a, const uint16_t *b, float alpha, size_t n) |
| void | add_stream_inplace (float *a, const float *b, size_t n) |
| void | add_stream_reorder_2d (float *main_inout, float *aux_scratch, int grid_h, int grid_w, int embed_dim, int merge_size) |
| int | argmax_f32 (const float *scores, int n) |
| Find index of maximum value. | |
| void | assistant_layer_scale_forward (float *hidden, const float *scale, int tokens, int embed_dim) |
| void | attention_backward_causal_head_major (const float *d_output, const float *q, const float *k, const float *v, const float *attn_weights, float *d_q, float *d_k, float *d_v, float *d_scores, int num_heads, int num_tokens, int head_dim, int aligned_head_dim, int aligned_context_window) |
| void | attention_backward_causal_head_major_gqa (const float *d_output, const float *q, const float *k, const float *v, const float *attn_weights, float *d_q, float *d_k, float *d_v, float *d_scores, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int aligned_context_window) |
| void | attention_backward_causal_head_major_gqa_bf16 (const uint16_t *d_output, float *d_x, const uint16_t *q, const uint16_t *k, const uint16_t *v, const float *attn_weights, float *d_q, float *d_k, float *d_v, float *d_scores, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int aligned_context_window, float *scratch_d_output, float *scratch_q, float *scratch_k, float *scratch_v) |
| void | attention_flash_decode (float *out, const float *q, const float *k, const float *v, int T_q, int T_k, int H, int D_h, float scale) |
| Main flash attention function with SIMD dispatch. | |
| void | attention_forward_causal_head_major (const float *q, const float *k, const float *v, float *scores, float *output, int num_heads, int num_tokens, int head_dim, int aligned_head_dim, int aligned_context_window) |
| void | attention_forward_causal_head_major_exact (const float *q, const float *k, const float *v, float *scores, float *output, int num_heads, int num_tokens, int head_dim, int aligned_head_dim, int aligned_context_window) |
| void | attention_forward_causal_head_major_gqa (const float *q, const float *k, const float *v, float *scores, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int aligned_context_window) |
| void | attention_forward_causal_head_major_gqa_bf16 (const uint16_t *q, const uint16_t *k, const uint16_t *v, float *scores, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int aligned_context_window, float *scratch_q, float *scratch_k, float *scratch_v) |
| void | attention_forward_causal_head_major_gqa_exact (const float *q, const float *k, const float *v, float *scores, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int aligned_context_window) |
| void | attention_forward_causal_head_major_gqa_flash (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim) |
| void | attention_forward_causal_head_major_gqa_flash_strided (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens) |
| void | attention_forward_causal_head_major_gqa_flash_strided_f16kv (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens) |
| void | attention_forward_causal_head_major_gqa_flash_strided_f16kv_workspace (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens, float *rounded_kv, size_t rounded_kv_bytes) |
| void | attention_forward_causal_head_major_gqa_flash_strided_gemma4 (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens) |
| void | attention_forward_causal_head_major_gqa_flash_strided_gemma4_token_output (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens) |
| void | attention_forward_causal_head_major_gqa_flash_strided_sliding (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens, int sliding_window) |
| void | attention_forward_causal_head_major_gqa_flash_strided_sliding_gemma4 (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens, int sliding_window) |
| void | attention_forward_causal_head_major_gqa_flash_strided_sliding_gemma4_token_output (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens, int sliding_window) |
| void | attention_forward_causal_head_major_gqa_flash_strided_token_output (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens) |
| void | attention_forward_causal_head_major_gqa_llama_regular_strided_sliding_workspace (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens, int sliding_window, float *scores, size_t scores_bytes, float *value_columns, size_t value_columns_bytes, float *scaled_scores, size_t scaled_scores_bytes) |
| ck_attention_status_t | attention_forward_causal_head_major_gqa_prefill_append_bf16cache_pytorch_contract (const float *q, const uint16_t *k_cache, const uint16_t *v_cache, float *output, int num_heads, int num_kv_heads, int q_tokens, int past_tokens, int cache_capacity, int head_dim, int aligned_head_dim, ck_attention_reduction_t reduction) |
| ck_attention_status_t | attention_forward_causal_head_major_gqa_prefill_append_bf16cache_pytorch_contract_workspace (const float *q, const uint16_t *k_cache, const uint16_t *v_cache, float *output, int num_heads, int num_kv_heads, int q_tokens, int past_tokens, int cache_capacity, int head_dim, int aligned_head_dim, ck_attention_reduction_t reduction, float *token_workspace, size_t token_workspace_bytes) |
| ck_attention_status_t | attention_forward_causal_head_major_gqa_prefill_append_f16cache_auto_workspace (const float *q, const uint16_t *k_cache, const uint16_t *v_cache, float *output, int num_heads, int num_kv_heads, int q_tokens, int past_tokens, int cache_capacity, int head_dim, int aligned_head_dim, ck_attention_reduction_t reduction, float *token_workspace, size_t token_workspace_bytes, void *gqa_workspace, size_t gqa_workspace_bytes, int route_num_heads, int route_num_kv_heads, int route_head_dim, int route_query_tokens, int route_min_kv_tokens, int route_workers, int route_query_tile_size, int route_concurrent_query_tiles) |
| ck_attention_status_t | attention_forward_causal_head_major_gqa_prefill_append_f16cache_contract (const float *q, const uint16_t *k_cache, const uint16_t *v_cache, float *output, int num_heads, int num_kv_heads, int q_tokens, int past_tokens, int cache_capacity, int head_dim, int aligned_head_dim, ck_attention_reduction_t reduction) |
| ck_attention_status_t | attention_forward_causal_head_major_gqa_prefill_append_f16cache_contract_workspace (const float *q, const uint16_t *k_cache, const uint16_t *v_cache, float *output, int num_heads, int num_kv_heads, int q_tokens, int past_tokens, int cache_capacity, int head_dim, int aligned_head_dim, ck_attention_reduction_t reduction, float *token_workspace, size_t token_workspace_bytes) |
| ck_attention_status_t | attention_forward_causal_head_major_gqa_prefill_append_f16cache_gqa_reuse_config (const float *q, const uint16_t *k_cache, const uint16_t *v_cache, float *output, int num_heads, int num_kv_heads, int q_tokens, int past_tokens, int cache_capacity, int head_dim, int aligned_head_dim, int query_tile_size, int concurrent_query_tiles, void *workspace, size_t workspace_bytes) |
| size_t | attention_forward_causal_head_major_gqa_prefill_append_f16cache_gqa_reuse_workspace_bytes (int num_heads, int num_kv_heads, int head_dim, int workers, int query_tile_size, int concurrent_query_tiles) |
| ck_attention_status_t | attention_forward_causal_head_major_gqa_prefill_append_f16cache_qtile64_schedule (const float *q, const uint16_t *k_cache, const uint16_t *v_cache, float *output, int num_heads, int num_kv_heads, int q_tokens, int past_tokens, int cache_capacity, int head_dim, int aligned_head_dim, ck_attention_prefill_schedule_t schedule) |
| ck_attention_status_t | attention_forward_causal_head_major_gqa_prefill_full_bf16cache_pytorch_contract (const float *q, const uint16_t *k_cache, const uint16_t *v_cache, float *output, int num_heads, int num_kv_heads, int q_tokens, int past_tokens, int cache_capacity, int head_dim, int aligned_head_dim, ck_attention_reduction_t reduction) |
| ck_attention_status_t | attention_forward_causal_head_major_gqa_prefill_segmented_f16cache_contract_workspace (const float *q, const uint16_t *k_cache, const uint16_t *v_cache, float *output, int num_heads, int num_kv_heads, int q_tokens, int past_tokens, int cache_capacity, int head_dim, int aligned_head_dim, ck_attention_reduction_t reduction, float *token_workspace, size_t token_workspace_bytes, const int *segment_lengths, int num_segments) |
| void | attention_forward_causal_head_major_shared_kv_gemma4 (const float *q, float *output, int num_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens) |
| void | attention_forward_causal_head_major_shared_kv_sliding_gemma4 (const float *q, float *output, int num_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens, int sliding_window) |
| void | attention_forward_chunk_head_major_gqa_flash_gemma4 (const float *q_chunk, const float *k_cache, const float *v_cache, float *out_chunk, int num_heads, int num_kv_heads, int q_tokens, int kv_tokens, int cache_capacity, int head_dim, int aligned_head_dim) |
| ck_attention_status_t | attention_forward_decode_head_major_gqa_bf16cache_pytorch_contract (const float *q_token, const uint16_t *k_cache, const uint16_t *v_cache, float *out_token, int num_heads, int num_kv_heads, int kv_tokens, int cache_capacity, int head_dim, int aligned_head_dim, ck_attention_reduction_t reduction) |
| void | attention_forward_decode_head_major_gqa_flash (const float *q_token, const float *k_cache, const float *v_cache, float *out_token, int num_heads, int num_kv_heads, int kv_tokens, int cache_capacity, int head_dim, int aligned_head_dim) |
| void | attention_forward_decode_head_major_gqa_flash_f16cache (const float *q_token, const uint16_t *k_cache, const uint16_t *v_cache, float *out_token, int num_heads, int num_kv_heads, int kv_tokens, int cache_capacity, int head_dim, int aligned_head_dim) |
| ck_attention_status_t | attention_forward_decode_head_major_gqa_flash_f16cache_contract (const float *q_token, const uint16_t *k_cache, const uint16_t *v_cache, float *out_token, int num_heads, int num_kv_heads, int kv_tokens, int cache_capacity, int head_dim, int aligned_head_dim, ck_attention_reduction_t reduction) |
| void | attention_forward_decode_head_major_gqa_flash_f16cache_split (const float *q_token, const uint16_t *k_cache, const uint16_t *v_cache, float *out_token, int num_heads, int num_kv_heads, int kv_tokens, int cache_capacity, int head_dim, int aligned_head_dim, int split_chunks) |
| void | attention_forward_decode_head_major_gqa_flash_f16kv (const float *q_token, const float *k_cache, const float *v_cache, float *out_token, int num_heads, int num_kv_heads, int kv_tokens, int cache_capacity, int head_dim, int aligned_head_dim) |
| void | attention_forward_decode_head_major_gqa_flash_gemma4 (const float *q_token, const float *k_cache, const float *v_cache, float *out_token, int num_heads, int num_kv_heads, int kv_tokens, int cache_capacity, int head_dim, int aligned_head_dim) |
| void | attention_forward_decode_head_major_gqa_flash_sliding (const float *q_token, const float *k_cache, const float *v_cache, float *out_token, int num_heads, int num_kv_heads, int kv_tokens, int cache_capacity, int head_dim, int aligned_head_dim, int sliding_window) |
| void | attention_forward_decode_head_major_gqa_flash_sliding_gemma4 (const float *q_token, const float *k_cache, const float *v_cache, float *out_token, int num_heads, int num_kv_heads, int kv_tokens, int cache_capacity, int head_dim, int aligned_head_dim, int sliding_window) |
| void | attention_forward_decode_head_major_gqa_llama_regular_sliding_workspace (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int live_tokens, int kv_stride_tokens, int head_dim, int aligned_head_dim, int sliding_window, float *scores, size_t scores_bytes, float *value_columns, size_t value_columns_bytes, float *scaled_scores, size_t scaled_scores_bytes) |
| void | attention_forward_decode_head_major_gqa_regular (const float *q_token, const float *k_cache, const float *v_cache, float *out_token, int num_heads, int num_kv_heads, int kv_tokens, int cache_capacity, int head_dim, int aligned_head_dim) |
| WARNING: This is NOT true flash attention! | |
| void | attention_forward_decode_head_major_shared_kv_gemma4 (const float *q_token, const float *k_cache, const float *v_cache, float *out_token, int num_heads, int kv_tokens, int cache_capacity, int head_dim, int aligned_head_dim) |
| void | attention_forward_decode_head_major_shared_kv_sliding_gemma4 (const float *q_token, const float *k_cache, const float *v_cache, float *out_token, int num_heads, int kv_tokens, int cache_capacity, int head_dim, int aligned_head_dim, int sliding_window) |
| void | attention_forward_full_head_major_gqa_exact_strided (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens) |
| void | attention_forward_full_head_major_gqa_flash (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim) |
| void | attention_forward_full_head_major_gqa_flash_strided (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens) |
| void | attention_forward_full_head_major_gqa_flash_strided_bf16_storage (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens) |
| void | attention_forward_full_head_major_gqa_flash_strided_gemma4 (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens) |
| void | attention_forward_full_head_major_gqa_ggml_strided (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens) |
| void | attention_forward_full_head_major_gqa_ggml_strided_workspace (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens, float *score_rows, size_t score_rows_bytes, float *v_columns, size_t v_columns_bytes, float *probability_row, size_t probability_row_bytes) |
| void | attention_forward_full_head_major_gqa_pytorch_cpu_flash_bf16_storage (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens) |
| void | attention_forward_full_head_major_gqa_pytorch_cpu_flash_bf16_storage_token_output (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens) |
| void | attention_forward_full_head_major_gqa_sdpa_bf16_storage (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens) |
| void | attention_forward_full_head_major_gqa_tiled336_f16kv_fp32_strided (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens) |
| void | attention_forward_full_head_major_gqa_tiled64_f16kv_fp32_strided (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens) |
| void | attention_forward_full_head_major_gqa_tiled_f16kv_fp32_strided (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens) |
| void | attention_forward_mixed_visual_chunk_head_major_gqa_flash_strided_gemma4 (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens, int visual_start, int visual_tokens) |
| void | attention_forward_mixed_visual_chunk_head_major_gqa_flash_strided_gemma4_token_output (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int kv_stride_tokens, int visual_start, int visual_tokens) |
| int | attention_forward_query_key_head_major_f32 (const float *query, const float *key, const float *value, float *output, float *score_scratch, int num_heads, int query_tokens, int key_tokens, int head_dim, float scale) |
| int | attention_forward_query_key_head_major_f32_packed_k (const float *query, const float *key, const float *value, float *output, float *score_scratch, float *key_transpose_scratch, int num_heads, int query_tokens, int key_tokens, int head_dim, float scale) |
| int | attention_forward_query_key_head_major_tiled_f16kv_fp32 (const float *query, const float *key, const float *value, float *output, int num_heads, int query_tokens, int key_tokens, int head_dim, float scale) |
| void | attention_forward_sparse_token_major_gqa_bf16cache_pytorch_cpu_flash_contract (const float *query, const uint16_t *key_cache, const uint16_t *value_cache, const float *selected_indices, float *output, float *score_scratch, int rows, int query_heads, int kv_heads, int head_dim, int selection_width, int context_length, int position) |
| void | attn_gate_sigmoid_mul_backward (const float *d_out, const float *x, const float *gate, float *d_x, float *d_gate, int rows, int num_heads, int state_dim) |
| void | attn_gate_sigmoid_mul_forward (const float *x, const float *gate, float *out, int rows, int num_heads, int state_dim) |
| void | attn_gate_sigmoid_mul_pytorch_bf16_storage (const float *x, const float *gate, float *out, int rows, int num_heads, int state_dim) |
| void | attn_gate_softplus_mul_forward (const float *x, const float *gate, float *out, int rows, int num_heads, int state_dim) |
| 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. | |
| void | backward_causal_softmax_head_major (float *d_scores, const float *weights, int num_heads, int num_tokens, int aligned_context_window) |
| void | backward_causal_softmax_head_major_bf16 (uint16_t *d_scores, const uint16_t *weights, int num_heads, int num_tokens, int aligned_context_window, float *scratch_d_scores, float *scratch_weights) |
| void | causal_softmax_head_major (float *scores, int num_heads, int num_tokens, int aligned_context_window) |
| void | causal_softmax_head_major_bf16 (uint16_t *scores, int num_heads, int num_tokens, int aligned_context_window, float *scratch) |
| void | causal_softmax_head_major_exact (float *scores, int num_heads, int num_tokens, int aligned_context_window) |
| int | ck_attention_bf16_pytorch_gqa_available (void) |
| void | ck_attention_flash_decode_wrapper (const float *q_token, const float *k_cache, const float *v_cache, float *out_token, int num_heads, int num_kv_heads, int kv_tokens, int cache_capacity, int head_dim, int aligned_head_dim) |
| Wrapper to call TRUE flash attention from orchestration layer. | |
| float | ck_attention_pytorch_sdpa_scale_f32 (int head_dim) |
| int | ck_attention_sparse_bf16_pytorch_gqa_available (void) |
| int | ck_flash_attn_choose_tile_k (int D_h) |
| int | ck_flash_attn_fast_exp_kind (void) |
| int | ck_gemm_bf16_amx_available (void) |
| int | ck_gemm_bf16_fp32out_amx_raw (const uint16_t *A, const uint16_t *B, float *C, int M, int N, int K, int accumulate) |
| int | ck_gemm_nt_f16_ggml_oracle (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| int | ck_gemm_nt_f16_simd_lanes (void) |
| void | ck_gemm_nt_head_major_q5_0 (const float *attn_out, const void *wo, const float *bias, float *output, int tokens, int embed_dim, int num_heads, int head_dim) |
| Output projection from head-major attention (auto-dispatch) | |
| void | ck_gemm_nt_head_major_q8_0 (const float *attn_out, const void *wo, const float *bias, float *output, int tokens, int embed_dim, int num_heads, int head_dim) |
| Output projection from head-major attention (Q8_0 weights) | |
| int | ck_get_num_threads (void) |
| int | ck_get_physical_cores (void) |
| void | ck_layout_head_to_token_f32 (const float *src, float *dst, int heads, int tokens, int head_dim) |
| void | ck_layout_token_to_head_f32 (const float *src, float *dst, int tokens, int heads, int head_dim) |
| void * | ck_memcpy_parallel_dispatch (void *dst, const void *src, size_t size) |
| int | ck_multimodal_mrope_positions_2d (int32_t *positions, int total_tokens, int prefix_start, int position_base, int prefix_tokens, int grid_x, int grid_y, int text_pos) |
| int | ck_multimodal_prefix_insert_f32 (const float *source_rows, int32_t *token_ids, float *decoder_rows, int row_count, int source_row_stride, int decoder_row_stride, int copy_dim, int start_row, int decoder_capacity) |
| const char * | ck_q6_k_prepared_provider_name (void) |
| const char * | ck_q6_k_q8_k_provider_name (void) |
| void | ck_residual_add_backward (const float *d_out, float *d_a, float *d_b, int tokens, int aligned_embed_dim) |
| void | ck_residual_add_token_major (const float *a, const float *b, float *out, int tokens, int aligned_embed_dim) |
| void | ck_residual_add_token_major_bf16_storage (const float *a, const float *b, float *out, int tokens, int aligned_embed_dim) |
| void | ck_residual_add_token_major_parallel_dispatch (const float *a, const float *b, float *out, int tokens, int aligned_embed_dim) |
| void | ck_set_num_threads (int num_threads) |
| void | ck_set_strict_parity (int enabled) |
| const float * | ck_strict_consume_next_gemm_a (size_t elems) |
| int | ck_strict_mtmd_clip_encode_planar_f32 (const float *planar, int channels, int height, int width, float *out, size_t out_elems) |
| int | ck_strict_parity_enabled (void) |
| void | ck_strict_store_next_gemm_a (const float *data, size_t elems) |
| CKMathBackend | ckernel_backend_native (void) |
| void | deepseek_csa_attention_backward_f32 (const float *d_out, const float *q, const float *k, const float *v, const int *indices, const float *attn, float *d_q, float *d_k, float *d_v, int query_tokens, int key_tokens, int heads, int dim, int top_k, float scale) |
| void | deepseek_csa_attention_f32 (const float *q, const float *k, const float *v, const int *indices, float *out, float *attn, int query_tokens, int key_tokens, int heads, int dim, int top_k, float scale) |
| void | deepseek_dsa_topk_softmax_backward_f32 (const int *indices, const float *weights, const float *d_weights, float *d_scores, int tokens, int heads, int key_count, int top_k) |
| void | deepseek_dsa_topk_softmax_f32 (const float *scores, int *indices, float *weights, int tokens, int heads, int key_count, int top_k) |
| void | deepseek_hybrid_attention_f32 (const float *q, const float *k, const float *v, const int *indices, float *out, float *attn, int query_tokens, int key_tokens, int heads, int dim, int top_k, float scale, int mode) |
| void | deepseek_mhc_mix_backward_f32 (const float *d_out, const float *streams, const float *mix, float *d_streams, float *d_mix, int tokens, int n_streams, int dim) |
| void | deepseek_mhc_mix_f32 (const float *streams, const float *mix, float *out, int tokens, int n_streams, int dim) |
| void | deepseek_mla_attention_decode_f32 (const float *q, const float *k_cache, const float *v_cache, float *output, int num_heads, int num_kv_heads, int cache_len, int qk_head_dim, int v_head_dim, int max_seq_len, int cache_stride) |
| void | deepseek_mla_attention_decode_f32_workspace (const float *q, const float *k_cache, const float *v_cache, float *output, int num_heads, int num_kv_heads, int cache_len, int qk_head_dim, int v_head_dim, int max_seq_len, int cache_stride, float scale, float *scores, size_t scores_bytes) |
| void | deepseek_mla_attention_f32 (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int qk_head_dim, int v_head_dim) |
| void | deepseek_mla_attention_f32_parallel_dispatch (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int qk_head_dim, int v_head_dim, float scale, float *scores, size_t scores_bytes) |
| void | deepseek_mla_attention_f32_workspace (const float *q, const float *k, const float *v, float *output, int num_heads, int num_kv_heads, int num_tokens, int qk_head_dim, int v_head_dim, float scale, float *scores, size_t scores_bytes) |
| void | deepseek_mla_kv_cache_batch_store_f32 (float *k_cache, float *v_cache, const float *k, const float *v, int num_tokens, int num_kv_heads, int qk_head_dim, int v_head_dim, int max_seq_len, int cache_stride) |
| void | deepseek_mla_kv_cache_store_f32 (float *k_cache, float *v_cache, const float *k, const float *v, int pos, int num_kv_heads, int qk_head_dim, int v_head_dim, int max_seq_len, int cache_stride) |
| void | deepseek_mla_kv_decompress_bf16 (const float *compressed_kv, const uint16_t *kv_b_proj, float *k_nope, float *value, int tokens, int heads, int kv_lora_rank, int qk_nope_dim, int v_dim) |
| void | deepseek_mla_kv_decompress_bf16_parallel_dispatch (const float *compressed_kv, const uint16_t *kv_b_proj, float *k_nope, float *value, int tokens, int heads, int kv_lora_rank, int qk_nope_dim, int v_dim) |
| void | deepseek_mla_kv_decompress_bf16_token_range (const float *compressed_kv, const uint16_t *kv_b_proj, float *k_nope, float *value, int tokens, int heads, int kv_lora_rank, int qk_nope_dim, int v_dim, int token_begin, int token_end) |
| void | deepseek_mla_kv_decompress_f32 (const float *compressed_kv, const float *kv_b_proj, float *k_nope, float *value, int tokens, int heads, int kv_lora_rank, int qk_nope_dim, int v_dim) |
| void | deepseek_mla_partial_rope_concat_f32 (const float *q_nope, const float *q_pe, const float *k_nope, const float *k_pe, const float *cos, const float *sin, float *query, float *key, int tokens, int heads, int qk_nope_dim, int qk_rope_dim) |
| void | deepseek_mla_partial_rope_concat_packed_bf16_storage (const float *q_packed, const float *k_nope, const float *kv_a_packed, const float *cos, const float *sin, float *query, float *key, int tokens, int heads, int kv_lora_rank, int qk_nope_dim, int qk_rope_dim) |
| void | deepseek_mla_partial_rope_concat_packed_f32 (const float *q_packed, const float *k_nope, const float *kv_a_packed, const float *cos, const float *sin, float *query, float *key, int tokens, int heads, int kv_lora_rank, int qk_nope_dim, int qk_rope_dim) |
| void | dequant_q4_0_row (const void *src, float *dst, size_t n_elements) |
| Dequantize Q4_0 row (multiple blocks) | |
| void | dequant_q4_1_row (const void *src, float *dst, size_t n_elements) |
| Dequantize Q4_1 row (multiple blocks) | |
| void | dequant_q4_k_row (const void *src, float *dst, size_t n_elements) |
| Dequantize Q4_K row (multiple blocks) | |
| void | dequant_q5_0_row (const void *src, float *dst, size_t n_elements) |
| Dequantize Q5_0 row (multiple blocks) | |
| void | dequant_q5_1_row (const void *src, float *dst, size_t n_elements) |
| Dequantize Q5_1 row (multiple blocks) | |
| void | dequant_q6_k_row (const void *src, float *dst, size_t n_elements) |
| Dequantize Q6_K row (multiple blocks) | |
| void | dequant_q8_0_row (const void *src, float *dst, size_t n_elements) |
| Dequantize Q8_0 row (multiple blocks) | |
| void | embedding_backward (const int32_t *token_ids, int token_count, const float *d_output, float *d_token_embeddings, float *d_pos_embeddings, int vocab_size, int embed_dim, int aligned_embed_dim, int context_window, int add_pos) |
| void | embedding_backward_bf16 (const int32_t *token_ids, int token_count, const uint16_t *d_output, uint16_t *d_token_embeddings, uint16_t *d_pos_embeddings, int vocab_size, int embed_dim, int aligned_embed_dim, int context_window, int add_pos) |
| void | embedding_backward_bf16_mixed (const int32_t *token_ids, int token_count, const uint16_t *d_output, float *d_token_embeddings, float *d_pos_embeddings, int vocab_size, int embed_dim, int aligned_embed_dim, int context_window, int add_pos) |
| void | embedding_forward (const int32_t *token_ids, int token_count, int vocab_size, const float *token_embeddings, const float *pos_embeddings, float *output, int embed_dim, int aligned_embed_dim, int context_window, int add_pos) |
| void | embedding_forward_bf16 (const int32_t *token_ids, int token_count, int vocab_size, const uint16_t *token_embeddings, const uint16_t *pos_embeddings, uint16_t *output, int embed_dim, int aligned_embed_dim, int context_window, int add_pos) |
| void | embedding_forward_bf16_fp32 (const int32_t *token_ids, int token_count, int vocab_size, const uint16_t *token_embeddings, const float *pos_embeddings, float *output, int embed_dim, int aligned_embed_dim, int context_window, int add_pos) |
| void | embedding_forward_q4_k (const int32_t *token_ids, int token_count, int vocab_size, const void *token_embeddings, const float *pos_embeddings, float *output, int embed_dim, int aligned_embed_dim, int context_window, int add_pos) |
| void | embedding_forward_q5_0 (const int32_t *token_ids, int token_count, int vocab_size, const void *token_embeddings, const float *pos_embeddings, float *output, int embed_dim, int aligned_embed_dim, int context_window, int add_pos) |
| void | embedding_forward_q6_k (const int32_t *token_ids, int token_count, int vocab_size, const void *token_embeddings, const float *pos_embeddings, float *output, int embed_dim, int aligned_embed_dim, int context_window, int add_pos) |
| void | embedding_forward_q8_0 (const int32_t *token_ids, int token_count, int vocab_size, const void *token_embeddings, const float *pos_embeddings, float *output, int embed_dim, int aligned_embed_dim, int context_window, int add_pos) |
| 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_parallel_dispatch (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 | fc1_backward_kernel (const float *d_output, const float *fc1_input, const float *W_fc1, float *d_input, float *d_W_fc1, float *d_b_fc1, int T, int aligned_in, int aligned_out, int num_threads) |
| void | fc2_backward_kernel (const float *d_output, const float *fc2_input, const float *W_fc2, float *d_input, float *d_W_fc2, float *d_b_fc2, int T, int aligned_in, int aligned_out, int num_threads) |
| void | feature_concat (const float *main_input, const float *branch_input, float *output, int rows, int main_dim, int branch_slice_dim, int num_branch_slices) |
| void | feature_concat_2way (const float *main_input, const float *branch_input, float *output, int rows, int main_dim, int branch_slice_dim, int num_branch_slices) |
| void | feature_slice_copy (const float *src, float *dst, int rows, int src_dim, int dst_dim, int dst_feature_offset) |
| void | final_logit_scale_f32 (float *logits, int tokens, int vocab_size, float scale) |
| void | fused_mlp_swiglu_decode (const float *x, const float *W_gate, const float *W_up, const float *W_down, const float *b_gate, const float *b_up, const float *b_down, float *output, int D, int Hff) |
| void | fused_mlp_swiglu_decode_tiled (const float *x, const float *W_gate, const float *W_up, const float *W_down, const float *b_gate, const float *b_up, const float *b_down, float *output, int D, int Hff) |
| void | fused_mlp_swiglu_decode_v2 (const float *x, const float *W_gate, const float *W_up, const float *W_down, const float *b_gate, const float *b_up, const float *b_down, float *output, int D, int Hff) |
| void | fused_mlp_swiglu_prefill (const float *x, const float *W_gate, const float *W_up, const float *W_down, float *output, int seq_len, int hidden, int intermediate, float *scratch) |
| Fused MLP (Gate + Up + SwiGLU + Down) for prefill. | |
| void | fused_mlp_swiglu_prefill_bias (const float *x, const float *W_gate, const float *W_up, const float *W_down, const float *B_gate, const float *B_up, const float *B_down, float *output, int seq_len, int hidden, int intermediate, float *scratch) |
| Fused MLP (Gate + Up + SwiGLU + Down) for prefill with biases. | |
| void | fused_mlp_swiglu_prefill_w1w2_quant (const float *x, const void *W1, const float *B1, CKDataType w1_dt, const void *W2, const float *B2, CKDataType w2_dt, float *output, int seq_len, int embed_dim, int aligned_embed_dim, int intermediate_dim, int aligned_intermediate_dim, void *scratch) |
| Quantized fused MLP for prefill (W1=gate+up, W2=down) | |
| size_t | fused_mlp_swiglu_prefill_w1w2_quant_scratch_size (int aligned_embed_dim, int aligned_intermediate_dim) |
| Get scratch buffer size for fused_mlp_swiglu_prefill_w1w2_quant. | |
| size_t | fused_mlp_swiglu_scratch_size (int intermediate) |
| Get scratch buffer size for fused_mlp_swiglu_prefill. | |
| void | fused_rmsnorm_qkv_prefill (const float *x, const float *gamma, const float *Wq, const float *Wk, const float *Wv, float *Q, float *K, float *V, int seq_len, int hidden, int q_dim, int kv_dim, float eps, float *scratch) |
| Fused RMSNorm + QKV projection for prefill. | |
| void | fused_rmsnorm_qkv_prefill_head_major (const float *x, const float *gamma, const float *Wq, const float *Bq, const float *Wk, const float *Bk, const float *Wv, const float *Bv, float *Q, float *K, float *V, int seq_len, int embed_dim, int aligned_embed_dim, int num_heads, int num_kv_heads, int head_dim, int aligned_head_dim, int kv_stride_tokens, float eps, float *scratch) |
| Fused RMSNorm + QKV projection for prefill (head-major outputs) | |
| void | fused_rmsnorm_qkv_prefill_head_major_quant (const float *x, const float *gamma, const void *Wq, const float *Bq, CKDataType wq_dt, const void *Wk, const float *Bk, CKDataType wk_dt, const void *Wv, const float *Bv, CKDataType wv_dt, float *Q, float *K, float *V, int seq_len, int embed_dim, int aligned_embed_dim, int num_heads, int num_kv_heads, int head_dim, int aligned_head_dim, int kv_stride_tokens, float eps, void *scratch) |
| Fused RMSNorm + QKV projection for prefill (head-major, Q8 activations) | |
| size_t | fused_rmsnorm_qkv_prefill_head_major_quant_scratch_size (int aligned_embed_dim) |
| Get scratch buffer size for fused_rmsnorm_qkv_prefill_head_major_quant. | |
| size_t | fused_rmsnorm_qkv_scratch_size (int hidden) |
| Get scratch buffer size for fused_rmsnorm_qkv_prefill. | |
| void | gated_deltanet_autoregressive_backward (const float *d_out, const float *d_state_out, const float *q, const float *k, const float *v, const float *g, const float *beta, const float *state_in, const float *state_out, float *d_q, float *d_k, float *d_v, float *d_g, float *d_beta, float *d_state_in, int num_heads, int state_dim, float norm_eps) |
| void | gated_deltanet_autoregressive_forward (const float *q, const float *k, const float *v, const float *g, const float *beta, const float *state_in, float *state_out, float *out, int num_heads, int state_dim, float norm_eps) |
| void | gated_deltanet_llama_avx2_forward (const float *q, const float *k, const float *v, const float *g, const float *beta, const float *state_in, float *state_out, float *out, int num_heads, int group_count, int state_dim, float norm_eps) |
| void | gated_deltanet_llama_avx2_prefill_forward (const float *q, const float *k, const float *v, const float *g, const float *beta, const float *state_in, float *state_out, float *out, int rows, int num_heads, int group_count, int state_dim, float norm_eps) |
| void | gated_deltanet_llama_chunk64_head_forward (const float *q, const float *k, const float *v, const float *g, const float *beta, const float *state_in, float *state_out, float *out, int rows, int num_heads, int group_count, int head, int state_dim) |
| void | gated_deltanet_llama_chunk64_prefill_forward (const float *q, const float *k, const float *v, const float *g, const float *beta, const float *state_in, float *state_out, float *out, int rows, int num_heads, int group_count, int state_dim, float norm_eps) |
| void | gated_deltanet_prefill_forward (const float *q, const float *k, const float *v, const float *g, const float *beta, const float *state_in, float *state_out, float *out, int rows, int num_heads, int state_dim, float norm_eps) |
| void | gated_deltanet_pytorch_grouped_bf16_forward (const float *q, const float *k, const float *v, const float *g, const float *beta, const float *state_in, float *state_out, float *out, int num_heads, int group_count, int state_dim, float norm_eps) |
| void | gated_deltanet_pytorch_grouped_bf16_prefill_forward (const float *q, const float *k, const float *v, const float *g, const float *beta, const float *state_in, float *state_out, float *out, int rows, int num_heads, int group_count, int state_dim, float norm_eps) |
| void | geglu_backward_bf16_mixed (const uint16_t *x, const uint16_t *d_out, float *d_x, int tokens, int dim) |
| void | geglu_backward_fp32 (const float *x, const float *d_out, float *d_x, int tokens, int dim) |
| void | geglu_forward_bf16 (const uint16_t *x, uint16_t *out, int tokens, int dim, float *scratch) |
| void | geglu_forward_exact (const float *x, float *out, int tokens, int dim) |
| void | geglu_forward_fp32 (const float *x, float *out, int tokens, int dim) |
| void | geglu_forward_ggml_native (const float *x, float *out, int tokens, int dim) |
| void | gelu_backward_exact (const float *input, const float *d_output, float *d_input, size_t n) |
| void | gelu_backward_exact_bf16 (const uint16_t *input, const uint16_t *d_output, uint16_t *d_input, size_t n, float *scratch_input, float *scratch_d_output, float *scratch_d_input) |
| void | gelu_backward_fast (const float *input, const float *d_output, float *d_input, size_t n) |
| void | gelu_backward_fast_bf16 (const uint16_t *input, const uint16_t *d_output, uint16_t *d_input, size_t n, float *scratch_input, float *scratch_d_output, float *scratch_d_input) |
| void | gelu_backward_scalar (const float *input, const float *d_output, float *d_input, size_t n) |
| void | gelu_erf_bf16_storage (float *data, size_t n) |
| void | gelu_erf_fp64_f32_inplace (float *data, size_t n) |
| void | gelu_exact_inplace (float *data, size_t n) |
| void | gelu_fast_inplace (float *data, size_t n) |
| void | gelu_fast_inplace_bf16 (uint16_t *data, size_t n, float *scratch) |
| void | gelu_ggml_inplace (float *data, size_t n) |
| void | gelu_ggml_native_inplace (float *data, size_t n) |
| void | gelu_pytorch_erf_f32_inplace (float *data, size_t n) |
| void | gelu_pytorch_erf_sleef_bf16_storage (float *data, size_t n) |
| void | gelu_pytorch_tanh_bf16_storage (float *data, size_t n) |
| void | gemm_avx512_parallel (const float *A, const float *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_backward_bf16_mixed (const uint16_t *d_output, const uint16_t *input, const uint16_t *weight, float *d_input, float *d_weight, float *d_bias, int tokens, int in_dim, int out_dim) |
| void | gemm_backward_f32_train_parallel_dispatch (const float *d_output, const float *input, const float *W, float *d_input, float *d_W, float *d_b, int T, int aligned_in, int aligned_out, int num_threads) |
| void | gemm_backward_f32_train_parallel_dispatch_v2 (const float *d_output, const float *input, const float *W, float *d_input, float *d_W, float *d_b, int T, int aligned_in, int aligned_out, int num_threads) |
| void | gemm_bias_gelu_fused (const float *A, const float *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_bias_relu_fused (const float *A, const float *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_bias_silu_fused (const float *A, const float *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_blocked_serial (const float *A, const float *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_blocked_serial_bf16 (const uint16_t *A, const uint16_t *B, const uint16_t *bias, uint16_t *C, int M, int N, int K) |
| void | gemm_blocked_serial_train_parallel_dispatch (const float *A, const float *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_fine_grained_parallel (const float *A, const float *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_microkernel (const float *A, const float *B, float *C, int M, int N, int K, int B_transposed) |
| void | gemm_microkernel_blocked (const float *A, const float *B, float *C, int M, int N, int K) |
| void | gemm_microkernel_blocked_bt (const float *A, const float *B, float *C, int M, int N, int K) |
| void | gemm_microkernel_packed (const float *A, const float *B, float *C, int M, int N, int K) |
| void | gemm_naive_parallel (const float *A, const float *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nn_avx512 (const float *A, const float *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nn_blocked (const float *A, const float *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nn_parallel (const float *A, const float *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nn_simd (const float *A, const float *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_bf16 (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_bf16_amx_bf16_storage (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_bf16_amx_bf16_storage_workspace (const float *A, const void *B, const float *bias, float *C, int M, int N, int K, uint16_t *a_bf16, size_t a_bf16_bytes) |
| void | gemm_nt_bf16_bf16_storage (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_bf16_bf16_storage_parallel_dispatch (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_bf16_bf16_storage_row_range (const float *A, const void *B, const float *bias, float *C, int M, int N, int K, int row_begin, int row_end) |
| void | gemm_nt_bf16_native_bf16_storage (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_bf16_parallel_dispatch (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_bf16_prefill_shape_safe_bf16_storage (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_bf16_prefill_shape_safe_bf16_storage_workspace (const float *A, const void *B, const float *bias, float *C, int M, int N, int K, uint16_t *a_bf16, size_t a_bf16_bytes) |
| void | gemm_nt_bf16_pytorch_onednn_3_12_brgemm_bf16_storage (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_bf16_pytorch_onednn_brgemm_bf16_storage (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_bf16_row_range (const float *A, const void *B, const float *bias, float *C, int M, int N, int K, int row_begin, int row_end) |
| void | gemm_nt_f16 (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| NT GEMM wrapper for FP16 weights with the engine's standard ABI. | |
| void | gemm_nt_f16_clipped (const float *A, const void *B, const float *bias, const float *input_min, const float *input_max, const float *output_min, const float *output_max, float *C, int M, int N, int K) |
| void | gemm_nt_f32_llama_production (const float *A, const float *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_f32_llama_production_output_range (const float *A, const float *B, const float *bias, float *C, int M, int N, int K, int output_begin, int output_end) |
| void | gemm_nt_fp32_exact_parallel_dispatch (const float *A, const float *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_q4_0 (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| Matrix-matrix multiply: C[M,N] = A[M,K] @ B[N,K]^T + bias. | |
| void | gemm_nt_q4_1 (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| GEMM with transposed Q4_1 weights: C = A @ B^T. | |
| void | gemm_nt_q4_k (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_q4_k_q8_k (const void *A_q8, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_q5_0 (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_q5_1 (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| GEMM with transposed Q5_1 weights: C = A @ B^T. | |
| void | gemm_nt_q5_1_q8_1 (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_q5_1_q8_1_ref (const void *A_q8, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_q5_k (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_q5_k_q8_k (const void *A_q8, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_q6_k (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_q6_k_q8_k (const void *A_q8, const void *B, const float *bias, float *C, int M, int N, int K) |
| NT GEMM: C = A @ B^T where A is Q8_K and B is Q6_K. | |
| void | gemm_nt_q6_k_q8_k_m4_tile (const void *A_q8, const void *B, const float *bias, float *C, int M, int N, int K, int m0, int m1, int n0, int n1) |
| void | gemm_nt_q6_k_q8_k_tile (const void *A_q8, const void *B, const float *bias, float *C, int M, int N, int K, int m0, int m1, int n0, int n1) |
| Compute one C[m0:m1, n0:n1] tile for Q8_K activations x Q6_K weights. | |
| void | gemm_nt_q6_k_q8_k_tiled (const void *A_q8, const void *B, const float *bias, float *C, int M, int N, int K) |
| Experimental single-thread tiled NT GEMM wrapper. | |
| void | gemm_nt_q8_0 (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_q8_0_q8_0 (const void *A_q8, const void *B, const float *bias, float *C, int M, int N, int K) |
| gemm_nt_q8_0_q8_0 with optional bias (matches header signature) | |
| void | gemm_nt_q8_0_q8_0_contract (const float *A, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_q8_0_q8_0_m2n4 (const void *A_q8, const void *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_nt_q8_0_q8_0_m2n4_tile (const void *A_q8, const void *B, const float *bias, float *C, int M, int N, int K, int ldc) |
| void | gemm_q4_k (float *Y, const void *W, const float *X, int M, int N, int K) |
| Auto-dispatch GEMM based on available SIMD. | |
| void | gemm_q4_k_q8_k (float *Y, const void *W, const void *X_q8, int M, int N, int K) |
| void | gemm_q6_k (float *Y, const void *W, const float *X, int M, int N, int K) |
| void | gemm_q6_k_q8_k (float *Y, const void *W, const void *X_q8, int M, int N, int K) |
| GEMM: Y = W @ X^T where W is Q6_K and X is Q8_K. | |
| void | gemm_swiglu_fused (const float *x, const float *W_gate, const float *W_up, const float *b_gate, const float *b_up, float *output, int M, int N, int K) |
| void | gemm_tn_avx512 (const float *A, const float *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_tn_blocked (const float *A, const float *B, const float *bias, float *C, int M, int N, int K) |
| void | gemm_tn_parallel (const float *A, const float *B, const float *bias, float *C, int M, int N, int K) |
| void | gemma4_final_logit_softcap_forward (float *logits, int tokens, int vocab_size, float cap) |
| void | gemma4_per_layer_embed_forward (float *hidden, const float *per_layer_input, const float *inp_gate, const float *proj, const float *post_norm, const float *out_scale, int tokens, int layer, int num_layers, int embed_dim, int per_layer_dim, float eps) |
| void | gemma4_per_layer_prepare_bf16_forward (float *per_layer_input, const float *hidden, const int32_t *token_ids, const uint16_t *per_layer_token_emb, const uint16_t *per_layer_model_proj, const float *per_layer_proj_norm, int tokens, int num_layers, int embed_dim, int per_layer_dim, int vocab_size, float eps) |
| void | gemma4_per_layer_prepare_forward (float *per_layer_input, const float *hidden, const int32_t *token_ids, const void *per_layer_token_emb, const uint16_t *per_layer_model_proj, const float *per_layer_proj_norm, int tokens, int num_layers, int embed_dim, int per_layer_dim, int vocab_size, float eps) |
| void | gemma4_v_norm_forward (const float *input, float *output, float *rstd_cache, int tokens, int num_kv_heads, int head_dim, float eps) |
| void | gemma4_v_norm_forward_parallel_dispatch (const float *input, float *output, float *rstd_cache, int tokens, int num_kv_heads, int head_dim, float eps) |
| void | gemma4_vision_projector_prep_forward (const float *input, float *output, int tokens, int dim, float scale, float eps) |
| void | gemv_bf16 (float *y, const void *W, const float *x, int M, int K) |
| void | gemv_bf16_bf16_storage (float *y, const void *W, const float *x, int M, int K) |
| void | gemv_bf16_bf16_storage_parallel_dispatch (float *y, const void *W, const float *x, int M, int K) |
| void | gemv_bf16_parallel_dispatch (float *y, const void *W, const float *x, int M, int K) |
| void | gemv_fused_q5_0_bias_dispatch (float *y, const void *W, const float *x, const float *bias, int M, int K) |
| void | gemv_fused_q8_0_bias_dispatch (float *y, const void *W, const float *x, const float *bias, int M, int K) |
| void | gemv_q4_0 (float *y, const void *W, const float *x, int M, int K) |
| Auto-dispatch GEMV. | |
| void | gemv_q4_k (float *y, const void *W, const float *x, int M, int K) |
| Auto-dispatch GEMV based on available SIMD. | |
| void | gemv_q4_k_q8_k (float *y, const void *W, const void *x_q8, int M, int K) |
| void | gemv_q4_k_q8_k_parallel (float *y, const void *W, const void *x_q8, int M, int K, int ith, int nth) |
| void | gemv_q4_k_q8_k_parallel_simd (float *y, const void *W, const void *x_q8, int M, int K, int ith, int nth) |
| void | gemv_q4_k_q8_k_ref (float *y, const void *W, const void *x_q8, int M, int K) |
| void | gemv_q5_0 (float *y, const void *W, const float *x, int M, int K) |
| Auto-dispatch GEMV for Q5_0 weights based on CPU features. | |
| void | gemv_q5_0_parallel (float *y, const void *W, const float *x, int M, int K, int ith, int nth) |
| Parallel reference GEMV for Q5_0 × FP32. | |
| void | gemv_q5_0_parallel_simd (float *y, const void *W, const float *x, int M, int K, int ith, int nth) |
| Parallel SIMD GEMV for Q5_0 × FP32 with prefetching. | |
| void | gemv_q5_0_q8_0 (float *y, const void *W, const void *x_q8, int M, int K) |
| Matrix-vector multiply with Q5_0 weights and Q8_0 input. | |
| void | gemv_q5_1 (float *y, const void *W, const float *x, int M, int K) |
| Auto-dispatch GEMV. | |
| void | gemv_q5_1_q8_1 (float *y, const void *W, const float *x, int M, int K) |
| void | gemv_q5_1_q8_1_ref (float *y, const void *W, const void *x_q8, int M, int K) |
| void | gemv_q5_k (float *y, const void *W, const float *x, int M, int K) |
| void | gemv_q5_k_q8_k (float *y, const void *W, const void *x_q8, int M, int K) |
| void | gemv_q6_k (float *y, const void *W, const float *x, int M, int K) |
| void | gemv_q6_k_q8_k (float *y, const void *W, const void *x_q8, int M, int K) |
| GEMV: y = W @ x where W is Q6_K and x is Q8_K. | |
| void | gemv_q6_k_q8_k_parallel (float *y, const void *W, const void *x_q8, int M, int K, int ith, int nth) |
| Parallel reference GEMV for Q6_K × Q8_K. | |
| void | gemv_q6_k_q8_k_parallel_simd (float *y, const void *W, const void *x_q8, int M, int K, int ith, int nth) |
| Parallel SIMD GEMV for Q6_K × Q8_K. | |
| void | gemv_q8_0 (float *y, const void *W, const float *x, int M, int K) |
| Auto-dispatch GEMV for Q8_0 weights based on CPU features. | |
| void | gemv_q8_0_q8_0 (float *y, const void *W, const void *x_q8, int M, int K) |
| Matrix-vector multiply with Q8_0 weights and Q8_0 input. | |
| void | gemv_q8_0_q8_0_contract (float *y, const void *W, const float *x, int M, int K) |
| void | gemv_q8_0_q8_0_x4 (float *y, const void *W, const void *x_q8, int M, int K) |
| void | gradient_accumulate_f32 (float *dst, const float *src, size_t numel) |
| void | gradient_accumulate_multi_f32 (float *const *dsts, const float *const *srcs, const size_t *numels, int tensor_count) |
| float | gradient_clip_norm_f32 (float *grad, size_t numel, float max_norm) |
| Clip gradient norm (fp32) | |
| float | gradient_global_norm_multi_f32 (const float *const *grads, const size_t *numels, int tensor_count) |
| void | gradient_scale_f32 (float *grad, size_t numel, float scale) |
| void | group_limited_topk_router_sigmoid_f32 (const float *logits, const float *correction_bias, int *indices, float *weights, int rows, int n_experts, int top_k, int n_group, int topk_group, int norm_topk_prob, float routed_scaling_factor) |
| void | hyper_connection_mix_bf16 (const float *hyper_input, const float *norm_weight, const uint16_t *mix_down_weight, const uint16_t *mix_up_weight, const uint16_t *inject_weight, float *mixed_output, float *injection_output, float *normalized_scratch, float *dynamic_scratch, float *mix_scratch, int rows, int streams, int hidden_dim, int dynamic_dim, float eps, int emit_injection) |
| void | hyper_connection_mix_q4k_q5_0_q4k (const float *hyper_input, const float *norm_weight, const void *mix_down_weight, const void *mix_up_weight, const void *inject_weight, float *mixed_output, float *injection_output, float *normalized_scratch, float *dynamic_scratch, float *mix_scratch, int rows, int streams, int hidden_dim, int dynamic_dim, float eps, int emit_injection) |
| void | hyper_connection_mix_q6k_q5_0_q4k (const float *hyper_input, const float *norm_weight, const void *mix_down_weight, const void *mix_up_weight, const void *inject_weight, float *mixed_output, float *injection_output, float *normalized_scratch, float *dynamic_scratch, float *mix_scratch, int rows, int streams, int hidden_dim, int dynamic_dim, float eps, int emit_injection) |
| void | hyper_stream_expand_bf16 (const float *input, float *output, int rows, int streams, int hidden_dim) |
| void | hyper_stream_expand_f32 (const float *input, float *output, int rows, int streams, int hidden_dim) |
| void | hyper_stream_inject_bf16 (const float *hyper_input, const float *block_output, const float *injection_weight, float *output, int rows, int streams, int hidden_dim) |
| void | hyper_stream_inject_f32 (const float *hyper_input, const float *block_output, const float *injection_weight, float *output, int rows, int streams, int hidden_dim) |
| void | im2patch (const float *image, float *patches, int C, int H, int W, int P) |
| void | im2patch_bf16 (const uint16_t *image, uint16_t *patches, int C, int H, int W, int P) |
| void | kv_cache_repack_head_major_inplace (float *buf, int num_heads, int tokens, int cache_capacity, int aligned_head_dim) |
| void | kv_cache_store (float *__restrict kv_cache_k, float *__restrict kv_cache_v, const float *__restrict k, const float *__restrict v, int layer, int pos, int num_kv_heads, int head_dim, int max_seq_len) |
| void | kv_cache_store_batch_bf16 (uint16_t *__restrict kv_cache_k, uint16_t *__restrict kv_cache_v, const float *__restrict k, const float *__restrict v, int start_pos, int num_tokens, int num_kv_heads, int head_dim, int max_seq_len) |
| void | kv_cache_store_batch_f16 (uint16_t *__restrict kv_cache_k, uint16_t *__restrict kv_cache_v, const float *__restrict k, const float *__restrict v, int start_pos, int num_tokens, int num_kv_heads, int head_dim, int max_seq_len) |
| void | kv_cache_store_batch_f32 (float *__restrict kv_cache_k, float *__restrict kv_cache_v, const float *__restrict k, const float *__restrict v, int start_pos, int num_tokens, int num_kv_heads, int head_dim, int max_seq_len) |
| void | kv_cache_store_bf16 (uint16_t *__restrict kv_cache_k, uint16_t *__restrict kv_cache_v, const float *__restrict k, const float *__restrict v, int layer, int pos, int num_kv_heads, int head_dim, int max_seq_len) |
| void | kv_cache_store_f16 (uint16_t *__restrict kv_cache_k, uint16_t *__restrict kv_cache_v, const float *__restrict k, const float *__restrict v, int layer, int pos, int num_kv_heads, int head_dim, int max_seq_len) |
| void | kv_cache_store_shared_q (float *__restrict kv_cache_k, float *__restrict kv_cache_v, const float *__restrict q, int layer, int pos, int num_heads, int head_dim, int max_seq_len) |
| void | kv_cache_write_head_major (const float *__restrict k_token, const float *__restrict v_token, float *__restrict k_cache, float *__restrict v_cache, int num_kv_heads, int token_index, int cache_capacity, int head_dim, int aligned_head_dim) |
| void | layernorm_backward_kernel (const float *d_output, const float *input, const float *gamma, const float *mean, const float *rstd, float *d_input, float *d_gamma, float *d_beta, int tokens, int d_model, int aligned_embed_dim) |
| void | layernorm_backward_kernel_bf16 (const uint16_t *d_output, const uint16_t *input, const float *gamma, const float *mean, const float *rstd, uint16_t *d_input, float *d_gamma, float *d_beta, int tokens, int d_model, int aligned_embed_dim, float *scratch_d_output, float *scratch_input, float *scratch_d_input) |
| void | layernorm_forward_rolled_slice (const float *__restrict input_slice_base, const float *__restrict gamma, const float *__restrict beta, float *__restrict output_slice_base, float *__restrict mean_cache_slice, float *__restrict rstd_cache_slice, int num_tokens_in_slice, int d_model, int aligned_embed_dim, float eps) |
| void | layernorm_forward_rolled_slice_bf16 (const uint16_t *__restrict input_slice_base, const float *__restrict gamma, const float *__restrict beta, uint16_t *__restrict output_slice_base, float *__restrict mean_cache_slice, float *__restrict rstd_cache_slice, int num_tokens_in_slice, int d_model, int aligned_embed_dim, float eps, float *scratch_input, float *scratch_output) |
| void | layernorm_forward_unrolled_slice (const float *__restrict input_slice_base, const float *__restrict gamma, const float *__restrict beta, float *__restrict output_slice_base, float *__restrict mean_cache_slice, float *__restrict rstd_cache_slice, int num_tokens_in_slice, int d_model, float eps) |
| void | layernorm_forward_unrolled_slice_bf16 (const uint16_t *__restrict input_slice_base, const float *__restrict gamma, const float *__restrict beta, uint16_t *__restrict output_slice_base, float *__restrict mean_cache_slice, float *__restrict rstd_cache_slice, int num_tokens_in_slice, int d_model, float eps, float *scratch_input, float *scratch_output) |
| void | layernorm_naive_serial (const float *input, const float *gamma, const float *beta, float *output, float *mean_cache, float *rstd_cache, int tokens, int d_model, int aligned_embed_dim, float eps) |
| void | layernorm_naive_serial_bf16_storage (const float *input, const float *gamma, const float *beta, float *output, float *mean_cache, float *rstd_cache, int tokens, int d_model, float eps) |
| void | layernorm_naive_serial_matched_precision (const float *input, const float *gamma, const float *beta, float *output, float *mean_cache, float *rstd_cache, int tokens, int d_model, float eps) |
| void | layernorm_pytorch_welford_bf16_storage (const float *input, const float *gamma, const float *beta, float *output, float *mean_cache, float *rstd_cache, int tokens, int d_model, float eps) |
| void | mamba2_conv1d_decode_f32 (const float *state_in, const float *x, const float *weight, const float *bias, float *conv_out, float *state_out, int rows, int conv_dim, int kernel_size) |
| void | mamba2_conv1d_f32_channel_range (const float *state_in, const float *x, const float *weight, const float *bias, float *conv_out, float *state_out, int rows, int conv_dim, int kernel_size, int channel_begin, int channel_end) |
| void | mamba2_conv1d_f32_parallel_dispatch (const float *state_in, const float *x, const float *weight, const float *bias, float *conv_out, float *state_out, int rows, int conv_dim, int kernel_size) |
| void | mamba2_dt_softplus_f32 (const float *dt, const float *dt_bias, float *dt_out, int rows, int num_heads, float dt_min, float dt_max) |
| void | mamba2_in_proj_split_f32 (const float *projected, float *gate, float *hidden_bc, float *dt, int rows, int d_mlp, int intermediate_dim, int conv_dim, int num_heads) |
| void | mamba2_rmsnorm_gate_f32 (const float *x, const float *gate, const float *weight, float *out, int rows, int inner_dim, int group_size, float eps) |
| void | mamba2_selective_scan_f32 (const float *state_init, const float *x, const float *dt, const float *a, const float *b, const float *c, const float *d, float *state_out, float *y, int batch, int seq_len, int num_heads, int head_dim, int state_dim, int num_groups) |
| void | mamba2_selective_scan_f32_head_range (const float *state_init, const float *x, const float *dt, const float *a, const float *b, const float *c, const float *d, float *state_out, float *y, int batch, int seq_len, int num_heads, int head_dim, int state_dim, int num_groups, int head_begin, int head_end) |
| void | mamba2_selective_scan_f32_parallel_dispatch (const float *state_init, const float *x, const float *dt, const float *a, const float *b, const float *c, const float *d, float *state_out, float *y, int batch, int seq_len, int num_heads, int head_dim, int state_dim, int num_groups) |
| void | mamba2_selective_state_update_decode_f32 (const float *state_in, const float *x, const float *dt, const float *a, const float *b, const float *c, const float *d, float *state_out, float *y, int rows, int num_heads, int head_dim, int state_dim, int num_groups) |
| void | mlp_token_parallel (const float *input, const float *W_fc1, const float *b_fc1, const float *W_fc2, const float *b_fc2, float *fc1_output, float *output, int T, int aligned_dim, int num_threads) |
| void | mlp_token_parallel_bf16 (const uint16_t *input, const uint16_t *W_fc1, const uint16_t *b_fc1, const uint16_t *W_fc2, const uint16_t *b_fc2, float *fc1_output, float *output, int T, int aligned_dim, int num_threads, float *scratch_bias1_f, float *scratch_bias2_f, uint16_t *scratch_fc1_bf16) |
| void | mlp_token_parallel_bf16_backward_mixed (const uint16_t *input, const uint16_t *W_fc1, const uint16_t *b_fc1, const uint16_t *W_fc2, const uint16_t *d_output, float *d_input, float *d_W_fc1, float *d_b_fc1, float *d_W_fc2, float *d_b_fc2, int T, int aligned_dim, int num_threads, float *scratch_fc1_pre, uint16_t *scratch_fc1_act_bf16, float *scratch_d_fc1) |
| void | mlp_token_parallel_bf16_fp32act (const uint16_t *input, const uint16_t *W_fc1, const uint16_t *b_fc1, const uint16_t *W_fc2, const uint16_t *b_fc2, float *fc1_output, float *output, int T, int aligned_dim, int num_threads, float *scratch_input_f, float *scratch_bias1_f, float *scratch_bias2_f, uint16_t *scratch_fc1_bf16) |
| void | mlp_token_parallel_exact (const float *input, const float *W_fc1, const float *b_fc1, const float *W_fc2, const float *b_fc2, float *fc1_output, float *output, int T, int aligned_dim, int num_threads) |
| 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) |
| int | moe_softmax_topk_router_llama_f32_workspace (const float *logits, int *indices, float *weights, int rows, int n_experts, int top_k, float routed_scaling_factor, void *workspace, size_t workspace_bytes) |
| int | moe_softmax_topk_router_pytorch_bf16_workspace (const float *logits, int *indices, float *weights, int rows, int n_experts, int top_k, float routed_scaling_factor, void *workspace, size_t workspace_bytes) |
| size_t | moe_softmax_topk_router_workspace_bytes (int n_experts) |
| 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_parallel_dispatch (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_prepared_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_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_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_parallel_dispatch (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_parallel_dispatch (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_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 | mrope_qk_imrope_positions (float *q, float *k, const int32_t *positions, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int n_dims, int section_0, int section_1, int section_2, int section_3, int n_ctx_orig, float freq_base, float freq_scale, float ext_factor, float attn_factor, float beta_fast, float beta_slow) |
| void | mrope_qk_text (float *q, float *k, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int n_dims, int section_0, int section_1, int section_2, int section_3, int n_ctx_orig, float freq_base, float freq_scale, float ext_factor, float attn_factor, float beta_fast, float beta_slow) |
| void | mrope_qk_text_imrope (float *q, float *k, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int n_dims, int section_0, int section_1, int section_2, int section_3, int n_ctx_orig, float freq_base, float freq_scale, float ext_factor, float attn_factor, float beta_fast, float beta_slow) |
| void | mrope_qk_text_imrope_bf16_pytorch_storage (float *q, float *k, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int n_dims, int section_0, int section_1, int section_2, int section_3, int n_ctx_orig, float freq_base, float freq_scale, float ext_factor, float attn_factor, float beta_fast, float beta_slow) |
| void | mrope_qk_text_imrope_positions_bf16_pytorch_storage (float *q, float *k, const int32_t *positions, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int n_dims, int section_0, int section_1, int section_2, int section_3, int n_ctx_orig, float freq_base, float freq_scale, float ext_factor, float attn_factor, float beta_fast, float beta_slow) |
| void | mrope_qk_vision (float *q, float *k, const int32_t *positions, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int n_dims, int section_0, int section_1, int section_2, int section_3, int n_ctx_orig, float freq_base, float freq_scale, float ext_factor, float attn_factor, float beta_fast, float beta_slow) |
| void | mrope_qk_vision_bf16_pytorch_storage (float *q, float *k, const int32_t *positions, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int n_dims, int section_0, int section_1, int section_2, int section_3, int n_ctx_orig, float freq_base, float freq_scale, float ext_factor, float attn_factor, float beta_fast, float beta_slow) |
| void | mrope_qk_vision_bf16_storage (float *q, float *k, const int32_t *positions, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int n_dims, int section_0, int section_1, int section_2, int section_3, int n_ctx_orig, float freq_base, float freq_scale, float ext_factor, float attn_factor, float beta_fast, float beta_slow) |
| void | mrope_qk_vision_fp16_storage (float *q, float *k, const int32_t *positions, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int n_dims, int section_0, int section_1, int section_2, int section_3, int n_ctx_orig, float freq_base, float freq_scale, float ext_factor, float attn_factor, float beta_fast, float beta_slow) |
| void | nemotron_group_limited_topk_router_f32 (const float *scores, const float *correction_bias, int *indices, float *weights, int rows, int n_experts, int top_k, int n_group, int topk_group, int norm_topk_prob, float routed_scaling_factor) |
| void | patch2im (const float *d_patches, float *d_image, int C, int H, int W, int P) |
| void | patch2im_bf16 (const uint16_t *d_patches, uint16_t *d_image, int C, int H, int W, int P) |
| void | patch_projection_bf16_pytorch_onednn_conv3d_storage (const float *input, const void *weights, const float *bias, float *output, int batch, int out_channels, int in_channels, int temporal, int patch_h, int patch_w) |
| void | patch_projection_image_bf16_native_storage (const float *image, const void *weights_t0, const void *weights_t1, const float *bias, float *output, int channels, int image_h, int image_w, int patch_size, int out_channels, int merge_size) |
| void | patch_projection_image_bf16_pytorch_onednn_conv3d_storage (const float *image, const void *weights_t0, const void *weights_t1, const float *bias, float *output, int channels, int image_h, int image_w, int patch_size, int out_channels, int merge_size) |
| void | position_embeddings_add (float *x, const float *position_embd, int num_tokens, int embed_dim, int num_positions) |
| void | position_embeddings_add_at_offset (float *x, const float *position_embd, int num_tokens, int embed_dim, int num_positions, int start_position) |
| void | position_embeddings_add_gemma4v_xy (float *x, const float *position_embd, int grid_h, int grid_w, int embed_dim, int source_grid_size) |
| void | position_embeddings_add_tiled_2d (float *x, const float *position_embd, int grid_h, int grid_w, int embed_dim, int merge_size, int source_grid_size) |
| void | position_embeddings_add_tiled_2d_align_corners (float *x, const float *position_embd, int grid_h, int grid_w, int embed_dim, int merge_size, int source_grid_size) |
| void | position_embeddings_add_tiled_2d_align_corners_bf16 (float *x, const float *position_embd, int grid_h, int grid_w, int embed_dim, int merge_size, int source_grid_size) |
| void | position_embeddings_add_tiled_2d_align_corners_fp32_interp_bf16 (float *x, const float *position_embd, int grid_h, int grid_w, int embed_dim, int merge_size, int source_grid_size) |
| void | q_norm_forward (float *q, const float *q_gamma, int num_heads, int num_tokens, int head_dim, float eps) |
| void | qk_norm_backward (const float *d_q_out, const float *d_k_out, const float *q_in, const float *k_in, const float *q_gamma, const float *k_gamma, float *d_q_in, float *d_k_in, float *d_q_gamma, float *d_k_gamma, int num_heads, int num_kv_heads, int num_tokens, int head_dim, float eps) |
| int | qk_norm_backward_last_isa (void) |
| void | qk_norm_forward (float *q, float *k, const float *q_gamma, const float *k_gamma, int num_heads, int num_kv_heads, int num_tokens, int head_dim, float eps) |
| void | qk_norm_forward_decode_exact (float *q, float *k, const float *q_gamma, const float *k_gamma, int num_heads, int num_kv_heads, int num_tokens, int head_dim, float eps) |
| void | qk_norm_forward_fp64_sum (float *q, float *k, const float *q_gamma, const float *k_gamma, int num_heads, int num_kv_heads, int num_tokens, int head_dim, float eps) |
| void | qk_norm_forward_llama_production (float *q, float *k, const float *q_gamma, const float *k_gamma, int num_heads, int num_kv_heads, int num_tokens, int head_dim, float eps) |
| void | qk_norm_forward_parallel_dispatch (float *q, float *k, const float *q_gamma, const float *k_gamma, int num_heads, int num_kv_heads, int num_tokens, int head_dim, float eps) |
| void | qk_norm_forward_prefill_exact (float *q, float *k, const float *q_gamma, const float *k_gamma, int num_heads, int num_kv_heads, int num_tokens, int head_dim, float eps) |
| void | qk_norm_forward_pytorch_bf16_storage (float *q, float *k, const float *q_gamma, const float *k_gamma, int num_heads, int num_kv_heads, int num_tokens, int head_dim, float eps) |
| void | qk_norm_forward_qwen4_pytorch_bf16_storage (float *q, float *k, const float *q_gamma, const float *k_gamma, int num_heads, int num_kv_heads, int num_tokens, int head_dim, float eps) |
| void | quantize_batch_q8_0 (const float *x, void *y, int num_rows, int k) |
| Batch quantize FP32 to Q8_0 format (row-major output) | |
| void | quantize_batch_q8_k (const float *x, void *y, int num_rows, int k) |
| Batch quantize FP32 to Q8_K format (row-major output) | |
| void | quantize_batch_q8_k_4row_nearest_even (const float *x, void *y, int num_rows, int k) |
| void | quantize_row_q8_0 (const float *x, void *y, int k) |
| Quantize FP32 to Q8_0 format (scalar reference) | |
| void | quantize_row_q8_k (const float *x, void *y, int k) |
| void | qwen4_ple_gate_conv_inject_bf16 (const float *hyper_input, const float *key_projected, const float *value_projected, const float *norm_key_weight, const float *norm_query_weight, const float *norm_conv_weight, const uint16_t *conv_weight, float *hyper_output, float *key_norm_scratch, float *query_norm_scratch, float *gated_scratch, float *conv_norm_scratch, const float *conv_state_in, float *conv_state_out, int rows, int streams, int hidden_dim, int kernel_size, int dilation, float eps) |
| void | qwen4_ple_gate_conv_inject_fp16 (const float *hyper_input, const float *key_projected, const float *value_projected, const float *norm_key_weight, const float *norm_query_weight, const float *norm_conv_weight, const uint16_t *conv_weight, float *hyper_output, float *key_norm_scratch, float *query_norm_scratch, float *gated_scratch, float *conv_norm_scratch, const float *conv_state_in, float *conv_state_out, int rows, int streams, int hidden_dim, int kernel_size, int dilation, float eps) |
| void | qwen4_ple_gate_conv_inject_llama_fp16 (const float *hyper_input, const float *key_projected, const float *value_projected, const float *norm_key_weight, const float *norm_query_weight, const float *norm_conv_weight, const uint16_t *conv_weight, float *hyper_output, float *key_norm_scratch, float *query_norm_scratch, float *gated_scratch, float *conv_norm_scratch, const float *conv_state_in, float *conv_state_out, int rows, int streams, int hidden_dim, int kernel_size, int dilation, float eps) |
| void | qwen4_ple_ngram_embed_bf16 (const int32_t *token_ids, const uint16_t *embedding, const int64_t *layer_multipliers, const int64_t *head_offsets, const int64_t *head_vocab_sizes, float *output, const float *token_state_in, float *token_state_out, int rows, int ngram_size, int heads_per_ngram, int head_dim, int eos_token_id, int position) |
| void | qwen4_ple_ngram_embed_q5_0 (const int32_t *token_ids, const void *embedding, const int64_t *layer_multipliers, const int64_t *head_offsets, const int64_t *head_vocab_sizes, float *output, const float *token_state_in, float *token_state_out, int rows, int ngram_size, int heads_per_ngram, int head_dim, int eos_token_id, int position) |
| void | qwen4_qsa_index_select_bf16 (const float *projected_qk, const float *index_key_cache_in, const float *q_norm_weight, const float *k_norm_weight, float *selected_indices, float *index_key_cache_out, float *q_norm_scratch, float *pooled_key_scratch, float *block_score_scratch, int32_t *block_index_scratch, int rows, int query_heads, int index_head_dim, int token_budget, int compress_ratio, int rotary_dim, int context_length, int position, float rope_theta, float eps) |
| void | recurrent_conv_state_update_backward (const float *d_conv_x, const float *d_state_out, float *d_state_in, float *d_q, float *d_k, float *d_v, int history_len, int num_seqs, int num_tokens, int q_dim, int k_dim, int v_dim) |
| void | recurrent_conv_state_update_backward_workspace (const float *d_conv_x, const float *d_state_out, float *d_state_in, float *d_q, float *d_k, float *d_v, float *d_conv_total, int history_len, int num_seqs, int num_tokens, int q_dim, int k_dim, int v_dim) |
| void | recurrent_conv_state_update_forward (const float *state_in, const float *q, const float *k, const float *v, float *conv_x, float *state_out, int history_len, int num_seqs, int num_tokens, int q_dim, int k_dim, int v_dim) |
| void | recurrent_dt_gate_backward (const float *d_gate, const float *alpha, const float *dt_bias, const float *a, float *d_alpha, float *d_dt_bias, float *d_a, int rows, int dim) |
| void | recurrent_dt_gate_expanded_forward (const float *alpha, const float *dt_bias, const float *a, float *gate, int rows, int num_heads, int state_dim) |
| void | recurrent_dt_gate_forward (const float *alpha, const float *dt_bias, const float *a, float *gate, int rows, int num_heads, int state_dim) |
| void | recurrent_dt_gate_forward_pytorch_fp32 (const float *alpha, const float *dt_bias, const float *a, float *gate, int rows, int num_heads, int state_dim) |
| void | recurrent_norm_gate_backward (const float *d_out, const float *x, const float *gate, const float *weight, float *d_x, float *d_gate, float *d_weight, int rows, int num_heads, int head_dim, float eps) |
| void | recurrent_norm_gate_forward (const float *x, const float *gate, const float *weight, float *out, int rows, int num_heads, int head_dim, float eps) |
| void | recurrent_norm_gate_llama_avx2_forward (const float *x, const float *gate, const float *weight, float *out, int rows, int num_heads, int head_dim, float eps) |
| void | recurrent_norm_gate_pytorch_bf16_storage (const float *x, const float *gate, const float *weight, float *out, int rows, int num_heads, int head_dim, float eps) |
| void | recurrent_norm_sigmoid_gate_llama_avx2_forward (const float *x, const float *gate, const float *weight, float *out, int rows, int num_heads, int head_dim, float eps) |
| void | recurrent_norm_sigmoid_gate_pytorch_bf16_storage (const float *x, const float *gate, const float *weight, float *out, int rows, int num_heads, int head_dim, float eps) |
| void | recurrent_qk_l2_norm_backward (const float *d_q_out, const float *d_k_out, const float *q, const float *k, float *d_q, float *d_k, int rows, int q_dim, int k_dim, int head_dim, float eps) |
| void | recurrent_qk_l2_norm_forward (float *q, float *k, int rows, int q_dim, int k_dim, int head_dim, float eps) |
| void | recurrent_qk_l2_norm_pytorch_bf16_storage (float *q, float *k, int rows, int q_dim, int k_dim, int expanded_heads, int head_dim, float eps) |
| void | recurrent_qk_l2_norm_pytorch_fp32_output (float *q, float *k, int rows, int q_dim, int k_dim, int head_dim, float eps) |
| void | recurrent_sigmoid_forward_ggml (const float *x, float *out, int rows, int dim) |
| void | recurrent_sigmoid_forward_pytorch_bf16_input_fp32_output (const float *x, float *out, int rows, int dim) |
| void | recurrent_silu_backward (const float *d_out, const float *x, float *d_x, int rows, int dim) |
| void | recurrent_silu_forward (const float *x, float *out, int rows, int dim) |
| void | recurrent_silu_forward_ggml (const float *x, float *out, int rows, int dim) |
| void | recurrent_silu_forward_pytorch_bf16_input_fp32_output (const float *x, float *out, int rows, int dim) |
| void | recurrent_silu_forward_pytorch_bf16_storage (const float *x, float *out, int rows, int dim) |
| void | recurrent_split_conv_qkv_backward (const float *d_q, const float *d_k, const float *d_v, float *d_packed_qkv, int rows, int q_dim, int k_dim, int v_dim) |
| void | recurrent_split_conv_qkv_forward (const float *packed_qkv, float *q, float *k, float *v, int rows, int q_dim, int k_dim, int v_dim) |
| void | recurrent_split_qkv_backward (const float *d_q, const float *d_k, const float *d_v, float *d_packed_qkv, int rows, int q_dim, int k_dim, int v_dim) |
| void | recurrent_split_qkv_forward (const float *packed_qkv, float *q, float *k, float *v, int rows, int q_dim, int k_dim, int v_dim) |
| void | relu2_backward (const float *input, const float *d_output, float *d_input, size_t n) |
| void | relu2_forward (const float *input, float *output, size_t n) |
| void | relu_backward (const float *input, const float *d_output, float *d_input, size_t n) |
| void | relu_backward_bf16 (const uint16_t *input, const uint16_t *d_output, uint16_t *d_input, size_t n) |
| void | relu_forward (const float *input, float *output, size_t n) |
| void | relu_forward_bf16 (const uint16_t *input, uint16_t *output, size_t n) |
| void | relu_forward_inplace (float *data, size_t n) |
| void | relu_forward_inplace_bf16 (uint16_t *data, size_t n) |
| void | rmsnorm_backward (const float *d_output, const float *input, const float *gamma, const float *rstd_cache, float *d_input, float *d_gamma, int tokens, int d_model, int aligned_embed_dim) |
| void | rmsnorm_backward_bf16 (const uint16_t *d_output, const uint16_t *input, const float *gamma, const float *rstd_cache, uint16_t *d_input, float *d_gamma, int tokens, int d_model, int aligned_embed_dim) |
| void | rmsnorm_backward_int4 (const uint8_t *d_output, const uint8_t *input, const float *gamma, const float *rstd_cache, uint8_t *d_input, float *d_gamma, int tokens, int d_model, int aligned_embed_dim, float *scratch_d_output, float *scratch_input, float *scratch_d_input) |
| void | rmsnorm_backward_int8 (const int8_t *d_output, const int8_t *input, const float *gamma, const float *rstd_cache, int8_t *d_input, float *d_gamma, int tokens, int d_model, int aligned_embed_dim, float *scratch_d_output, float *scratch_input, float *scratch_d_input) |
| void | rmsnorm_forward (const float *input, const float *gamma, float *output, float *rstd_cache, int tokens, int d_model, int aligned_embed_dim, float eps) |
| void | rmsnorm_forward_bf16 (const uint16_t *input, const float *gamma, uint16_t *output, float *rstd_cache, int tokens, int d_model, int aligned_embed_dim, float eps) |
| void | rmsnorm_forward_fp32_square_fp64_sum (const float *input, const float *gamma, float *output, float *rstd_cache, int tokens, int d_model, int aligned_embed_dim, float eps) |
| void | rmsnorm_forward_fp64_sum (const float *input, const float *gamma, float *output, float *rstd_cache, int tokens, int d_model, int aligned_embed_dim, float eps) |
| void | rmsnorm_forward_int4 (const uint8_t *input, const float *gamma, uint8_t *output, float *rstd_cache, int tokens, int d_model, int aligned_embed_dim, float eps, float *scratch_input, float *scratch_output) |
| void | rmsnorm_forward_int8 (const int8_t *input, const float *gamma, int8_t *output, float *rstd_cache, int tokens, int d_model, int aligned_embed_dim, float eps, float *scratch_input, float *scratch_output) |
| void | rmsnorm_forward_kv_lora (const float *input, const float *gamma, float *output, float *rstd_cache, int tokens, int d_model, int aligned_embed_dim, float eps) |
| void | rmsnorm_forward_llama_production (const float *input, const float *gamma, float *output, float *rstd_cache, int tokens, int d_model, int aligned_embed_dim, float eps) |
| void | rmsnorm_forward_no_weight (const float *input, float *output, float *rstd_cache, int tokens, int d_model, int aligned_embed_dim, float eps) |
| void | rmsnorm_forward_parallel_dispatch (const float *input, const float *gamma, float *output, float *rstd_cache, int tokens, int d_model, int aligned_embed_dim, float eps) |
| void | rmsnorm_forward_pytorch_bf16_storage (const float *input, const float *gamma, float *output, float *rstd_cache, int tokens, int d_model, int aligned_embed_dim, float eps) |
| void | rmsnorm_forward_qwen3next_pytorch_bf16_storage (const float *input, const float *gamma, float *output, float *rstd_cache, int tokens, int d_model, int aligned_embed_dim, float eps) |
| void | rmsnorm_forward_strided_f32 (const float *input, const float *gamma, float *output, float *rstd_cache, int tokens, int d_model, int input_stride, int output_stride, float eps) |
| void | rmsnorm_forward_strided_pytorch_bf16_storage (const float *input, const float *gamma, float *output, float *rstd_cache, int tokens, int d_model, int input_stride, int output_stride, float eps) |
| void | rope_backward (const float *d_out, float *d_x, const float *cos_cache, const float *sin_cache, int num_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset) |
| void | rope_backward_bf16 (const uint16_t *d_out, uint16_t *d_x, const float *cos_cache, const float *sin_cache, int num_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, float *scratch_d_out, float *scratch_d_x) |
| void | rope_backward_inplace (float *d_x, const float *cos_cache, const float *sin_cache, int num_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset) |
| void | rope_backward_qk (const float *d_q_out, const float *d_k_out, float *d_q, float *d_k, const float *cos_cache, const float *sin_cache, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset) |
| void | rope_backward_qk_bf16 (const uint16_t *d_q_out, const uint16_t *d_k_out, uint16_t *d_q, uint16_t *d_k, const float *cos_cache, const float *sin_cache, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, float *scratch_dq_out, float *scratch_dq, float *scratch_dk_out, float *scratch_dk) |
| void | rope_backward_qk_pairwise_with_rotary_dim (const float *d_q_out, const float *d_k_out, float *d_q, float *d_k, const float *cos_cache, const float *sin_cache, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int rotary_dim) |
| void | rope_forward (float *x, const float *cos_cache, const float *sin_cache, int num_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset) |
| void | rope_forward_bf16 (uint16_t *x, const float *cos_cache, const float *sin_cache, int num_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, float *scratch) |
| void | rope_forward_bf16_with_rotary_dim (uint16_t *x, const float *cos_cache, const float *sin_cache, int num_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int rotary_dim, float *scratch) |
| void | rope_forward_q_split_direct_f32 (float *q, const float *freq_factors, int use_freq_factors, int num_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int rotary_dim, float freq_base) |
| void | rope_forward_qk (float *q, float *k, const float *cos_cache, const float *sin_cache, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset) |
| void | rope_forward_qk_bf16 (uint16_t *q, uint16_t *k, const float *cos_cache, const float *sin_cache, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, float *scratch_q, float *scratch_k) |
| void | rope_forward_qk_bf16_with_rotary_dim (uint16_t *q, uint16_t *k, const float *cos_cache, const float *sin_cache, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int rotary_dim, float *scratch_q, float *scratch_k) |
| void | rope_forward_qk_gemma4_direct (float *q, float *k, const float *freq_factors, int use_freq_factors, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int rotary_dim, float freq_base) |
| void | rope_forward_qk_gemma4v_vision_xy (float *q, float *k, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int grid_w, int rotary_dim, float freq_base) |
| void | rope_forward_qk_pairwise_llama_cpu (float *q, float *k, const float *cos_cache, const float *sin_cache, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int rotary_dim) |
| void | rope_forward_qk_pairwise_with_rotary_dim (float *q, float *k, const float *cos_cache, const float *sin_cache, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int rotary_dim) |
| void | rope_forward_qk_split_direct_f32 (float *q, float *k, const float *freq_factors, int use_freq_factors, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int rotary_dim, float freq_base) |
| void | rope_forward_qk_split_direct_token_range_f32 (float *q, float *k, const float *freq_factors, int use_freq_factors, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int rotary_dim, float freq_base, int token_begin, int token_end) |
| void | rope_forward_qk_split_llama_token_range_f32 (float *q, float *k, const float *freq_factors, int use_freq_factors, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int rotary_dim, float freq_base, int token_begin, int token_end) |
| void | rope_forward_qk_strided (float *q, float *k, const float *cos_cache, const float *sin_cache, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int q_stride_tokens, int k_stride_tokens) |
| void | rope_forward_qk_strided_with_rotary_dim (float *q, float *k, const float *cos_cache, const float *sin_cache, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int q_stride_tokens, int k_stride_tokens, int rotary_dim) |
| void | rope_forward_qk_with_rotary_dim (float *q, float *k, const float *cos_cache, const float *sin_cache, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int rotary_dim) |
| void | rope_forward_qk_with_rotary_dim_cache_stride (float *q, float *k, const float *cos_cache, const float *sin_cache, int num_heads, int num_kv_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int rotary_dim, int cache_rotary_dim) |
| void | rope_forward_strided (float *x, const float *cos_cache, const float *sin_cache, int num_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int head_stride_tokens) |
| void | rope_forward_strided_with_rotary_dim (float *x, const float *cos_cache, const float *sin_cache, int num_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int head_stride_tokens, int rotary_dim) |
| void | rope_forward_with_rotary_dim (float *x, const float *cos_cache, const float *sin_cache, int num_heads, int num_tokens, int head_dim, int aligned_head_dim, int pos_offset, int rotary_dim) |
| void | rope_precompute_cache (float *cos_cache, float *sin_cache, int max_seq_len, int head_dim, float base, int rotary_dim, const char *scaling_type, float scaling_factor) |
| void | rope_precompute_cache_llama_cpu (float *cos_cache, float *sin_cache, int max_seq_len, int head_dim, float base, int rotary_dim, const char *scaling_type, float scaling_factor) |
| void | rope_precompute_cache_split (float *cos_cache, float *sin_cache, int max_seq_len, int head_dim, float base) |
| void | rowwise_bias_add (float *x, const float *bias, int rows, int dim) |
| void | scal_copy_f32 (float *y, const float *x, float alpha, int n) |
| Scaled copy: y = alpha * x. | |
| void | sigmoid_backward (const float *input, const float *d_output, float *d_input, size_t n) |
| void | sigmoid_backward_bf16 (const uint16_t *input, const uint16_t *d_output, uint16_t *d_input, size_t n, float *scratch_input, float *scratch_d_output, float *scratch_d_input) |
| void | sigmoid_forward (const float *input, float *output, size_t n) |
| void | sigmoid_forward_bf16 (const uint16_t *input, uint16_t *output, size_t n, float *scratch_input, float *scratch_output) |
| float | sigmoid_scalar (float x) |
| void | softmax_cross_entropy_loss (const float *logits, const int32_t *targets, int tokens, int vocab_size, float *d_logits, float *loss_out) |
| void | softmax_cross_entropy_loss_bf16 (const uint16_t *logits, const int32_t *targets, int tokens, int vocab_size, uint16_t *d_logits, float *loss_out, float *scratch_logits, float *scratch_d_logits) |
| void | softmax_cross_entropy_loss_ptref (const float *logits, const int32_t *targets, int tokens, int vocab_size, float *d_logits, float *loss_out) |
| void | spatial_average_pool_contiguous (const float *input, float *output, int grid_h, int grid_w, int embed_dim, int merge_size) |
| void | spatial_merge_2x2 (const float *input, float *output, int grid_h, int grid_w, int embed_dim) |
| void | spatial_merge_contiguous_tiled (const float *input, float *output, int grid_h, int grid_w, int embed_dim, int merge_size) |
| void | speculative_commit_one_i32 (int accepted, int verified_token, int *token_buffer, int *token_count, int max_tokens, int *target_position, int *draft_position, int *accepted_count, int *rejected_count) |
| Commit one verified speculative token and update decode counters. | |
| void | speculative_verify_greedy_f32 (const float *target_logits, int vocab_size, int draft_token, int *accepted, int *verified_token) |
| Greedy one-token speculative verification. | |
| void | split_q_gate_backward (const float *d_q, const float *d_gate, float *d_packed_qg, int rows, int q_dim, int gate_dim, int group_dim) |
| void | split_q_gate_forward (const float *packed_qg, float *q, float *gate, int rows, int q_dim, int gate_dim, int group_dim) |
| void | split_qkv_packed_head_major_forward (const float *packed_qkv, float *q, float *k, float *v, int rows, int q_dim, int k_dim, int v_dim, int num_heads, int num_kv_heads) |
| void | ssm_conv1d_backward (const float *d_out, const float *conv_x, const float *kernel, float *d_conv_x, float *d_kernel, int kernel_size, int num_channels, int num_tokens, int num_seqs) |
| void | ssm_conv1d_forward (const float *conv_x, const float *kernel, float *out, int kernel_size, int num_channels, int num_tokens, int num_seqs) |
| void | ssm_conv1d_forward_llama_fma (const float *conv_x, const float *kernel, float *out, int kernel_size, int num_channels, int num_tokens, int num_seqs) |
| void | ssm_conv1d_forward_llama_production (const float *conv_x, const float *kernel, float *out, int kernel_size, int num_channels, int num_tokens, int num_seqs) |
| void | ssm_conv1d_forward_llama_production_serial (const float *conv_x, const float *kernel, float *out, int kernel_size, int num_channels, int num_tokens, int num_seqs) |
| void | ssm_conv1d_forward_pytorch_bf16_storage (const float *conv_x, const float *kernel, float *out, int kernel_size, int num_channels, int num_tokens, int num_seqs) |
| void | swiglu_backward (const float *input, const float *d_output, float *d_input, int tokens, int dim) |
| void | swiglu_backward_bf16 (const uint16_t *input, const uint16_t *d_output, uint16_t *d_input, int tokens, int dim) |
| void | swiglu_backward_exact (const float *input, const float *d_output, float *d_input, int tokens, int dim) |
| void | swiglu_forward (const float *input, float *output, int tokens, int dim) |
| void | swiglu_forward_bf16 (const uint16_t *input, uint16_t *output, int tokens, int dim) |
| void | swiglu_forward_exact (const float *input, float *output, int tokens, int dim) |
| void | swiglu_forward_ggml (const float *input, float *output, int tokens, int dim) |
| void | swiglu_forward_ggml_split (const float *gate, const float *up, float *output, int tokens, int dim) |
| void | swiglu_forward_pytorch_bf16_storage (const float *input, float *output, int tokens, int dim) |
| void | swiglu_forward_q8_k (const float *input, void *output_q8, int tokens, int dim) |
| void | topk_batched_f32 (const float *scores, int num_tokens, int n_experts, int k, int *indices, float *weights) |
| Batched top-K selection for multiple tokens. | |
| void | topk_f32 (const float *scores, int n, int k, int *indices, float *values) |
| Find top-K indices and values from a score vector. | |
| void | topk_softmax_backward_f32 (const int *indices, const float *weights, const float *d_weights, float *d_scores, int num_tokens, int n_experts_or_keys, int k) |
| Backward for hard top-k followed by softmax over selected values. | |
| void | topk_softmax_f32 (const float *scores, int n, int k, int *indices, float *weights) |
| Find top-K indices with softmax-normalized weights. | |
| void | unfused_rmsnorm_qkv_prefill (const float *x, const float *gamma, const float *Wq, const float *Wk, const float *Wv, float *x_norm, float *Q, float *K, float *V, int seq_len, int hidden, int q_dim, int kv_dim, float eps) |
| Unfused version for benchmarking comparison. | |
| void | vec_dot_q6_k_q8_k (int n, float *s, const void *vx, const void *vy) |
| Q6_K x Q8_K dot product (single row) | |
| void | vision_position_ids_2d_merge (int32_t *positions, int grid_h, int grid_w, int merge_size) |
| 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]) | |
| void | yarn_rope_cache_contiguous_positions_f32 (float *cos_cache, float *sin_cache, int num_tokens, int rotary_dim, float freq_base, float factor, int original_context, float beta_fast, float beta_slow, float mscale, float mscale_all_dim) |
| void | yarn_rope_cache_explicit_positions_bf16 (uint16_t *cos_cache, uint16_t *sin_cache, const int32_t *positions, int num_tokens, int rotary_dim, float freq_base, float factor, int original_context, float beta_fast, float beta_slow, float mscale, float mscale_all_dim) |
| void | yarn_rope_cache_explicit_positions_f32 (float *cos_cache, float *sin_cache, const int32_t *positions, int num_tokens, int rotary_dim, float freq_base, float factor, int original_context, float beta_fast, float beta_slow, float mscale, float mscale_all_dim) |
Definition at line 2124 of file ckernel_engine.h.
| Enumerator | |
|---|---|
| CK_ATTN_REDUCTION_FP32_ONLINE | |
| CK_ATTN_REDUCTION_F16_ONLINE_FP32_MERGE | |
| CK_ATTN_REDUCTION_F16_ONLINE_SINGLE_RANGE | |
| CK_ATTN_REDUCTION_F16_FLASH_AUTO_QTILE64 | |
| CK_ATTN_REDUCTION_BF16_PYTORCH_SDPA | |
Definition at line 2114 of file ckernel_engine.h.
| Enumerator | |
|---|---|
| CK_ATTENTION_STATUS_OK | |
| CK_ATTENTION_STATUS_INVALID_ARGUMENT | |
| CK_ATTENTION_STATUS_UNSUPPORTED_CONTRACT | |
| CK_ATTENTION_STATUS_INSUFFICIENT_WORKSPACE | |
Definition at line 2132 of file ckernel_engine.h.
| void adamw_clip_update_multi_f32 | ( | float *const * | grads, |
| float *const * | weights, | ||
| float *const * | m_states, | ||
| float *const * | v_states, | ||
| const size_t * | numels, | ||
| int | tensor_count, | ||
| float | lr, | ||
| float | beta1, | ||
| float | beta2, | ||
| float | eps, | ||
| float | weight_decay, | ||
| float | max_grad_norm, | ||
| int | step | ||
| ) |
Definition at line 638 of file optimizer_kernels.c.
References adamw_update_f32_impl(), ck_adamw_multi_parallel_work(), CK_OPT_PAR_MAX_THREADS, CK_OPT_PAR_MIN_NUMEL, ck_opt_pick_active_threads(), ck_threadpool_dispatch_n(), ck_threadpool_global(), ck_threadpool_n_threads(), gradient_global_norm_multi_f32(), and gradient_scale_f32_impl().
| void adamw_update_f32 | ( | const float * | grad, |
| float * | weight, | ||
| float * | m, | ||
| float * | v, | ||
| size_t | numel, | ||
| float | lr, | ||
| float | beta1, | ||
| float | beta2, | ||
| float | eps, | ||
| float | weight_decay, | ||
| int | step | ||
| ) |
Definition at line 592 of file optimizer_kernels.c.
References adamw_update_f32_impl(), ck_adamw_parallel_work(), CK_OPT_PAR_MAX_THREADS, CK_OPT_PAR_MIN_NUMEL, ck_opt_pick_active_threads(), ck_threadpool_dispatch_n(), ck_threadpool_global(), and ck_threadpool_n_threads().
| void add_backward_bf16 | ( | const uint16_t * | d_y, |
| uint16_t * | d_a, | ||
| uint16_t * | d_b, | ||
| size_t | n | ||
| ) |
Definition at line 187 of file add_kernels_bf16.c.
| void add_forward_2d_bf16 | ( | const uint16_t * | a, |
| const uint16_t * | b, | ||
| uint16_t * | y, | ||
| int | tokens, | ||
| int | dim, | ||
| int | aligned_dim | ||
| ) |
Definition at line 235 of file add_kernels_bf16.c.
References bf16_to_float(), and float_to_bf16().
| void add_forward_bf16 | ( | const uint16_t * | a, |
| const uint16_t * | b, | ||
| uint16_t * | y, | ||
| size_t | n | ||
| ) |
Definition at line 38 of file add_kernels_bf16.c.
References bf16_to_float(), and float_to_bf16().
| void add_forward_f32 | ( | const float * | a, |
| const float * | b, | ||
| float * | y, | ||
| size_t | n | ||
| ) |
Element-wise add: y = a + b
test_add.py::TestAddForward::test_add_forward_f32
test_add.py::TestAddForward::test_add_inplace_f32
test_multi_layer_parity.py::TestMultiLayerParity::test_residual_add
Element-wise addition of two vectors.
After changes: make test
Definition at line 284 of file add_kernels_bf16.c.
| void add_inplace_bf16 | ( | uint16_t * | a, |
| const uint16_t * | b, | ||
| size_t | n | ||
| ) |
Definition at line 119 of file add_kernels_bf16.c.
References bf16_to_float(), and float_to_bf16().
| void add_inplace_f32 | ( | float * | a, |
| const float * | b, | ||
| size_t | n | ||
| ) |
Definition at line 318 of file add_kernels_bf16.c.
Referenced by mega_fused_outproj_mlp_prefill().
| void add_scaled_forward_bf16 | ( | const uint16_t * | a, |
| const uint16_t * | b, | ||
| uint16_t * | y, | ||
| float | alpha, | ||
| size_t | n | ||
| ) |
Definition at line 86 of file add_kernels_bf16.c.
References bf16_to_float(), and float_to_bf16().
| void add_scaled_inplace_bf16 | ( | uint16_t * | a, |
| const uint16_t * | b, | ||
| float | alpha, | ||
| size_t | n | ||
| ) |
Definition at line 149 of file add_kernels_bf16.c.
References bf16_to_float(), and float_to_bf16().
| void add_stream_inplace | ( | float * | a, |
| const float * | b, | ||
| size_t | n | ||
| ) |
Definition at line 713 of file vision_kernels.c.
| void add_stream_reorder_2d | ( | float * | main_inout, |
| float * | aux_scratch, | ||
| int | grid_h, | ||
| int | grid_w, | ||
| int | embed_dim, | ||
| int | merge_size | ||
| ) |
Definition at line 726 of file vision_kernels.c.
References tile_order_index_2d().
| int argmax_f32 | ( | const float * | scores, |
| int | n | ||
| ) |
Find index of maximum value.
| scores | Input scores [n] |
| n | Number of scores |
Definition at line 500 of file topk_kernels.c.
Referenced by speculative_verify_greedy_f32().
| void assistant_layer_scale_forward | ( | float * | hidden, |
| const float * | scale, | ||
| int | tokens, | ||
| int | embed_dim | ||
| ) |
Definition at line 389 of file gemma4_per_layer_embed.c.
| void attention_backward_causal_head_major | ( | const float * | d_output, |
| const float * | q, | ||
| const float * | k, | ||
| const float * | v, | ||
| const float * | attn_weights, | ||
| float * | d_q, | ||
| float * | d_k, | ||
| float * | d_v, | ||
| float * | d_scores, | ||
| int | num_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | aligned_context_window | ||
| ) |
Causal attention backward (non-GQA version)
test_attention_backward.py::TestAttentionBackward::test_backward
test_attention_backward.py::TestAttentionBackward::test_backward_vs_separate
test_parity.py::test_attention_backward_parity
Non-GQA version where num_heads == num_kv_heads. Simpler than GQA, no head broadcasting needed.
After changes: make test && make llamacpp-parity-full
Definition at line 9175 of file attention_kernels.c.
References attention_backward_causal_head_major_gqa().
| void attention_backward_causal_head_major_gqa | ( | const float * | d_output, |
| const float * | q, | ||
| const float * | k, | ||
| const float * | v, | ||
| const float * | attn_weights, | ||
| float * | d_q, | ||
| float * | d_k, | ||
| float * | d_v, | ||
| float * | d_scores, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | aligned_context_window | ||
| ) |
GQA causal attention backward (score-matrix version)
test_attention_backward.py::TestAttentionBackwardGQA::test_gqa_backward
test_attention_backward.py::TestAttentionBackwardGQA::test_gqa_vs_separate
test_parity.py::test_attention_backward_parity
Computes dQ, dK, dV given dOutput and attention weights. Supports grouped-query attention with head broadcasting.
After changes: make test && make llamacpp-parity-full
Definition at line 9036 of file attention_kernels.c.
References qkv_index(), and score_index().
Referenced by attention_backward_causal_head_major(), attention_backward_causal_head_major_gqa_bf16(), and ck_layer_backward_rmsnorm_swiglu().
| void attention_backward_causal_head_major_gqa_bf16 | ( | const uint16_t * | d_output, |
| float * | d_x, | ||
| const uint16_t * | q, | ||
| const uint16_t * | k, | ||
| const uint16_t * | v, | ||
| const float * | attn_weights, | ||
| float * | d_q, | ||
| float * | d_k, | ||
| float * | d_v, | ||
| float * | d_scores, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | aligned_context_window, | ||
| float * | scratch_d_output, | ||
| float * | scratch_q, | ||
| float * | scratch_k, | ||
| float * | scratch_v | ||
| ) |
BF16 attention backward with caller-provided scratch buffers
Accepts BF16 inputs, converts to FP32, runs FP32 backward. Caller provides scratch buffers (no per-call malloc).
After changes: make test
Definition at line 8983 of file attention_kernels.c.
References attention_backward_causal_head_major_gqa(), and convert_bf16_tensor_to_buf().
| void attention_flash_decode | ( | float * | out, |
| const float * | q, | ||
| const float * | k, | ||
| const float * | v, | ||
| int | T_q, | ||
| int | T_k, | ||
| int | H, | ||
| int | D_h, | ||
| float | scale | ||
| ) |
Main flash attention function with SIMD dispatch.
| out | Output [T_q, H, D_h] |
| q | Query [T_q, H, D_h] |
| k | Key [T_k, H, D_h] |
| v | Value [T_k, H, D_h] |
| T_q | Number of query tokens (1 for decode) |
| T_k | Number of key/value tokens (context length) |
| H | Number of heads |
| D_h | Head dimension |
| scale | 1/sqrt(D_h) |
Definition at line 696 of file attention_flash_true.c.
References attention_flash_decode_scalar().
Referenced by attention_forward_chunk_head_major_gqa_flash_gemma4(), attention_forward_decode_head_major_gqa_flash(), attention_forward_decode_head_major_gqa_flash_f16cache(), attention_forward_decode_head_major_gqa_flash_gemma4(), ck_attention_flash_decode_wrapper(), mega_fused_attention_prefill(), and mega_fused_attention_prefill_q8_0().
| void attention_forward_causal_head_major | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | scores, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | aligned_context_window | ||
| ) |
Causal attention forward (score-matrix version)
test_attention.py::TestAttentionForward::test_causal_forward
test_attention.py::TestAttentionForward::test_gqa_broadcast
test_attention.py::TestAttentionForward::test_exact_vs_fast
test_parity.py::test_attention_parity
Computes softmax(Q @ K^T / sqrt(d)) @ V with causal masking. Uses O(N^2) memory for scores matrix.
After changes: make test && make llamacpp-parity-full
Definition at line 1281 of file attention_kernels.c.
References causal_softmax_head_major(), qkv_index(), and score_index().
| void attention_forward_causal_head_major_exact | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | scores, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | aligned_context_window | ||
| ) |
Causal attention forward (exact version using stdlib expf)
test_attention.py::TestAttentionForward::test_exact_single
test_attention.py::TestAttentionForward::test_exact_vs_fast
Uses standard library expf for numerical accuracy reference. Slower but provides maximum accuracy.
After changes: make test
Definition at line 1357 of file attention_kernels.c.
References causal_softmax_head_major_exact(), qkv_index(), and score_index().
| void attention_forward_causal_head_major_gqa | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | scores, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | aligned_context_window | ||
| ) |
GQA causal attention forward (score-matrix version)
test_attention.py::TestAttentionForward::test_gqa_forward
test_attention.py::TestAttentionForward::test_gqa_broadcast
test_attention_backward.py::TestAttentionBackwardGQA::test_gqa_backward
test_parity.py::test_attention_gqa_parity
Grouped-query attention: Q has num_heads, K/V have num_kv_heads. Each query head maps to a KV head via ratio.
After changes: make test && make llamacpp-parity-full
Definition at line 1435 of file attention_kernels.c.
References causal_softmax_head_major(), qkv_index(), and score_index().
Referenced by ck_layer_forward_rmsnorm_swiglu(), ck_layer_forward_rmsnorm_swiglu_q4_k(), ck_layer_forward_rmsnorm_swiglu_quant(), and ck_layer_forward_rmsnorm_swiglu_ref().
| void attention_forward_causal_head_major_gqa_bf16 | ( | const uint16_t * | q, |
| const uint16_t * | k, | ||
| const uint16_t * | v, | ||
| float * | scores, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | aligned_context_window, | ||
| float * | scratch_q, | ||
| float * | scratch_k, | ||
| float * | scratch_v | ||
| ) |
BF16 GQA causal attention forward
bf16/test_attention_bf16.py::TestAttentionBF16::test_bf16_forward
bf16/test_attention_bf16.py::TestAttentionBF16::test_bf16_gqa
bf16/test_attention_bf16.py::TestAttentionBF16::test_bf16_flash
Accepts BF16 inputs, converts to FP32, uses exact softmax. Caller provides scratch buffers (no per-call malloc).
After changes: make test
Definition at line 1577 of file attention_kernels.c.
References attention_forward_causal_head_major_gqa_exact(), and convert_bf16_tensor_to_buf().
| void attention_forward_causal_head_major_gqa_exact | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | scores, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | aligned_context_window | ||
| ) |
GQA causal attention forward (exact version using stdlib expf)
test_attention.py::TestAttentionForward::test_gqa_exact
bf16/test_attention_bf16.py::TestAttentionBF16::test_bf16_gqa
Uses standard library expf for numerical accuracy reference. Used by BF16 wrapper to avoid approximation error accumulation.
After changes: make test
Definition at line 1505 of file attention_kernels.c.
References causal_softmax_head_major_exact(), qkv_index(), and score_index().
Referenced by attention_forward_causal_head_major_gqa_bf16(), ck_layer_forward_rmsnorm_swiglu(), and ck_layer_forward_rmsnorm_swiglu_ref().
| void attention_forward_causal_head_major_gqa_flash | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim | ||
| ) |
Definition at line 4370 of file attention_kernels.c.
References attention_forward_head_major_gqa_flash_impl().
Referenced by ck_layer_forward_rmsnorm_swiglu(), ck_layer_forward_rmsnorm_swiglu_q4_k(), ck_layer_forward_rmsnorm_swiglu_quant(), ck_layer_forward_rmsnorm_swiglu_ref(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_9_prefill(), and qwen2_0_5b_decode_layer_9_prefill().
| void attention_forward_causal_head_major_gqa_flash_strided | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens | ||
| ) |
Flash attention forward with custom KV stride (for KV cache)
test_flash_attention.py::TestFlashAttention::test_flash_strided
test_kv_cache_attention.py::TestKVCacheAttention::test_flash_attention
Variant with configurable kv_stride_tokens for KV cache layouts where K/V may not be contiguous in memory.
After changes: make test
Definition at line 4422 of file attention_kernels.c.
References attention_forward_head_major_gqa_flash_impl().
Referenced by attention_forward_causal_head_major_gqa_flash_strided_sliding(), mega_fused_attention_prefill(), mega_fused_attention_prefill_q8_0(), model_layer_0_prefill(), model_layer_0_prefill(), model_layer_0_prefill(), model_layer_0_prefill(), model_layer_10_prefill(), model_layer_10_prefill(), model_layer_10_prefill(), model_layer_10_prefill(), model_layer_11_prefill(), model_layer_11_prefill(), model_layer_11_prefill(), model_layer_11_prefill(), model_layer_12_prefill(), model_layer_12_prefill(), model_layer_12_prefill(), model_layer_12_prefill(), model_layer_13_prefill(), model_layer_13_prefill(), model_layer_13_prefill(), model_layer_13_prefill(), model_layer_14_prefill(), model_layer_14_prefill(), model_layer_14_prefill(), model_layer_14_prefill(), model_layer_15_prefill(), model_layer_15_prefill(), model_layer_15_prefill(), model_layer_15_prefill(), model_layer_16_prefill(), model_layer_16_prefill(), model_layer_16_prefill(), model_layer_16_prefill(), model_layer_17_prefill(), model_layer_17_prefill(), model_layer_17_prefill(), model_layer_17_prefill(), model_layer_18_prefill(), model_layer_18_prefill(), model_layer_18_prefill(), model_layer_18_prefill(), model_layer_19_prefill(), model_layer_19_prefill(), model_layer_19_prefill(), model_layer_19_prefill(), model_layer_1_prefill(), model_layer_1_prefill(), model_layer_1_prefill(), model_layer_1_prefill(), model_layer_20_prefill(), model_layer_20_prefill(), model_layer_20_prefill(), model_layer_20_prefill(), model_layer_21_prefill(), model_layer_21_prefill(), model_layer_21_prefill(), model_layer_21_prefill(), model_layer_22_prefill(), model_layer_22_prefill(), model_layer_22_prefill(), model_layer_22_prefill(), model_layer_23_prefill(), model_layer_23_prefill(), model_layer_23_prefill(), model_layer_23_prefill(), model_layer_2_prefill(), model_layer_2_prefill(), model_layer_2_prefill(), model_layer_2_prefill(), model_layer_3_prefill(), model_layer_3_prefill(), model_layer_3_prefill(), model_layer_3_prefill(), model_layer_4_prefill(), model_layer_4_prefill(), model_layer_4_prefill(), model_layer_4_prefill(), model_layer_5_prefill(), model_layer_5_prefill(), model_layer_5_prefill(), model_layer_5_prefill(), model_layer_6_prefill(), model_layer_6_prefill(), model_layer_6_prefill(), model_layer_6_prefill(), model_layer_7_prefill(), model_layer_7_prefill(), model_layer_7_prefill(), model_layer_7_prefill(), model_layer_8_prefill(), model_layer_8_prefill(), model_layer_8_prefill(), model_layer_8_prefill(), model_layer_9_prefill(), model_layer_9_prefill(), model_layer_9_prefill(), model_layer_9_prefill(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_9_prefill(), and qwen2_0_5b_decode_layer_9_prefill().
| void attention_forward_causal_head_major_gqa_flash_strided_f16kv | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens | ||
| ) |
Definition at line 5343 of file attention_kernels.c.
References attention_forward_causal_head_major_gqa_flash_strided_f16kv_serial(), and attention_forward_causal_head_major_gqa_flash_strided_f16kv_workspace().
| void attention_forward_causal_head_major_gqa_flash_strided_f16kv_workspace | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens, | ||
| float * | rounded_kv, | ||
| size_t | rounded_kv_bytes | ||
| ) |
Definition at line 5303 of file attention_kernels.c.
References ck_attention_causal_f16kv_work(), ck_round_fp16_buffer(), ck_threadpool_dispatch_n(), ck_threadpool_global(), and ck_threadpool_n_threads().
Referenced by attention_forward_causal_head_major_gqa_flash_strided_f16kv().
| void attention_forward_causal_head_major_gqa_flash_strided_gemma4 | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens | ||
| ) |
Definition at line 5024 of file attention_kernels.c.
References attention_forward_head_major_gqa_flash_impl().
Referenced by attention_forward_causal_head_major_gqa_flash_strided_sliding_gemma4_impl(), and attention_forward_causal_head_major_shared_kv_gemma4().
| void attention_forward_causal_head_major_gqa_flash_strided_gemma4_token_output | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens | ||
| ) |
Definition at line 5047 of file attention_kernels.c.
References attention_forward_head_major_gqa_flash_impl().
Referenced by attention_forward_causal_head_major_gqa_flash_strided_sliding_gemma4_impl().
| void attention_forward_causal_head_major_gqa_flash_strided_sliding | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens, | ||
| int | sliding_window | ||
| ) |
Flash attention forward with sliding window (prefill)
Sliding-window attention for prefill: each token attends to the last W tokens. When sliding_window <= 0, behaves like regular causal attention.
After changes: make test
Definition at line 566 of file attention_kernels_sliding.c.
References attention_forward_causal_head_major_gqa_flash_strided(), attention_output_index(), ck_sliding_attention_pick_threads(), ck_sliding_attention_work_fn(), ck_threadpool_dispatch_n(), ck_threadpool_global(), qkv_index(), and SLIDING_FLASH_IMPL.
| void attention_forward_causal_head_major_gqa_flash_strided_sliding_gemma4 | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens, | ||
| int | sliding_window | ||
| ) |
Definition at line 763 of file attention_kernels_sliding.c.
References attention_forward_causal_head_major_gqa_flash_strided_sliding_gemma4_impl().
Referenced by attention_forward_causal_head_major_shared_kv_sliding_gemma4().
| void attention_forward_causal_head_major_gqa_flash_strided_sliding_gemma4_token_output | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens, | ||
| int | sliding_window | ||
| ) |
Definition at line 782 of file attention_kernels_sliding.c.
References attention_forward_causal_head_major_gqa_flash_strided_sliding_gemma4_impl().
| void attention_forward_causal_head_major_gqa_flash_strided_token_output | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens | ||
| ) |
Definition at line 4444 of file attention_kernels.c.
References attention_forward_head_major_gqa_flash_impl().
| void attention_forward_causal_head_major_gqa_llama_regular_strided_sliding_workspace | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens, | ||
| int | sliding_window, | ||
| float * | scores, | ||
| size_t | scores_bytes, | ||
| float * | value_columns, | ||
| size_t | value_columns_bytes, | ||
| float * | scaled_scores, | ||
| size_t | scaled_scores_bytes | ||
| ) |
Definition at line 5960 of file attention_kernels.c.
References ck_attention_llama_regular_impl().
| ck_attention_status_t attention_forward_causal_head_major_gqa_prefill_append_bf16cache_pytorch_contract | ( | const float * | q, |
| const uint16_t * | k_cache, | ||
| const uint16_t * | v_cache, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | q_tokens, | ||
| int | past_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| ck_attention_reduction_t | reduction | ||
| ) |
Definition at line 8673 of file attention_kernels.c.
References attention_forward_causal_head_major_gqa_prefill_append_bf16cache_pytorch_contract_workspace(), CK_ATTENTION_STATUS_INVALID_ARGUMENT, and CK_GGML_FA_TILE_Q.
| ck_attention_status_t attention_forward_causal_head_major_gqa_prefill_append_bf16cache_pytorch_contract_workspace | ( | const float * | q, |
| const uint16_t * | k_cache, | ||
| const uint16_t * | v_cache, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | q_tokens, | ||
| int | past_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| ck_attention_reduction_t | reduction, | ||
| float * | token_workspace, | ||
| size_t | token_workspace_bytes | ||
| ) |
Definition at line 8596 of file attention_kernels.c.
References attention_forward_decode_head_major_gqa_bf16cache_pytorch_contract(), bf16_to_float(), ck_attention_f16_prefill_qtile64_work(), CK_ATTENTION_STATUS_INVALID_ARGUMENT, CK_ATTENTION_STATUS_OK, CK_ATTENTION_STATUS_UNSUPPORTED_CONTRACT, CK_ATTN_REDUCTION_BF16_PYTORCH_SDPA, CK_GGML_FA_TILE_Q, ck_threadpool_dispatch_n(), ck_threadpool_global(), ck_threadpool_n_threads(), ck_threadpool_thread_id(), and float_to_bf16().
Referenced by attention_forward_causal_head_major_gqa_prefill_append_bf16cache_pytorch_contract().
| ck_attention_status_t attention_forward_causal_head_major_gqa_prefill_append_f16cache_auto_workspace | ( | const float * | q, |
| const uint16_t * | k_cache, | ||
| const uint16_t * | v_cache, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | q_tokens, | ||
| int | past_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| ck_attention_reduction_t | reduction, | ||
| float * | token_workspace, | ||
| size_t | token_workspace_bytes, | ||
| void * | gqa_workspace, | ||
| size_t | gqa_workspace_bytes, | ||
| int | route_num_heads, | ||
| int | route_num_kv_heads, | ||
| int | route_head_dim, | ||
| int | route_query_tokens, | ||
| int | route_min_kv_tokens, | ||
| int | route_workers, | ||
| int | route_query_tile_size, | ||
| int | route_concurrent_query_tiles | ||
| ) |
Definition at line 7335 of file attention_kernels.c.
References attention_forward_causal_head_major_gqa_prefill_append_f16cache_contract_workspace(), attention_forward_causal_head_major_gqa_prefill_append_f16cache_gqa_reuse_config(), CK_ATTENTION_STATUS_INVALID_ARGUMENT, CK_ATTN_REDUCTION_F16_FLASH_AUTO_QTILE64, ck_threadpool_global(), and ck_threadpool_n_threads().
| ck_attention_status_t attention_forward_causal_head_major_gqa_prefill_append_f16cache_contract | ( | const float * | q, |
| const uint16_t * | k_cache, | ||
| const uint16_t * | v_cache, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | q_tokens, | ||
| int | past_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| ck_attention_reduction_t | reduction | ||
| ) |
Definition at line 7641 of file attention_kernels.c.
References attention_forward_causal_head_major_gqa_prefill_append_f16cache_contract_workspace(), CK_ATTENTION_STATUS_INVALID_ARGUMENT, CK_ATTN_REDUCTION_F16_FLASH_AUTO_QTILE64, and CK_GGML_FA_TILE_Q.
| ck_attention_status_t attention_forward_causal_head_major_gqa_prefill_append_f16cache_contract_workspace | ( | const float * | q, |
| const uint16_t * | k_cache, | ||
| const uint16_t * | v_cache, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | q_tokens, | ||
| int | past_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| ck_attention_reduction_t | reduction, | ||
| float * | token_workspace, | ||
| size_t | token_workspace_bytes | ||
| ) |
Definition at line 7419 of file attention_kernels.c.
References attention_forward_decode_head_major_gqa_flash_f16cache_contract(), ck_attention_f16_prefill_qtile64_dispatch(), CK_ATTENTION_STATUS_INVALID_ARGUMENT, CK_ATTENTION_STATUS_OK, CK_ATTENTION_STATUS_UNSUPPORTED_CONTRACT, CK_ATTN_PREFILL_SCHEDULE_QUERY_TILES, CK_ATTN_REDUCTION_F16_FLASH_AUTO_QTILE64, CK_ATTN_REDUCTION_F16_ONLINE_FP32_MERGE, CK_ATTN_REDUCTION_F16_ONLINE_SINGLE_RANGE, CK_ATTN_REDUCTION_FP32_ONLINE, and CK_GGML_FA_TILE_Q.
Referenced by attention_forward_causal_head_major_gqa_prefill_append_f16cache_auto_workspace(), and attention_forward_causal_head_major_gqa_prefill_append_f16cache_contract().
| ck_attention_status_t attention_forward_causal_head_major_gqa_prefill_append_f16cache_gqa_reuse_config | ( | const float * | q, |
| const uint16_t * | k_cache, | ||
| const uint16_t * | v_cache, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | q_tokens, | ||
| int | past_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | query_tile_size, | ||
| int | concurrent_query_tiles, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 7234 of file attention_kernels.c.
References attention_forward_causal_head_major_gqa_prefill_append_f16cache_gqa_reuse_workspace_bytes(), ck_attention_align64_size(), ck_attention_f16_prefill_gqa_reuse_work(), ck_attention_f16_prefill_gqa_reuse_worker_bytes(), CK_ATTENTION_STATUS_INSUFFICIENT_WORKSPACE, CK_ATTENTION_STATUS_INVALID_ARGUMENT, CK_ATTENTION_STATUS_OK, CK_ATTENTION_STATUS_UNSUPPORTED_CONTRACT, CK_ATTN_PREFILL_SCHEDULE_GQA_SHARED_KV_TILES, CK_GGML_FA_TILE_KV, ck_threadpool_dispatch_n(), ck_threadpool_global(), ck_threadpool_n_threads(), and ck_threadpool_thread_id().
Referenced by attention_forward_causal_head_major_gqa_prefill_append_f16cache_auto_workspace().
| size_t attention_forward_causal_head_major_gqa_prefill_append_f16cache_gqa_reuse_workspace_bytes | ( | int | num_heads, |
| int | num_kv_heads, | ||
| int | head_dim, | ||
| int | workers, | ||
| int | query_tile_size, | ||
| int | concurrent_query_tiles | ||
| ) |
Definition at line 6716 of file attention_kernels.c.
References ck_attention_align64_size(), ck_attention_f16_prefill_gqa_reuse_worker_bytes(), and CK_GGML_FA_TILE_KV.
Referenced by attention_forward_causal_head_major_gqa_prefill_append_f16cache_gqa_reuse_config().
| ck_attention_status_t attention_forward_causal_head_major_gqa_prefill_append_f16cache_qtile64_schedule | ( | const float * | q, |
| const uint16_t * | k_cache, | ||
| const uint16_t * | v_cache, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | q_tokens, | ||
| int | past_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| ck_attention_prefill_schedule_t | schedule | ||
| ) |
Definition at line 7392 of file attention_kernels.c.
References ck_attention_f16_prefill_qtile64_dispatch(), CK_ATTENTION_STATUS_INVALID_ARGUMENT, and CK_GGML_FA_TILE_Q.
| ck_attention_status_t attention_forward_causal_head_major_gqa_prefill_full_bf16cache_pytorch_contract | ( | const float * | q, |
| const uint16_t * | k_cache, | ||
| const uint16_t * | v_cache, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | q_tokens, | ||
| int | past_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| ck_attention_reduction_t | reduction | ||
| ) |
Definition at line 8713 of file attention_kernels.c.
References CK_ATTENTION_STATUS_INVALID_ARGUMENT, CK_ATTENTION_STATUS_UNSUPPORTED_CONTRACT, and CK_ATTN_REDUCTION_BF16_PYTORCH_SDPA.
| ck_attention_status_t attention_forward_causal_head_major_gqa_prefill_segmented_f16cache_contract_workspace | ( | const float * | q, |
| const uint16_t * | k_cache, | ||
| const uint16_t * | v_cache, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | q_tokens, | ||
| int | past_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| ck_attention_reduction_t | reduction, | ||
| float * | token_workspace, | ||
| size_t | token_workspace_bytes, | ||
| const int * | segment_lengths, | ||
| int | num_segments | ||
| ) |
Definition at line 7616 of file attention_kernels.c.
References ck_attention_forward_causal_head_major_gqa_prefill_segmented_f16cache_schedule_workspace(), and CK_ATTN_PREFILL_SCHEDULE_QUERY_TILES.
| void attention_forward_causal_head_major_shared_kv_gemma4 | ( | const float * | q, |
| float * | output, | ||
| int | num_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens | ||
| ) |
Definition at line 5070 of file attention_kernels.c.
References attention_forward_causal_head_major_gqa_flash_strided_gemma4().
| void attention_forward_causal_head_major_shared_kv_sliding_gemma4 | ( | const float * | q, |
| float * | output, | ||
| int | num_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens, | ||
| int | sliding_window | ||
| ) |
Definition at line 801 of file attention_kernels_sliding.c.
References attention_forward_causal_head_major_gqa_flash_strided_sliding_gemma4().
| void attention_forward_chunk_head_major_gqa_flash_gemma4 | ( | const float * | q_chunk, |
| const float * | k_cache, | ||
| const float * | v_cache, | ||
| float * | out_chunk, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | q_tokens, | ||
| int | kv_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim | ||
| ) |
Definition at line 6089 of file attention_kernels.c.
References attention_flash_decode().
| ck_attention_status_t attention_forward_decode_head_major_gqa_bf16cache_pytorch_contract | ( | const float * | q_token, |
| const uint16_t * | k_cache, | ||
| const uint16_t * | v_cache, | ||
| float * | out_token, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | kv_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| ck_attention_reduction_t | reduction | ||
| ) |
Definition at line 8522 of file attention_kernels.c.
References bf16_to_float(), CK_ATTENTION_STATUS_INVALID_ARGUMENT, CK_ATTENTION_STATUS_OK, CK_ATTENTION_STATUS_UNSUPPORTED_CONTRACT, CK_ATTN_REDUCTION_BF16_PYTORCH_SDPA, float_to_bf16(), score, and token.
Referenced by attention_forward_causal_head_major_gqa_prefill_append_bf16cache_pytorch_contract_workspace().
| void attention_forward_decode_head_major_gqa_flash | ( | const float * | q_token, |
| const float * | k_cache, | ||
| const float * | v_cache, | ||
| float * | out_token, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | kv_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim | ||
| ) |
Flash attention decode (single token attends to KV cache)
test_flash_attention.py::TestFlashAttention::test_flash_decode
test_kv_cache_attention.py::TestKVCacheAttention::test_flash_decode
test_fused_attention_decode.py::TestFusedAttentionDecode::test_flash_decode
test_attention.py::TestAttentionForward::test_flash_decode
Single query token attends to kv_tokens in KV cache. Uses true flash attention from attention_flash_true.c.
After changes: make test && make llamacpp-parity-full
Definition at line 6002 of file attention_kernels.c.
References attention_flash_decode().
Referenced by attention_forward_decode_head_major_gqa_flash_sliding(), model_layer_0_decode(), model_layer_0_decode(), model_layer_0_decode(), model_layer_0_decode(), model_layer_10_decode(), model_layer_10_decode(), model_layer_10_decode(), model_layer_10_decode(), model_layer_11_decode(), model_layer_11_decode(), model_layer_11_decode(), model_layer_11_decode(), model_layer_12_decode(), model_layer_12_decode(), model_layer_12_decode(), model_layer_12_decode(), model_layer_13_decode(), model_layer_13_decode(), model_layer_13_decode(), model_layer_13_decode(), model_layer_14_decode(), model_layer_14_decode(), model_layer_14_decode(), model_layer_14_decode(), model_layer_15_decode(), model_layer_15_decode(), model_layer_15_decode(), model_layer_15_decode(), model_layer_16_decode(), model_layer_16_decode(), model_layer_16_decode(), model_layer_16_decode(), model_layer_17_decode(), model_layer_17_decode(), model_layer_17_decode(), model_layer_17_decode(), model_layer_18_decode(), model_layer_18_decode(), model_layer_18_decode(), model_layer_18_decode(), model_layer_19_decode(), model_layer_19_decode(), model_layer_19_decode(), model_layer_19_decode(), model_layer_1_decode(), model_layer_1_decode(), model_layer_1_decode(), model_layer_1_decode(), model_layer_20_decode(), model_layer_20_decode(), model_layer_20_decode(), model_layer_20_decode(), model_layer_21_decode(), model_layer_21_decode(), model_layer_21_decode(), model_layer_21_decode(), model_layer_22_decode(), model_layer_22_decode(), model_layer_22_decode(), model_layer_22_decode(), model_layer_23_decode(), model_layer_23_decode(), model_layer_23_decode(), model_layer_23_decode(), model_layer_2_decode(), model_layer_2_decode(), model_layer_2_decode(), model_layer_2_decode(), model_layer_3_decode(), model_layer_3_decode(), model_layer_3_decode(), model_layer_3_decode(), model_layer_4_decode(), model_layer_4_decode(), model_layer_4_decode(), model_layer_4_decode(), model_layer_5_decode(), model_layer_5_decode(), model_layer_5_decode(), model_layer_5_decode(), model_layer_6_decode(), model_layer_6_decode(), model_layer_6_decode(), model_layer_6_decode(), model_layer_7_decode(), model_layer_7_decode(), model_layer_7_decode(), model_layer_7_decode(), model_layer_8_decode(), model_layer_8_decode(), model_layer_8_decode(), model_layer_8_decode(), model_layer_9_decode(), model_layer_9_decode(), model_layer_9_decode(), model_layer_9_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_9_decode(), and qwen2_0_5b_decode_layer_9_decode().
| void attention_forward_decode_head_major_gqa_flash_f16cache | ( | const float * | q_token, |
| const uint16_t * | k_cache, | ||
| const uint16_t * | v_cache, | ||
| float * | out_token, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | kv_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim | ||
| ) |
Definition at line 8750 of file attention_kernels.c.
References attention_flash_decode(), CK_FP16_TO_FP32, ck_local_fp16_to_fp32_2d(), and score.
Referenced by attention_forward_decode_head_major_gqa_flash_f16cache_contract().
| ck_attention_status_t attention_forward_decode_head_major_gqa_flash_f16cache_contract | ( | const float * | q_token, |
| const uint16_t * | k_cache, | ||
| const uint16_t * | v_cache, | ||
| float * | out_token, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | kv_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| ck_attention_reduction_t | reduction | ||
| ) |
Definition at line 6586 of file attention_kernels.c.
References attention_forward_decode_head_major_gqa_flash_f16cache(), attention_forward_decode_head_major_gqa_flash_f16cache_split(), CK_ATTENTION_STATUS_INVALID_ARGUMENT, CK_ATTENTION_STATUS_OK, CK_ATTENTION_STATUS_UNSUPPORTED_CONTRACT, CK_ATTN_REDUCTION_F16_ONLINE_FP32_MERGE, CK_ATTN_REDUCTION_F16_ONLINE_SINGLE_RANGE, CK_ATTN_REDUCTION_FP32_ONLINE, and ck_get_num_threads().
Referenced by attention_forward_causal_head_major_gqa_prefill_append_f16cache_contract_workspace(), and ck_attention_forward_causal_head_major_gqa_prefill_segmented_f16cache_schedule_workspace().
| void attention_forward_decode_head_major_gqa_flash_f16cache_split | ( | const float * | q_token, |
| const uint16_t * | k_cache, | ||
| const uint16_t * | v_cache, | ||
| float * | out_token, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | kv_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | split_chunks | ||
| ) |
Definition at line 6565 of file attention_kernels.c.
References attention_forward_decode_head_major_gqa_flash_f16cache_split_partitioned().
Referenced by attention_forward_decode_head_major_gqa_flash_f16cache_contract().
| void attention_forward_decode_head_major_gqa_flash_f16kv | ( | const float * | q_token, |
| const float * | k_cache, | ||
| const float * | v_cache, | ||
| float * | out_token, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | kv_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim | ||
| ) |
Definition at line 6151 of file attention_kernels.c.
References attention_flash_query_causal_exact_f16kv().
| void attention_forward_decode_head_major_gqa_flash_gemma4 | ( | const float * | q_token, |
| const float * | k_cache, | ||
| const float * | v_cache, | ||
| float * | out_token, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | kv_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim | ||
| ) |
Definition at line 6046 of file attention_kernels.c.
References attention_flash_decode().
Referenced by attention_forward_decode_head_major_gqa_flash_sliding_gemma4(), and attention_forward_decode_head_major_shared_kv_gemma4().
| void attention_forward_decode_head_major_gqa_flash_sliding | ( | const float * | q_token, |
| const float * | k_cache, | ||
| const float * | v_cache, | ||
| float * | out_token, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | kv_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | sliding_window | ||
| ) |
Definition at line 817 of file attention_kernels_sliding.c.
References attention_forward_decode_head_major_gqa_flash(), and SLIDING_DECODE_IMPL.
| void attention_forward_decode_head_major_gqa_flash_sliding_gemma4 | ( | const float * | q_token, |
| const float * | k_cache, | ||
| const float * | v_cache, | ||
| float * | out_token, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | kv_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | sliding_window | ||
| ) |
Definition at line 903 of file attention_kernels_sliding.c.
References attention_forward_decode_head_major_gqa_flash_gemma4(), and SLIDING_DECODE_IMPL_GEMMA4.
Referenced by attention_forward_decode_head_major_shared_kv_sliding_gemma4().
| void attention_forward_decode_head_major_gqa_llama_regular_sliding_workspace | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | live_tokens, | ||
| int | kv_stride_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | sliding_window, | ||
| float * | scores, | ||
| size_t | scores_bytes, | ||
| float * | value_columns, | ||
| size_t | value_columns_bytes, | ||
| float * | scaled_scores, | ||
| size_t | scaled_scores_bytes | ||
| ) |
Definition at line 5975 of file attention_kernels.c.
References ck_attention_llama_regular_impl().
| void attention_forward_decode_head_major_gqa_regular | ( | const float * | q_token, |
| const float * | k_cache, | ||
| const float * | v_cache, | ||
| float * | out_token, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | kv_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim | ||
| ) |
WARNING: This is NOT true flash attention!
This function is named "flash" but implements regular attention with O(n) complexity. It's kept for reference and as a fallback.
TRUE flash attention is implemented in attention_flash_true.c
test_kv_cache_attention.py::TestKVCacheAttention::test_regular_decode
test_attention.py::TestAttentionForward::test_regular_decode
Regular attention decode (score-matrix version) for fallback.
After changes: make test
Definition at line 8873 of file attention_kernels.c.
References attention_flash_query_causal_exact_f16kv(), ck_attention_strict_scale_f32(), ck_strict_parity_enabled(), and FLASH_QUERY_IMPL_DECODE.
Referenced by ck_attention_flash_decode_wrapper(), ck_layer_forward_rmsnorm_swiglu_decode_fused_attn_impl(), ck_layer_forward_rmsnorm_swiglu_decode_q4_k(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_9_decode(), qwen2_0_5b_decode_layer_9_decode(), and qwen2_0_5b_decode_layer_9_decode().
| void attention_forward_decode_head_major_shared_kv_gemma4 | ( | const float * | q_token, |
| const float * | k_cache, | ||
| const float * | v_cache, | ||
| float * | out_token, | ||
| int | num_heads, | ||
| int | kv_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim | ||
| ) |
Definition at line 6135 of file attention_kernels.c.
References attention_forward_decode_head_major_gqa_flash_gemma4().
| void attention_forward_decode_head_major_shared_kv_sliding_gemma4 | ( | const float * | q_token, |
| const float * | k_cache, | ||
| const float * | v_cache, | ||
| float * | out_token, | ||
| int | num_heads, | ||
| int | kv_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | sliding_window | ||
| ) |
Definition at line 976 of file attention_kernels_sliding.c.
References attention_forward_decode_head_major_gqa_flash_sliding_gemma4().
| void attention_forward_full_head_major_gqa_exact_strided | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens | ||
| ) |
Definition at line 5372 of file attention_kernels.c.
References attention_query_full_exact_regular(), ck_attention_head_full_ggml_graph_oracle_regular(), ck_attention_strict_scale_f32(), ck_attention_trace(), ck_attention_vec_dump_next_layer_id(), ck_strict_parity_enabled(), and qkv_index().
| void attention_forward_full_head_major_gqa_flash | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim | ||
| ) |
Definition at line 4391 of file attention_kernels.c.
References attention_forward_head_major_gqa_flash_impl().
| void attention_forward_full_head_major_gqa_flash_strided | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens | ||
| ) |
Definition at line 4467 of file attention_kernels.c.
References attention_forward_head_major_gqa_flash_impl().
| void attention_forward_full_head_major_gqa_flash_strided_bf16_storage | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens | ||
| ) |
Definition at line 4920 of file attention_kernels.c.
References attention_forward_head_major_gqa_flash_impl(), bf16_to_float(), and float_to_bf16().
| void attention_forward_full_head_major_gqa_flash_strided_gemma4 | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens | ||
| ) |
Definition at line 5084 of file attention_kernels.c.
References attention_forward_head_major_gqa_flash_impl().
| void attention_forward_full_head_major_gqa_ggml_strided | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens | ||
| ) |
Definition at line 5690 of file attention_kernels.c.
References attention_forward_full_head_major_gqa_ggml_strided_workspace().
| void attention_forward_full_head_major_gqa_ggml_strided_workspace | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens, | ||
| float * | score_rows, | ||
| size_t | score_rows_bytes, | ||
| float * | v_columns, | ||
| size_t | v_columns_bytes, | ||
| float * | probability_row, | ||
| size_t | probability_row_bytes | ||
| ) |
Definition at line 5449 of file attention_kernels.c.
References attention_query_full_ggml_regular(), ck_attention_full_ggml_graph_oracle_multihead(), ck_attention_ggml_out_graph_enabled(), ck_attention_head_full_ggml_graph_oracle_regular(), ck_attention_strict_scale_f32(), ck_attention_trace(), ck_attention_trace_float(), ck_attention_vec_dump_next_layer_id(), ck_strict_parity_enabled(), and qkv_index().
Referenced by attention_forward_full_head_major_gqa_ggml_strided().
| void attention_forward_full_head_major_gqa_pytorch_cpu_flash_bf16_storage | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens | ||
| ) |
Definition at line 4973 of file attention_kernels.c.
References ck_attention_full_bf16_pytorch_flash().
| void attention_forward_full_head_major_gqa_pytorch_cpu_flash_bf16_storage_token_output | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens | ||
| ) |
Definition at line 4998 of file attention_kernels.c.
References ck_attention_full_bf16_pytorch_flash().
| void attention_forward_full_head_major_gqa_sdpa_bf16_storage | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens | ||
| ) |
Definition at line 4948 of file attention_kernels.c.
References bf16_to_float(), ck_attention_full_bf16_sdpa_tiled(), and float_to_bf16().
| void attention_forward_full_head_major_gqa_tiled336_f16kv_fp32_strided | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens | ||
| ) |
Definition at line 3564 of file attention_kernels.c.
References ck_attention_forward_full_head_major_gqa_tiled_f16kv_fp32_strided(), and CK_GGML_FA_TILE_Q_LARGE.
| void attention_forward_full_head_major_gqa_tiled64_f16kv_fp32_strided | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens | ||
| ) |
Definition at line 3547 of file attention_kernels.c.
References ck_attention_forward_full_head_major_gqa_tiled_f16kv_fp32_strided(), and CK_GGML_FA_TILE_Q.
| void attention_forward_full_head_major_gqa_tiled_f16kv_fp32_strided | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens | ||
| ) |
Definition at line 3527 of file attention_kernels.c.
References ck_attention_forward_full_head_major_gqa_tiled_f16kv_fp32_strided(), CK_GGML_FA_TILE_Q, CK_GGML_FA_TILE_Q_LARGE, and CK_GGML_FA_TILE_Q_LARGE_MIN_TOKENS.
| void attention_forward_mixed_visual_chunk_head_major_gqa_flash_strided_gemma4 | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens, | ||
| int | visual_start, | ||
| int | visual_tokens | ||
| ) |
Definition at line 5216 of file attention_kernels.c.
References attention_forward_mixed_visual_chunk_head_major_gqa_flash_strided_gemma4_impl().
| void attention_forward_mixed_visual_chunk_head_major_gqa_flash_strided_gemma4_token_output | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens, | ||
| int | visual_start, | ||
| int | visual_tokens | ||
| ) |
Definition at line 5228 of file attention_kernels.c.
References attention_forward_mixed_visual_chunk_head_major_gqa_flash_strided_gemma4_impl().
| int attention_forward_query_key_head_major_f32 | ( | const float * | query, |
| const float * | key, | ||
| const float * | value, | ||
| float * | output, | ||
| float * | score_scratch, | ||
| int | num_heads, | ||
| int | query_tokens, | ||
| int | key_tokens, | ||
| int | head_dim, | ||
| float | scale | ||
| ) |
Definition at line 210 of file attention_kernels.c.
References ck_attention_forward_query_key_head_major_f32_run().
| int attention_forward_query_key_head_major_f32_packed_k | ( | const float * | query, |
| const float * | key, | ||
| const float * | value, | ||
| float * | output, | ||
| float * | score_scratch, | ||
| float * | key_transpose_scratch, | ||
| int | num_heads, | ||
| int | query_tokens, | ||
| int | key_tokens, | ||
| int | head_dim, | ||
| float | scale | ||
| ) |
Definition at line 227 of file attention_kernels.c.
References ck_attention_forward_query_key_head_major_f32_run().
| int attention_forward_query_key_head_major_tiled_f16kv_fp32 | ( | const float * | query, |
| const float * | key, | ||
| const float * | value, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | query_tokens, | ||
| int | key_tokens, | ||
| int | head_dim, | ||
| float | scale | ||
| ) |
Definition at line 3581 of file attention_kernels.c.
References ck_attention_forward_full_head_major_gqa_tiled_f16kv_fp32_strided(), ck_attention_strict_scale_f32(), CK_GGML_FA_TILE_Q, CK_GGML_FA_TILE_Q_LARGE, and CK_GGML_FA_TILE_Q_LARGE_MIN_TOKENS.
| void attention_forward_sparse_token_major_gqa_bf16cache_pytorch_cpu_flash_contract | ( | const float * | query, |
| const uint16_t * | key_cache, | ||
| const uint16_t * | value_cache, | ||
| const float * | selected_indices, | ||
| float * | output, | ||
| float * | score_scratch, | ||
| int | rows, | ||
| int | query_heads, | ||
| int | kv_heads, | ||
| int | head_dim, | ||
| int | selection_width, | ||
| int | context_length, | ||
| int | position | ||
| ) |
Definition at line 8452 of file attention_kernels.c.
References CK_ATTENTION_STATUS_OK.
| void attn_gate_sigmoid_mul_backward | ( | const float * | d_out, |
| const float * | x, | ||
| const float * | gate, | ||
| float * | d_x, | ||
| float * | d_gate, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | state_dim | ||
| ) |
Definition at line 187 of file hybrid_attention_kernels.c.
References hybrid_sigmoid().
| void attn_gate_sigmoid_mul_forward | ( | const float * | x, |
| const float * | gate, | ||
| float * | out, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | state_dim | ||
| ) |
Definition at line 116 of file hybrid_attention_kernels.c.
References hybrid_sigmoid().
| void attn_gate_sigmoid_mul_pytorch_bf16_storage | ( | const float * | x, |
| const float * | gate, | ||
| float * | out, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | state_dim | ||
| ) |
Definition at line 133 of file hybrid_attention_kernels.c.
References bf16_to_float(), float_to_bf16(), and recurrent_sigmoid_forward_pytorch_bf16_input_fp32_output().
| void attn_gate_softplus_mul_forward | ( | const float * | x, |
| const float * | gate, | ||
| float * | out, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | state_dim | ||
| ) |
Definition at line 162 of file hybrid_attention_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().
| void backward_causal_softmax_head_major | ( | float * | d_scores, |
| const float * | weights, | ||
| int | num_heads, | ||
| int | num_tokens, | ||
| int | aligned_context_window | ||
| ) |
Definition at line 382 of file softmax_kernels.c.
Referenced by backward_causal_softmax_head_major_bf16().
| void backward_causal_softmax_head_major_bf16 | ( | uint16_t * | d_scores, |
| const uint16_t * | weights, | ||
| int | num_heads, | ||
| int | num_tokens, | ||
| int | aligned_context_window, | ||
| float * | scratch_d_scores, | ||
| float * | scratch_weights | ||
| ) |
Definition at line 53 of file softmax_kernels_bf16.c.
References backward_causal_softmax_head_major(), bf16_tensor_to_float(), and float_tensor_to_bf16().
| void causal_softmax_head_major | ( | float * | scores, |
| int | num_heads, | ||
| int | num_tokens, | ||
| int | aligned_context_window | ||
| ) |
Causal softmax (in-place, row-wise)
test_softmax.py::TestSoftmaxForward::test_causal_softmax
test_softmax.py::TestSoftmaxForward::test_causal_vs_softmax
test_attention.py::TestAttentionForward::test_softmax_correctness
Applies causal mask (j > i => 0) and softmax to scores matrix. In-place on [num_heads, T, T] scores matrix.
After changes: make test && make llamacpp-parity-full
Definition at line 144 of file softmax_kernels.c.
Referenced by attention_forward_causal_head_major(), attention_forward_causal_head_major_gqa(), and causal_softmax_head_major_bf16().
| void causal_softmax_head_major_bf16 | ( | uint16_t * | scores, |
| int | num_heads, | ||
| int | num_tokens, | ||
| int | aligned_context_window, | ||
| float * | scratch | ||
| ) |
Definition at line 31 of file softmax_kernels_bf16.c.
References bf16_tensor_to_float(), causal_softmax_head_major(), and float_tensor_to_bf16().
| void causal_softmax_head_major_exact | ( | float * | scores, |
| int | num_heads, | ||
| int | num_tokens, | ||
| int | aligned_context_window | ||
| ) |
Causal softmax (exact version using stdlib expf)
test_softmax.py::TestSoftmaxForward::test_causal_softmax_exact
test_softmax.py::TestSoftmaxForward::test_exact_vs_fast
Exact causal softmax using standard library expf for numerical accuracy reference.
After changes: make test
Definition at line 339 of file softmax_kernels.c.
Referenced by attention_forward_causal_head_major_exact(), and attention_forward_causal_head_major_gqa_exact().
| int ck_attention_bf16_pytorch_gqa_available | ( | void | ) |
Definition at line 8511 of file attention_kernels.c.
Referenced by ck_attention_sparse_bf16_pytorch_gqa_available().
| void ck_attention_flash_decode_wrapper | ( | const float * | q_token, |
| const float * | k_cache, | ||
| const float * | v_cache, | ||
| float * | out_token, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | kv_tokens, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim | ||
| ) |
Wrapper to call TRUE flash attention from orchestration layer.
| q_token | Query token [H, D_h] |
| k_cache | Cached keys [T_k, H, D_h] |
| v_cache | Cached values [T_k, H, D_h] |
| out_token | Output [H, D_h] |
| num_heads | Number of heads |
| num_kv_heads | Number of KV heads (for GQA) |
| kv_tokens | Number of tokens in KV cache |
| cache_capacity | Cache capacity |
| head_dim | Head dimension |
| aligned_head_dim | Aligned head dimension |
Definition at line 72 of file ckernel_orchestration.c.
References attention_flash_decode(), and attention_forward_decode_head_major_gqa_regular().
Referenced by ck_layer_forward_rmsnorm_swiglu_decode(), ck_layer_forward_rmsnorm_swiglu_decode_fused(), ck_layer_forward_rmsnorm_swiglu_decode_q4_k(), and ck_layer_forward_rmsnorm_swiglu_decode_quant().
| float ck_attention_pytorch_sdpa_scale_f32 | ( | int | head_dim | ) |
Definition at line 4518 of file attention_kernels.c.
Referenced by ck_attention_full_bf16_sdpa_amx_range(), and ck_attention_full_bf16_sdpa_tiled_range().
| int ck_attention_sparse_bf16_pytorch_gqa_available | ( | void | ) |
Definition at line 8502 of file attention_kernels.c.
References ck_attention_bf16_pytorch_gqa_available().
| int ck_flash_attn_choose_tile_k | ( | int | D_h | ) |
Definition at line 108 of file attention_flash_true.c.
References ck_flash_attn_tile_k().
| int ck_flash_attn_fast_exp_kind | ( | void | ) |
Definition at line 112 of file attention_flash_true.c.
| int ck_gemm_bf16_amx_available | ( | void | ) |
Definition at line 1196 of file gemm_kernels_bf16.c.
Referenced by ck_attention_full_bf16_sdpa_amx_range(), gemm_nt_bf16_prefill_shape_safe_bf16_storage(), and gemm_nt_bf16_prefill_shape_safe_bf16_storage_workspace().
| int ck_gemm_bf16_fp32out_amx_raw | ( | const uint16_t * | A, |
| const uint16_t * | B, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K, | ||
| int | accumulate | ||
| ) |
Definition at line 1205 of file gemm_kernels_bf16.c.
References C.
Referenced by ck_attention_full_bf16_sdpa_amx_range().
| int ck_gemm_nt_f16_ggml_oracle | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 262 of file gemm_kernels_f16.c.
References C, and gemm_nt_f16_ggml_strict().
| int ck_gemm_nt_f16_simd_lanes | ( | void | ) |
Definition at line 583 of file gemm_kernels_f16.c.
| void ck_gemm_nt_head_major_q5_0 | ( | const float * | attn_out, |
| const void * | wo, | ||
| const float * | bias, | ||
| float * | output, | ||
| int | tokens, | ||
| int | embed_dim, | ||
| int | num_heads, | ||
| int | head_dim | ||
| ) |
Output projection from head-major attention (auto-dispatch)
This replaces flatten_head_major() + ck_gemm_nt_quant() with a single strided-access kernel that reads head-major attention output directly.
Definition at line 290 of file gemm_head_major_output.c.
References gemv_nt_q5_0_head_major_output().
Referenced by mega_fused_attention_prefill().
| void ck_gemm_nt_head_major_q8_0 | ( | const float * | attn_out, |
| const void * | wo, | ||
| const float * | bias, | ||
| float * | output, | ||
| int | tokens, | ||
| int | embed_dim, | ||
| int | num_heads, | ||
| int | head_dim | ||
| ) |
Output projection from head-major attention (Q8_0 weights)
Definition at line 315 of file gemm_head_major_output.c.
References CK_FP16_TO_FP32, block_q8_0::d, QK8_0, and block_q8_0::qs.
Referenced by mega_fused_attention_prefill().
| int ck_get_num_threads | ( | void | ) |
Definition at line 310 of file ckernel_strict.c.
References ck_set_num_threads(), g_num_threads, and g_threads_initialized.
Referenced by attention_forward_decode_head_major_gqa_flash_f16cache_contract(), and gemm_blocked_serial().
| int ck_get_physical_cores | ( | void | ) |
Definition at line 170 of file ckernel_strict.c.
References CK_ADD_PAIR.
| void ck_layout_head_to_token_f32 | ( | const float * | src, |
| float * | dst, | ||
| int | heads, | ||
| int | tokens, | ||
| int | head_dim | ||
| ) |
Definition at line 19 of file layout_kernels.c.
| void ck_layout_token_to_head_f32 | ( | const float * | src, |
| float * | dst, | ||
| int | tokens, | ||
| int | heads, | ||
| int | head_dim | ||
| ) |
Definition at line 6 of file layout_kernels.c.
| void * ck_memcpy_parallel_dispatch | ( | void * | dst, |
| const void * | src, | ||
| size_t | size | ||
| ) |
| int ck_multimodal_mrope_positions_2d | ( | int32_t * | positions, |
| int | total_tokens, | ||
| int | prefix_start, | ||
| int | position_base, | ||
| int | prefix_tokens, | ||
| int | grid_x, | ||
| int | grid_y, | ||
| int | text_pos | ||
| ) |
Definition at line 2892 of file rope_kernels.c.
References token.
| int ck_multimodal_prefix_insert_f32 | ( | const float * | source_rows, |
| int32_t * | token_ids, | ||
| float * | decoder_rows, | ||
| int | row_count, | ||
| int | source_row_stride, | ||
| int | decoder_row_stride, | ||
| int | copy_dim, | ||
| int | start_row, | ||
| int | decoder_capacity | ||
| ) |
Definition at line 342 of file embedding_kernels.c.
| const char * ck_q6_k_prepared_provider_name | ( | void | ) |
Definition at line 62 of file gemm_kernels_q6k_q8k.c.
| const char * ck_q6_k_q8_k_provider_name | ( | void | ) |
Definition at line 1367 of file gemm_kernels_q6k_q8k.c.
References ck_q6k_q8k_force_ref(), and ck_strict_parity_enabled().
| void ck_residual_add_backward | ( | const float * | d_out, |
| float * | d_a, | ||
| float * | d_b, | ||
| int | tokens, | ||
| int | aligned_embed_dim | ||
| ) |
Definition at line 151 of file ckernel_orchestration.c.
| void ck_residual_add_token_major | ( | const float * | a, |
| const float * | b, | ||
| float * | out, | ||
| int | tokens, | ||
| int | aligned_embed_dim | ||
| ) |
Definition at line 139 of file ckernel_orchestration.c.
Referenced by ck_layer_forward_rmsnorm_swiglu_decode_fused_attn_impl(), mega_fused_attention_prefill(), and mega_fused_attention_prefill_q8_0().
| void ck_residual_add_token_major_bf16_storage | ( | const float * | a, |
| const float * | b, | ||
| float * | out, | ||
| int | tokens, | ||
| int | aligned_embed_dim | ||
| ) |
Definition at line 67 of file add_kernels_bf16.c.
References bf16_to_float(), and float_to_bf16().
| void ck_residual_add_token_major_parallel_dispatch | ( | const float * | a, |
| const float * | b, | ||
| float * | out, | ||
| int | tokens, | ||
| int | aligned_embed_dim | ||
| ) |
| void ck_set_num_threads | ( | int | num_threads | ) |
Definition at line 280 of file ckernel_strict.c.
References ck_get_physical_cores(), ck_parse_env_int(), g_num_threads, and g_threads_initialized.
Referenced by ck_get_num_threads().
| void ck_set_strict_parity | ( | int | enabled | ) |
Definition at line 28 of file ckernel_strict.c.
References ck_strict_next_gemm_a_size, ck_strict_next_gemm_a_valid, and ck_strict_parity.
| const float * ck_strict_consume_next_gemm_a | ( | size_t | elems | ) |
Definition at line 70 of file ckernel_strict.c.
References ck_strict_next_gemm_a, ck_strict_next_gemm_a_size, ck_strict_next_gemm_a_valid, and ck_strict_parity.
Referenced by gemm_nt_q8_0_q8_0_contract().
| int ck_strict_mtmd_clip_encode_planar_f32 | ( | const float * | planar, |
| int | channels, | ||
| int | height, | ||
| int | width, | ||
| float * | out, | ||
| size_t | out_elems | ||
| ) |
Definition at line 84 of file ckernel_strict.c.
| int ck_strict_parity_enabled | ( | void | ) |
Definition at line 43 of file ckernel_strict.c.
References ck_strict_parity.
Referenced by adamw_update_f32_impl(), attention_forward_decode_head_major_gqa_regular(), attention_forward_full_head_major_gqa_exact_strided(), attention_forward_full_head_major_gqa_ggml_strided_workspace(), attention_forward_head_major_gqa_flash_impl(), attention_forward_mixed_visual_chunk_head_major_gqa_flash_strided_gemma4_impl(), ck_dot_q6_k_q8_k_fast_or_ref(), ck_layer_forward_rmsnorm_swiglu(), ck_layer_forward_rmsnorm_swiglu_ref(), ck_mlp_swiglu_forward(), ck_mlp_swiglu_forward_ref(), ck_q6_k_q8_k_provider_name(), ck_q8k_activations_enabled(), gated_deltanet_autoregressive_forward(), gated_deltanet_impl_name(), geglu_forward_fp32(), gemm_avx512_parallel(), gemm_blocked_serial(), gemm_fine_grained_parallel(), gemm_naive_parallel(), gemm_nn_avx512(), gemm_nn_avx512_probe(), gemm_nn_blocked(), gemm_nn_parallel(), gemm_nt_f16(), gemm_nt_fp32_exact_parallel_dispatch(), gemm_nt_q6_k_q8_k_m4_tile(), gemm_nt_q8_0_q8_0_contract(), gemm_tn_avx512(), gemm_tn_blocked(), gemm_tn_parallel(), gemv_q4_k_q8_k_vnni(), gemv_q6_k_q8_k(), gemv_q6_k_q8_k_parallel_simd(), gemv_q8_0_q8_0_contract(), layernorm_forward_rolled_slice(), layernorm_forward_unrolled_slice(), mrope_qk_imrope_positions(), mrope_qk_vision(), rmsnorm_backward(), rmsnorm_forward_strided_f32(), softmax_cross_entropy_loss_index_mean_impl(), softmax_cross_entropy_loss_legacy_mean_impl(), swiglu_backward(), swiglu_forward(), and swiglu_forward_q8_k().
| void ck_strict_store_next_gemm_a | ( | const float * | data, |
| size_t | elems | ||
| ) |
Definition at line 48 of file ckernel_strict.c.
References ck_strict_next_gemm_a, ck_strict_next_gemm_a_cap, ck_strict_next_gemm_a_size, ck_strict_next_gemm_a_valid, and ck_strict_parity.
Referenced by ck_attention_full_ggml_graph_oracle_multihead().
| CKMathBackend ckernel_backend_native | ( | void | ) |
Obtain the built-in native backend (single-node CPU, C + intrinsics).
Definition at line 39 of file backend_native.c.
References ckernel_sgemm_native(), and CKMathBackend::sgemm.
| void deepseek_csa_attention_backward_f32 | ( | const float * | d_out, |
| const float * | q, | ||
| const float * | k, | ||
| const float * | v, | ||
| const int * | indices, | ||
| const float * | attn, | ||
| float * | d_q, | ||
| float * | d_k, | ||
| float * | d_v, | ||
| int | query_tokens, | ||
| int | key_tokens, | ||
| int | heads, | ||
| int | dim, | ||
| int | top_k, | ||
| float | scale | ||
| ) |
Definition at line 621 of file deepseek_kernels.c.
References ds_qkv_idx().
| void deepseek_csa_attention_f32 | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| const int * | indices, | ||
| float * | out, | ||
| float * | attn, | ||
| int | query_tokens, | ||
| int | key_tokens, | ||
| int | heads, | ||
| int | dim, | ||
| int | top_k, | ||
| float | scale | ||
| ) |
Definition at line 562 of file deepseek_kernels.c.
References ds_qkv_idx(), and ds_softmax().
Referenced by deepseek_hybrid_attention_f32().
| void deepseek_dsa_topk_softmax_backward_f32 | ( | const int * | indices, |
| const float * | weights, | ||
| const float * | d_weights, | ||
| float * | d_scores, | ||
| int | tokens, | ||
| int | heads, | ||
| int | key_count, | ||
| int | top_k | ||
| ) |
Definition at line 153 of file deepseek_kernels.c.
References topk_softmax_backward_f32().
| void deepseek_dsa_topk_softmax_f32 | ( | const float * | scores, |
| int * | indices, | ||
| float * | weights, | ||
| int | tokens, | ||
| int | heads, | ||
| int | key_count, | ||
| int | top_k | ||
| ) |
Definition at line 86 of file deepseek_kernels.c.
| void deepseek_hybrid_attention_f32 | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| const int * | indices, | ||
| float * | out, | ||
| float * | attn, | ||
| int | query_tokens, | ||
| int | key_tokens, | ||
| int | heads, | ||
| int | dim, | ||
| int | top_k, | ||
| float | scale, | ||
| int | mode | ||
| ) |
Definition at line 683 of file deepseek_kernels.c.
References deepseek_csa_attention_f32().
| void deepseek_mhc_mix_backward_f32 | ( | const float * | d_out, |
| const float * | streams, | ||
| const float * | mix, | ||
| float * | d_streams, | ||
| float * | d_mix, | ||
| int | tokens, | ||
| int | n_streams, | ||
| int | dim | ||
| ) |
Definition at line 53 of file deepseek_kernels.c.
References ds_mhc_idx(), and ds_mix_idx().
| void deepseek_mhc_mix_f32 | ( | const float * | streams, |
| const float * | mix, | ||
| float * | out, | ||
| int | tokens, | ||
| int | n_streams, | ||
| int | dim | ||
| ) |
Definition at line 30 of file deepseek_kernels.c.
References ds_mhc_idx(), and ds_mix_idx().
| void deepseek_mla_attention_decode_f32 | ( | const float * | q, |
| const float * | k_cache, | ||
| const float * | v_cache, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | cache_len, | ||
| int | qk_head_dim, | ||
| int | v_head_dim, | ||
| int | max_seq_len, | ||
| int | cache_stride | ||
| ) |
Definition at line 1044 of file deepseek_kernels.c.
References deepseek_mla_attention_decode_f32_workspace().
| void deepseek_mla_attention_decode_f32_workspace | ( | const float * | q, |
| const float * | k_cache, | ||
| const float * | v_cache, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | cache_len, | ||
| int | qk_head_dim, | ||
| int | v_head_dim, | ||
| int | max_seq_len, | ||
| int | cache_stride, | ||
| float | scale, | ||
| float * | scores, | ||
| size_t | scores_bytes | ||
| ) |
Definition at line 978 of file deepseek_kernels.c.
References score.
Referenced by deepseek_mla_attention_decode_f32().
| void deepseek_mla_attention_f32 | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | qk_head_dim, | ||
| int | v_head_dim | ||
| ) |
Definition at line 879 of file deepseek_kernels.c.
References deepseek_mla_attention_f32_workspace().
| void deepseek_mla_attention_f32_parallel_dispatch | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | qk_head_dim, | ||
| int | v_head_dim, | ||
| float | scale, | ||
| float * | scores, | ||
| size_t | scores_bytes | ||
| ) |
Definition at line 839 of file deepseek_kernels.c.
References ck_threadpool_dispatch_n(), ck_threadpool_global(), ck_threadpool_n_threads(), deepseek_mla_attention_f32_workspace(), and ds_mla_attention_f32_work().
| void deepseek_mla_attention_f32_workspace | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| float * | output, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | qk_head_dim, | ||
| int | v_head_dim, | ||
| float | scale, | ||
| float * | scores, | ||
| size_t | scores_bytes | ||
| ) |
Definition at line 768 of file deepseek_kernels.c.
References ds_mla_attention_f32_query_range().
Referenced by deepseek_mla_attention_f32(), and deepseek_mla_attention_f32_parallel_dispatch().
| void deepseek_mla_kv_cache_batch_store_f32 | ( | float * | k_cache, |
| float * | v_cache, | ||
| const float * | k, | ||
| const float * | v, | ||
| int | num_tokens, | ||
| int | num_kv_heads, | ||
| int | qk_head_dim, | ||
| int | v_head_dim, | ||
| int | max_seq_len, | ||
| int | cache_stride | ||
| ) |
Definition at line 900 of file deepseek_kernels.c.
| void deepseek_mla_kv_cache_store_f32 | ( | float * | k_cache, |
| float * | v_cache, | ||
| const float * | k, | ||
| const float * | v, | ||
| int | pos, | ||
| int | num_kv_heads, | ||
| int | qk_head_dim, | ||
| int | v_head_dim, | ||
| int | max_seq_len, | ||
| int | cache_stride | ||
| ) |
Definition at line 937 of file deepseek_kernels.c.
| void deepseek_mla_kv_decompress_bf16 | ( | const float * | compressed_kv, |
| const uint16_t * | kv_b_proj, | ||
| float * | k_nope, | ||
| float * | value, | ||
| int | tokens, | ||
| int | heads, | ||
| int | kv_lora_rank, | ||
| int | qk_nope_dim, | ||
| int | v_dim | ||
| ) |
Definition at line 270 of file deepseek_kernels.c.
References deepseek_mla_kv_decompress_bf16_token_range().
Referenced by deepseek_mla_kv_decompress_bf16_parallel_dispatch().
| void deepseek_mla_kv_decompress_bf16_parallel_dispatch | ( | const float * | compressed_kv, |
| const uint16_t * | kv_b_proj, | ||
| float * | k_nope, | ||
| float * | value, | ||
| int | tokens, | ||
| int | heads, | ||
| int | kv_lora_rank, | ||
| int | qk_nope_dim, | ||
| int | v_dim | ||
| ) |
Definition at line 308 of file deepseek_kernels.c.
References ck_threadpool_global(), ck_threadpool_n_threads(), ck_threadpool_parallel_for_n(), deepseek_mla_kv_decompress_bf16(), and ds_mla_kv_decompress_bf16_rows().
| void deepseek_mla_kv_decompress_bf16_token_range | ( | const float * | compressed_kv, |
| const uint16_t * | kv_b_proj, | ||
| float * | k_nope, | ||
| float * | value, | ||
| int | tokens, | ||
| int | heads, | ||
| int | kv_lora_rank, | ||
| int | qk_nope_dim, | ||
| int | v_dim, | ||
| int | token_begin, | ||
| int | token_end | ||
| ) |
Definition at line 225 of file deepseek_kernels.c.
References bf16_to_float(), ds_mla_thd_idx(), ds_mla_tok_idx(), and float_to_bf16().
Referenced by deepseek_mla_kv_decompress_bf16(), and ds_mla_kv_decompress_bf16_rows().
| void deepseek_mla_kv_decompress_f32 | ( | const float * | compressed_kv, |
| const float * | kv_b_proj, | ||
| float * | k_nope, | ||
| float * | value, | ||
| int | tokens, | ||
| int | heads, | ||
| int | kv_lora_rank, | ||
| int | qk_nope_dim, | ||
| int | v_dim | ||
| ) |
Definition at line 185 of file deepseek_kernels.c.
References ds_mla_thd_idx(), and ds_mla_tok_idx().
| void deepseek_mla_partial_rope_concat_f32 | ( | const float * | q_nope, |
| const float * | q_pe, | ||
| const float * | k_nope, | ||
| const float * | k_pe, | ||
| const float * | cos, | ||
| const float * | sin, | ||
| float * | query, | ||
| float * | key, | ||
| int | tokens, | ||
| int | heads, | ||
| int | qk_nope_dim, | ||
| int | qk_rope_dim | ||
| ) |
Definition at line 367 of file deepseek_kernels.c.
References ds_mla_apply_kimi_rope(), ds_mla_thd_idx(), and ds_mla_tok_idx().
| void deepseek_mla_partial_rope_concat_packed_bf16_storage | ( | const float * | q_packed, |
| const float * | k_nope, | ||
| const float * | kv_a_packed, | ||
| const float * | cos, | ||
| const float * | sin, | ||
| float * | query, | ||
| float * | key, | ||
| int | tokens, | ||
| int | heads, | ||
| int | kv_lora_rank, | ||
| int | qk_nope_dim, | ||
| int | qk_rope_dim | ||
| ) |
Definition at line 473 of file deepseek_kernels.c.
References ds_mla_bf16_round(), and ds_mla_thd_idx().
| void deepseek_mla_partial_rope_concat_packed_f32 | ( | const float * | q_packed, |
| const float * | k_nope, | ||
| const float * | kv_a_packed, | ||
| const float * | cos, | ||
| const float * | sin, | ||
| float * | query, | ||
| float * | key, | ||
| int | tokens, | ||
| int | heads, | ||
| int | kv_lora_rank, | ||
| int | qk_nope_dim, | ||
| int | qk_rope_dim | ||
| ) |
Definition at line 406 of file deepseek_kernels.c.
References ds_mla_thd_idx().
| void dequant_q4_0_row | ( | const void * | src, |
| float * | dst, | ||
| size_t | n_elements | ||
| ) |
Dequantize Q4_0 row (multiple blocks)
| src | Q4_0 data |
| dst | FP32 output |
| n_elements | Number of elements to dequantize |
Definition at line 63 of file dequant_kernels.c.
References dequant_q4_0_block(), and QK4_0.
| void dequant_q4_1_row | ( | const void * | src, |
| float * | dst, | ||
| size_t | n_elements | ||
| ) |
Dequantize Q4_1 row (multiple blocks)
Definition at line 141 of file dequant_kernels.c.
References dequant_q4_1_block(), and QK4_1.
Referenced by dequant_row().
| void dequant_q4_k_row | ( | const void * | src, |
| float * | dst, | ||
| size_t | n_elements | ||
| ) |
Dequantize Q4_K row (multiple blocks)
Definition at line 372 of file dequant_kernels.c.
References dequant_q4_k_block(), and QK_K.
Referenced by embedding_forward_q4_k().
| void dequant_q5_0_row | ( | const void * | src, |
| float * | dst, | ||
| size_t | n_elements | ||
| ) |
Dequantize Q5_0 row (multiple blocks)
Definition at line 198 of file dequant_kernels.c.
References dequant_q5_0_block(), and QK5_0.
Referenced by embedding_forward_q5_0(), moe_relu2_expert_forward_q5_0_q5_0(), moe_relu2_expert_forward_q5_0_q8_0(), and qwen4_ple_ngram_embed_impl().
| void dequant_q5_1_row | ( | const void * | src, |
| float * | dst, | ||
| size_t | n_elements | ||
| ) |
Dequantize Q5_1 row (multiple blocks)
Definition at line 257 of file dequant_kernels.c.
References dequant_q5_1_block(), and QK5_1.
Referenced by dequant_row(), and moe_relu2_shared_forward_q5_1_q8_0().
| void dequant_q6_k_row | ( | const void * | src, |
| float * | dst, | ||
| size_t | n_elements | ||
| ) |
Dequantize Q6_K row (multiple blocks)
Definition at line 422 of file dequant_kernels.c.
References dequant_q6_k_block(), and QK_K.
Referenced by embedding_forward_q6_k().
| void dequant_q8_0_row | ( | const void * | src, |
| float * | dst, | ||
| size_t | n_elements | ||
| ) |
Dequantize Q8_0 row (multiple blocks)
Definition at line 288 of file dequant_kernels.c.
References dequant_q8_0_block(), and QK8_0.
Referenced by dequant_row(), embedding_forward_q8_0(), moe_relu2_expert_forward_q5_0_q8_0(), and moe_relu2_shared_forward_q5_1_q8_0().
| void embedding_backward | ( | const int32_t * | token_ids, |
| int | token_count, | ||
| const float * | d_output, | ||
| float * | d_token_embeddings, | ||
| float * | d_pos_embeddings, | ||
| int | vocab_size, | ||
| int | embed_dim, | ||
| int | aligned_embed_dim, | ||
| int | context_window, | ||
| int | add_pos | ||
| ) |
Definition at line 296 of file embedding_kernels.c.
References vocab_size.
| void embedding_backward_bf16 | ( | const int32_t * | token_ids, |
| int | token_count, | ||
| const uint16_t * | d_output, | ||
| uint16_t * | d_token_embeddings, | ||
| uint16_t * | d_pos_embeddings, | ||
| int | vocab_size, | ||
| int | embed_dim, | ||
| int | aligned_embed_dim, | ||
| int | context_window, | ||
| int | add_pos | ||
| ) |
Definition at line 123 of file embedding_kernels_bf16.c.
References bf16_to_float(), float_to_bf16(), and vocab_size.
| void embedding_backward_bf16_mixed | ( | const int32_t * | token_ids, |
| int | token_count, | ||
| const uint16_t * | d_output, | ||
| float * | d_token_embeddings, | ||
| float * | d_pos_embeddings, | ||
| int | vocab_size, | ||
| int | embed_dim, | ||
| int | aligned_embed_dim, | ||
| int | context_window, | ||
| int | add_pos | ||
| ) |
Definition at line 166 of file embedding_kernels_bf16.c.
References bf16_to_float(), and vocab_size.
| void embedding_forward | ( | const int32_t * | token_ids, |
| int | token_count, | ||
| int | vocab_size, | ||
| const float * | token_embeddings, | ||
| const float * | pos_embeddings, | ||
| float * | output, | ||
| int | embed_dim, | ||
| int | aligned_embed_dim, | ||
| int | context_window, | ||
| int | add_pos | ||
| ) |
Definition at line 22 of file embedding_kernels.c.
References vocab_size.
| void embedding_forward_bf16 | ( | const int32_t * | token_ids, |
| int | token_count, | ||
| int | vocab_size, | ||
| const uint16_t * | token_embeddings, | ||
| const uint16_t * | pos_embeddings, | ||
| uint16_t * | output, | ||
| int | embed_dim, | ||
| int | aligned_embed_dim, | ||
| int | context_window, | ||
| int | add_pos | ||
| ) |
Definition at line 21 of file embedding_kernels_bf16.c.
References bf16_to_float(), float_to_bf16(), and vocab_size.
| void embedding_forward_bf16_fp32 | ( | const int32_t * | token_ids, |
| int | token_count, | ||
| int | vocab_size, | ||
| const uint16_t * | token_embeddings, | ||
| const float * | pos_embeddings, | ||
| float * | output, | ||
| int | embed_dim, | ||
| int | aligned_embed_dim, | ||
| int | context_window, | ||
| int | add_pos | ||
| ) |
Definition at line 73 of file embedding_kernels_bf16.c.
References bf16_to_float(), and vocab_size.
| void embedding_forward_q4_k | ( | const int32_t * | token_ids, |
| int | token_count, | ||
| int | vocab_size, | ||
| const void * | token_embeddings, | ||
| const float * | pos_embeddings, | ||
| float * | output, | ||
| int | embed_dim, | ||
| int | aligned_embed_dim, | ||
| int | context_window, | ||
| int | add_pos | ||
| ) |
Definition at line 76 of file embedding_kernels.c.
References CK_DT_Q4_K, ck_dtype_row_bytes(), dequant_q4_k_row(), and vocab_size.
Referenced by model_decode_token(), model_decode_token(), model_decode_token(), model_decode_token(), model_forward_prefill_impl(), model_forward_prefill_impl(), model_forward_prefill_impl(), model_forward_prefill_impl(), qwen2_0_5b_decode_decode_token(), qwen2_0_5b_decode_decode_token(), qwen2_0_5b_decode_decode_token(), qwen2_0_5b_decode_decode_token(), qwen2_0_5b_decode_forward_prefill_impl(), qwen2_0_5b_decode_forward_prefill_impl(), qwen2_0_5b_decode_forward_prefill_impl(), and qwen2_0_5b_decode_forward_prefill_impl().
| void embedding_forward_q5_0 | ( | const int32_t * | token_ids, |
| int | token_count, | ||
| int | vocab_size, | ||
| const void * | token_embeddings, | ||
| const float * | pos_embeddings, | ||
| float * | output, | ||
| int | embed_dim, | ||
| int | aligned_embed_dim, | ||
| int | context_window, | ||
| int | add_pos | ||
| ) |
Definition at line 131 of file embedding_kernels.c.
References CK_DT_Q5_0, ck_dtype_row_bytes(), dequant_q5_0_row(), and vocab_size.
| void embedding_forward_q6_k | ( | const int32_t * | token_ids, |
| int | token_count, | ||
| int | vocab_size, | ||
| const void * | token_embeddings, | ||
| const float * | pos_embeddings, | ||
| float * | output, | ||
| int | embed_dim, | ||
| int | aligned_embed_dim, | ||
| int | context_window, | ||
| int | add_pos | ||
| ) |
Definition at line 241 of file embedding_kernels.c.
References CK_DT_Q6_K, ck_dtype_row_bytes(), dequant_q6_k_row(), and vocab_size.
| void embedding_forward_q8_0 | ( | const int32_t * | token_ids, |
| int | token_count, | ||
| int | vocab_size, | ||
| const void * | token_embeddings, | ||
| const float * | pos_embeddings, | ||
| float * | output, | ||
| int | embed_dim, | ||
| int | aligned_embed_dim, | ||
| int | context_window, | ||
| int | add_pos | ||
| ) |
Definition at line 186 of file embedding_kernels.c.
References CK_DT_Q8_0, ck_dtype_row_bytes(), dequant_q8_0_row(), and vocab_size.
Referenced by qwen2_0_5b_decode_decode_token(), and qwen2_0_5b_decode_forward_prefill_impl().
| 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_parallel_dispatch | ( | 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 | ||
| ) |
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 fc1_backward_kernel | ( | const float * | d_output, |
| const float * | fc1_input, | ||
| const float * | W_fc1, | ||
| float * | d_input, | ||
| float * | d_W_fc1, | ||
| float * | d_b_fc1, | ||
| int | T, | ||
| int | aligned_in, | ||
| int | aligned_out, | ||
| int | num_threads | ||
| ) |
Definition at line 174 of file mlp_kernels.c.
References gemm_nn_simd(), and gemm_tn_parallel().
Referenced by ck_layer_backward_rmsnorm_swiglu().
| void fc2_backward_kernel | ( | const float * | d_output, |
| const float * | fc2_input, | ||
| const float * | W_fc2, | ||
| float * | d_input, | ||
| float * | d_W_fc2, | ||
| float * | d_b_fc2, | ||
| int | T, | ||
| int | aligned_in, | ||
| int | aligned_out, | ||
| int | num_threads | ||
| ) |
Definition at line 126 of file mlp_kernels.c.
References gemm_nn_simd(), and gemm_tn_parallel().
Referenced by ck_attention_project_head_major_backward(), ck_layer_backward_rmsnorm_swiglu(), and ck_qkv_project_head_major_backward().
| void feature_concat | ( | const float * | main_input, |
| const float * | branch_input, | ||
| float * | output, | ||
| int | rows, | ||
| int | main_dim, | ||
| int | branch_slice_dim, | ||
| int | num_branch_slices | ||
| ) |
Definition at line 804 of file vision_kernels.c.
| void feature_concat_2way | ( | const float * | main_input, |
| const float * | branch_input, | ||
| float * | output, | ||
| int | rows, | ||
| int | main_dim, | ||
| int | branch_slice_dim, | ||
| int | num_branch_slices | ||
| ) |
Definition at line 756 of file vision_kernels.c.
| void feature_slice_copy | ( | const float * | src, |
| float * | dst, | ||
| int | rows, | ||
| int | src_dim, | ||
| int | dst_dim, | ||
| int | dst_feature_offset | ||
| ) |
Definition at line 783 of file vision_kernels.c.
| void final_logit_scale_f32 | ( | float * | logits, |
| int | tokens, | ||
| int | vocab_size, | ||
| float | scale | ||
| ) |
Definition at line 7 of file logit_kernels.c.
References vocab_size.
| void fused_mlp_swiglu_decode | ( | const float * | x, |
| const float * | W_gate, | ||
| const float * | W_up, | ||
| const float * | W_down, | ||
| const float * | b_gate, | ||
| const float * | b_up, | ||
| const float * | b_down, | ||
| float * | output, | ||
| int | D, | ||
| int | Hff | ||
| ) |
Definition at line 154 of file mlp_fused_decode.c.
References __attribute__(), MLP_TILE_SIZE, and silu_scalar().
| void fused_mlp_swiglu_decode_tiled | ( | const float * | x, |
| const float * | W_gate, | ||
| const float * | W_up, | ||
| const float * | W_down, | ||
| const float * | b_gate, | ||
| const float * | b_up, | ||
| const float * | b_down, | ||
| float * | output, | ||
| int | D, | ||
| int | Hff | ||
| ) |
Definition at line 429 of file mlp_fused_decode.c.
References __attribute__(), and silu_scalar().
Referenced by fused_mlp_swiglu_decode_v2().
| void fused_mlp_swiglu_decode_v2 | ( | const float * | x, |
| const float * | W_gate, | ||
| const float * | W_up, | ||
| const float * | W_down, | ||
| const float * | b_gate, | ||
| const float * | b_up, | ||
| const float * | b_down, | ||
| float * | output, | ||
| int | D, | ||
| int | Hff | ||
| ) |
Definition at line 318 of file mlp_fused_decode.c.
References __attribute__(), fused_mlp_swiglu_decode_tiled(), MAX_SWIGLU_STACK, and silu_scalar().
Referenced by ck_mlp_swiglu_forward_fully_fused_token().
| void fused_mlp_swiglu_prefill | ( | const float * | x, |
| const float * | W_gate, | ||
| const float * | W_up, | ||
| const float * | W_down, | ||
| float * | output, | ||
| int | seq_len, | ||
| int | hidden, | ||
| int | intermediate, | ||
| float * | scratch | ||
| ) |
Fused MLP (Gate + Up + SwiGLU + Down) for prefill.
Tiles along token dimension to keep gate/up/hidden in L3 cache.
| scratch | Temporary buffer from fused_mlp_swiglu_scratch_size() |
Definition at line 878 of file prefill_fused_gemm.c.
References fused_mlp_swiglu_prefill_bias().
| void fused_mlp_swiglu_prefill_bias | ( | const float * | x, |
| const float * | W_gate, | ||
| const float * | W_up, | ||
| const float * | W_down, | ||
| const float * | B_gate, | ||
| const float * | B_up, | ||
| const float * | B_down, | ||
| float * | output, | ||
| int | seq_len, | ||
| int | hidden, | ||
| int | intermediate, | ||
| float * | scratch | ||
| ) |
Fused MLP (Gate + Up + SwiGLU + Down) for prefill with biases.
Fused MLP (Gate + Up + SwiGLU + Down) for prefill with biases.
Definition at line 746 of file prefill_fused_gemm.c.
References add_bias_tile(), gemm_tile_nt_strided(), PREFILL_TILE_M, and silu().
Referenced by fused_mlp_swiglu_prefill().
| void fused_mlp_swiglu_prefill_w1w2_quant | ( | const float * | x, |
| const void * | W1, | ||
| const float * | B1, | ||
| CKDataType | w1_dt, | ||
| const void * | W2, | ||
| const float * | B2, | ||
| CKDataType | w2_dt, | ||
| float * | output, | ||
| int | seq_len, | ||
| int | embed_dim, | ||
| int | aligned_embed_dim, | ||
| int | intermediate_dim, | ||
| int | aligned_intermediate_dim, | ||
| void * | scratch | ||
| ) |
Quantized fused MLP for prefill (W1=gate+up, W2=down)
W1 uses Q8_0 activations (Q5_0/Q8_0 weights), W2 uses Q8_K activations (Q4_K/Q6_K weights).
Uses Q8_0 activations for W1 (Q5_0/Q8_0 weights) and Q8_K activations for W2 (Q4_K/Q6_K weights).
Definition at line 964 of file prefill_fused_gemm.c.
References align_up_size(), CK_DT_Q8_0, CK_DT_Q8_K, ck_dtype_row_bytes(), gemm_nt_q8_0_mlp_dispatch(), gemm_nt_q8_k_mlp_dispatch(), mlp_q8_0_dtype_supported(), mlp_q8_k_dtype_supported(), PREFILL_TILE_M, quantize_row_q8_0(), quantize_row_q8_k(), and silu_prefill().
Referenced by mega_fused_outproj_mlp_prefill().
| size_t fused_mlp_swiglu_prefill_w1w2_quant_scratch_size | ( | int | aligned_embed_dim, |
| int | aligned_intermediate_dim | ||
| ) |
Get scratch buffer size for fused_mlp_swiglu_prefill_w1w2_quant.
Definition at line 1062 of file prefill_fused_gemm.c.
References align_up_size(), CK_DT_Q8_0, CK_DT_Q8_K, ck_dtype_row_bytes(), and PREFILL_TILE_M.
Referenced by mega_fused_outproj_mlp_prefill_scratch_size().
| size_t fused_mlp_swiglu_scratch_size | ( | int | intermediate | ) |
Get scratch buffer size for fused_mlp_swiglu_prefill.
Get scratch buffer size for fused_mlp_swiglu_prefill.
Definition at line 898 of file prefill_fused_gemm.c.
References PREFILL_TILE_M.
| void fused_rmsnorm_qkv_prefill | ( | const float * | x, |
| const float * | gamma, | ||
| const float * | Wq, | ||
| const float * | Wk, | ||
| const float * | Wv, | ||
| float * | Q, | ||
| float * | K, | ||
| float * | V, | ||
| int | seq_len, | ||
| int | hidden, | ||
| int | q_dim, | ||
| int | kv_dim, | ||
| float | eps, | ||
| float * | scratch | ||
| ) |
Fused RMSNorm + QKV projection for prefill.
Tiles along token dimension to keep intermediate x_norm in L2 cache. Avoids ~7MB DRAM traffic per layer for seq_len=1024, hidden=896.
| scratch | Temporary buffer from fused_rmsnorm_qkv_scratch_size() |
Fused RMSNorm + QKV projection for prefill.
KEY INSIGHT: For Qwen2-0.5B, all QKV weights fit in L3: Wq (896×896) + Wk (128×896) + Wv (128×896) = 4.1MB < 6MB L3
So we use M-tiling (tokens) only:
This avoids both:
Definition at line 393 of file prefill_fused_gemm.c.
References gemm_tile_nt_strided(), PREFILL_TILE_M, and rmsnorm_tile().
| void fused_rmsnorm_qkv_prefill_head_major | ( | const float * | x, |
| const float * | gamma, | ||
| const float * | Wq, | ||
| const float * | Bq, | ||
| const float * | Wk, | ||
| const float * | Bk, | ||
| const float * | Wv, | ||
| const float * | Bv, | ||
| float * | Q, | ||
| float * | K, | ||
| float * | V, | ||
| int | seq_len, | ||
| int | embed_dim, | ||
| int | aligned_embed_dim, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens, | ||
| float | eps, | ||
| float * | scratch | ||
| ) |
Fused RMSNorm + QKV projection for prefill (head-major outputs)
Writes Q as [num_heads, seq_len, aligned_head_dim] and K/V with stride kv_stride_tokens for KV-cache compatibility.
Q is written as [num_heads, seq_len, aligned_head_dim]. K/V are written with kv_stride_tokens for KV-cache compatibility.
Definition at line 441 of file prefill_fused_gemm.c.
References add_bias_tile(), gemm_tile_nt_strided(), PREFILL_TILE_M, and rmsnorm_tile().
Referenced by mega_fused_attention_prefill(), and mega_fused_attention_prefill_q8_0().
| void fused_rmsnorm_qkv_prefill_head_major_quant | ( | const float * | x, |
| const float * | gamma, | ||
| const void * | Wq, | ||
| const float * | Bq, | ||
| CKDataType | wq_dt, | ||
| const void * | Wk, | ||
| const float * | Bk, | ||
| CKDataType | wk_dt, | ||
| const void * | Wv, | ||
| const float * | Bv, | ||
| CKDataType | wv_dt, | ||
| float * | Q, | ||
| float * | K, | ||
| float * | V, | ||
| int | seq_len, | ||
| int | embed_dim, | ||
| int | aligned_embed_dim, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | kv_stride_tokens, | ||
| float | eps, | ||
| void * | scratch | ||
| ) |
Fused RMSNorm + QKV projection for prefill (head-major, Q8 activations)
Supports Q5_0 or Q8_0 weights with Q8_0 activations.
Supports Q5_0 or Q8_0 weights with Q8_0 activations. Writes K/V directly into KV cache layout (kv_stride_tokens).
Definition at line 519 of file prefill_fused_gemm.c.
References align_up_size(), CK_DT_Q8_0, CK_DT_Q8_K, ck_dtype_row_bytes(), gemm_nt_q8_0_dispatch(), gemm_nt_q8_k_qkv_dispatch(), PREFILL_TILE_M, qkv_q8_0_dtype_supported(), qkv_q8_k_dtype_supported(), quantize_row_q8_0(), quantize_row_q8_k(), and rmsnorm_tile().
Referenced by mega_fused_attention_prefill(), and mega_fused_attention_prefill_q8_0().
| size_t fused_rmsnorm_qkv_prefill_head_major_quant_scratch_size | ( | int | aligned_embed_dim | ) |
Get scratch buffer size for fused_rmsnorm_qkv_prefill_head_major_quant.
Definition at line 651 of file prefill_fused_gemm.c.
References align_up_size(), CK_DT_Q8_0, CK_DT_Q8_K, ck_dtype_row_bytes(), and PREFILL_TILE_M.
Referenced by mega_fused_attention_prefill(), mega_fused_attention_prefill_q8_0(), mega_fused_attention_prefill_q8_0_scratch_size(), and mega_fused_attention_prefill_scratch_size().
| size_t fused_rmsnorm_qkv_scratch_size | ( | int | hidden | ) |
Get scratch buffer size for fused_rmsnorm_qkv_prefill.
Get scratch buffer size for fused_rmsnorm_qkv_prefill.
Definition at line 739 of file prefill_fused_gemm.c.
References PREFILL_TILE_M.
| void gated_deltanet_autoregressive_backward | ( | const float * | d_out, |
| const float * | d_state_out, | ||
| const float * | q, | ||
| const float * | k, | ||
| const float * | v, | ||
| const float * | g, | ||
| const float * | beta, | ||
| const float * | state_in, | ||
| const float * | state_out, | ||
| float * | d_q, | ||
| float * | d_k, | ||
| float * | d_v, | ||
| float * | d_g, | ||
| float * | d_beta, | ||
| float * | d_state_in, | ||
| int | num_heads, | ||
| int | state_dim, | ||
| float | norm_eps | ||
| ) |
Definition at line 1988 of file deltanet_kernels.c.
References CK_DELTANET_MAX_STACK_DIM, and gated_deltanet_autoregressive_backward_ref().
| void gated_deltanet_autoregressive_forward | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| const float * | g, | ||
| const float * | beta, | ||
| const float * | state_in, | ||
| float * | state_out, | ||
| float * | out, | ||
| int | num_heads, | ||
| int | state_dim, | ||
| float | norm_eps | ||
| ) |
Definition at line 1906 of file deltanet_kernels.c.
References ck_deltanet_force_ref(), ck_strict_parity_enabled(), and gated_deltanet_autoregressive_forward_ref().
| void gated_deltanet_llama_avx2_forward | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| const float * | g, | ||
| const float * | beta, | ||
| const float * | state_in, | ||
| float * | state_out, | ||
| float * | out, | ||
| int | num_heads, | ||
| int | group_count, | ||
| int | state_dim, | ||
| float | norm_eps | ||
| ) |
Definition at line 767 of file deltanet_kernels.c.
References gated_deltanet_llama_avx2_grouped_forward_transposed_impl().
Referenced by gated_deltanet_llama_avx2_prefill_forward().
| void gated_deltanet_llama_avx2_prefill_forward | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| const float * | g, | ||
| const float * | beta, | ||
| const float * | state_in, | ||
| float * | state_out, | ||
| float * | out, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | group_count, | ||
| int | state_dim, | ||
| float | norm_eps | ||
| ) |
Definition at line 1131 of file deltanet_kernels.c.
References gated_deltanet_llama_avx2_forward().
Referenced by gated_deltanet_llama_chunk64_prefill_forward().
| void gated_deltanet_llama_chunk64_head_forward | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| const float * | g, | ||
| const float * | beta, | ||
| const float * | state_in, | ||
| float * | state_out, | ||
| float * | out, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | group_count, | ||
| int | head, | ||
| int | state_dim | ||
| ) |
Definition at line 1202 of file deltanet_kernels.c.
References CK_DELTANET_LLAMA_CHUNK_MAX_DIM.
| void gated_deltanet_llama_chunk64_prefill_forward | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| const float * | g, | ||
| const float * | beta, | ||
| const float * | state_in, | ||
| float * | state_out, | ||
| float * | out, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | group_count, | ||
| int | state_dim, | ||
| float | norm_eps | ||
| ) |
Definition at line 1167 of file deltanet_kernels.c.
References CK_DELTANET_LLAMA_CHUNK_MAX_DIM, and gated_deltanet_llama_avx2_prefill_forward().
| void gated_deltanet_prefill_forward | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| const float * | g, | ||
| const float * | beta, | ||
| const float * | state_in, | ||
| float * | state_out, | ||
| float * | out, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | state_dim, | ||
| float | norm_eps | ||
| ) |
Definition at line 1949 of file deltanet_kernels.c.
References gated_deltanet_autoregressive_forward().
| void gated_deltanet_pytorch_grouped_bf16_forward | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| const float * | g, | ||
| const float * | beta, | ||
| const float * | state_in, | ||
| float * | state_out, | ||
| float * | out, | ||
| int | num_heads, | ||
| int | group_count, | ||
| int | state_dim, | ||
| float | norm_eps | ||
| ) |
Definition at line 1089 of file deltanet_kernels.c.
References gated_deltanet_pytorch_grouped_bf16_forward_impl().
Referenced by gated_deltanet_pytorch_grouped_bf16_prefill_forward().
| void gated_deltanet_pytorch_grouped_bf16_prefill_forward | ( | const float * | q, |
| const float * | k, | ||
| const float * | v, | ||
| const float * | g, | ||
| const float * | beta, | ||
| const float * | state_in, | ||
| float * | state_out, | ||
| float * | out, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | group_count, | ||
| int | state_dim, | ||
| float | norm_eps | ||
| ) |
Definition at line 1243 of file deltanet_kernels.c.
References gated_deltanet_pytorch_grouped_bf16_forward().
| void geglu_backward_bf16_mixed | ( | const uint16_t * | x, |
| const uint16_t * | d_out, | ||
| float * | d_x, | ||
| int | tokens, | ||
| int | dim | ||
| ) |
Definition at line 139 of file geglu_kernels.c.
References bf16_to_float().
| void geglu_backward_fp32 | ( | const float * | x, |
| const float * | d_out, | ||
| float * | d_x, | ||
| int | tokens, | ||
| int | dim | ||
| ) |
Definition at line 99 of file geglu_kernels.c.
| void geglu_forward_bf16 | ( | const uint16_t * | x, |
| uint16_t * | out, | ||
| int | tokens, | ||
| int | dim, | ||
| float * | scratch | ||
| ) |
Definition at line 83 of file geglu_kernels.c.
References bf16_tensor_to_float(), float_tensor_to_bf16(), and geglu_forward_fp32().
| void geglu_forward_exact | ( | const float * | x, |
| float * | out, | ||
| int | tokens, | ||
| int | dim | ||
| ) |
Definition at line 42 of file geglu_kernels.c.
References ck_gelu_tanh_parity_f32().
Referenced by geglu_forward_fp32().
| void geglu_forward_fp32 | ( | const float * | x, |
| float * | out, | ||
| int | tokens, | ||
| int | dim | ||
| ) |
Definition at line 55 of file geglu_kernels.c.
References ck_strict_parity_enabled(), geglu_forward_exact(), and gelu_fast_inplace().
Referenced by geglu_forward_bf16().
| void geglu_forward_ggml_native | ( | const float * | x, |
| float * | out, | ||
| int | tokens, | ||
| int | dim | ||
| ) |
Definition at line 17 of file geglu_kernels.c.
References gelu_ggml_native_inplace().
| void gelu_backward_exact | ( | const float * | input, |
| const float * | d_output, | ||
| float * | d_input, | ||
| size_t | n | ||
| ) |
Definition at line 368 of file gelu_kernels.c.
References __attribute__().
| void gelu_backward_exact_bf16 | ( | const uint16_t * | input, |
| const uint16_t * | d_output, | ||
| uint16_t * | d_input, | ||
| size_t | n, | ||
| float * | scratch_input, | ||
| float * | scratch_d_output, | ||
| float * | scratch_d_input | ||
| ) |
Definition at line 46 of file gelu_kernels_bf16.c.
References bf16_tensor_to_float(), float_tensor_to_bf16(), and gelu_backward_scalar().
| void gelu_backward_fast | ( | const float * | input, |
| const float * | d_output, | ||
| float * | d_input, | ||
| size_t | n | ||
| ) |
Definition at line 818 of file gelu_kernels.c.
References __attribute__().
Referenced by gelu_backward_fast_bf16().
| void gelu_backward_fast_bf16 | ( | const uint16_t * | input, |
| const uint16_t * | d_output, | ||
| uint16_t * | d_input, | ||
| size_t | n, | ||
| float * | scratch_input, | ||
| float * | scratch_d_output, | ||
| float * | scratch_d_input | ||
| ) |
Definition at line 69 of file gelu_kernels_bf16.c.
References bf16_tensor_to_float(), float_tensor_to_bf16(), and gelu_backward_fast().
| void gelu_backward_scalar | ( | const float * | input, |
| const float * | d_output, | ||
| float * | d_input, | ||
| size_t | n | ||
| ) |
Definition at line 794 of file gelu_kernels.c.
Referenced by gelu_backward_exact_bf16().
| void gelu_erf_bf16_storage | ( | float * | data, |
| size_t | n | ||
| ) |
Definition at line 609 of file gelu_kernels.c.
References bf16_to_float(), ck_gelu_system_erf(), and float_to_bf16().
| void gelu_erf_fp64_f32_inplace | ( | float * | data, |
| size_t | n | ||
| ) |
Definition at line 566 of file gelu_kernels.c.
References ck_gelu_system_erf().
Referenced by gelu_pytorch_erf_f32_inplace().
| void gelu_exact_inplace | ( | float * | data, |
| size_t | n | ||
| ) |
Definition at line 557 of file gelu_kernels.c.
References ck_gelu_tanh_f32().
Referenced by gelu_fast_inplace_bf16(), and mlp_token_parallel_exact().
| void gelu_fast_inplace | ( | float * | data, |
| size_t | n | ||
| ) |
GELU activation forward (fast approximation, in-place)
test_gelu.py::TestGELUForward::test_gelu_fast_inplace
test_gelu.py::TestGELUForward::test_gelu_vs_exact
test_parity.py::test_gelu_parity
Fast GELU approximation: 0.5 * x * (1 + tanh(sqrt(2/pi) * (x + 0.044715 * x^3))) In-place on contiguous buffer.
After changes: make test && make llamacpp-parity-full
Definition at line 243 of file gelu_kernels.c.
References __attribute__().
Referenced by mlp_token_parallel().
| void gelu_fast_inplace_bf16 | ( | uint16_t * | data, |
| size_t | n, | ||
| float * | scratch | ||
| ) |
Definition at line 31 of file gelu_kernels_bf16.c.
References bf16_tensor_to_float(), float_tensor_to_bf16(), and gelu_exact_inplace().
| void gelu_ggml_inplace | ( | float * | data, |
| size_t | n | ||
| ) |
Definition at line 753 of file gelu_kernels.c.
References ck_gelu_ggml_runtime_init(), ck_gelu_ggml_runtime_once, ck_gelu_ggml_table_f16, ck_gelu_ggml_table_init(), ck_gelu_ggml_table_once, ck_gelu_runtime_fp16_to_fp32, ck_gelu_runtime_fp32_to_fp16, ck_gelu_runtime_ready, ck_gelu_runtime_table_f16, ggml_fp16_to_fp32, and ggml_fp32_to_fp16.
| void gelu_ggml_native_inplace | ( | float * | data, |
| size_t | n | ||
| ) |
Definition at line 741 of file gelu_kernels.c.
References ck_gelu_ggml_table_f16, ck_gelu_ggml_table_init(), ck_gelu_ggml_table_once, ggml_fp16_to_fp32, and ggml_fp32_to_fp16.
| void gelu_pytorch_erf_f32_inplace | ( | float * | data, |
| size_t | n | ||
| ) |
Definition at line 580 of file gelu_kernels.c.
References gelu_erf_fp64_f32_inplace().
| void gelu_pytorch_erf_sleef_bf16_storage | ( | float * | data, |
| size_t | n | ||
| ) |
Definition at line 682 of file gelu_kernels.c.
References bf16_to_float(), and float_to_bf16().
| void gelu_pytorch_tanh_bf16_storage | ( | float * | data, |
| size_t | n | ||
| ) |
Definition at line 590 of file gelu_kernels.c.
References bf16_to_float(), and float_to_bf16().
| void gemm_avx512_parallel | ( | const float * | A, |
| const float * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 230 of file gemm_kernels.c.
References C, ck_strict_parity_enabled(), gemm_naive_parallel(), and gemm_naive_serial_float().
| void gemm_backward_bf16_mixed | ( | const uint16_t * | d_output, |
| const uint16_t * | input, | ||
| const uint16_t * | weight, | ||
| float * | d_input, | ||
| float * | d_weight, | ||
| float * | d_bias, | ||
| int | tokens, | ||
| int | in_dim, | ||
| int | out_dim | ||
| ) |
Definition at line 2043 of file gemm_kernels_bf16.c.
References bf16_to_float().
| void gemm_backward_f32_train_parallel_dispatch | ( | const float * | d_output, |
| const float * | input, | ||
| const float * | W, | ||
| float * | d_input, | ||
| float * | d_W, | ||
| float * | d_b, | ||
| int | T, | ||
| int | aligned_in, | ||
| int | aligned_out, | ||
| int | num_threads | ||
| ) |
Definition at line 610 of file ck_parallel_train.c.
References ck_threadpool_dispatch_n(), ck_threadpool_global(), ck_threadpool_n_threads(), ck_train_gemm_backward_serial(), ck_train_gemm_backward_work(), ck_train_outer_t1_compute_range(), ck_train_outer_t1_work(), ck_train_pick_active_threads(), and gemm_nn_simd().
| void gemm_backward_f32_train_parallel_dispatch_v2 | ( | const float * | d_output, |
| const float * | input, | ||
| const float * | W, | ||
| float * | d_input, | ||
| float * | d_W, | ||
| float * | d_b, | ||
| int | T, | ||
| int | aligned_in, | ||
| int | aligned_out, | ||
| int | num_threads | ||
| ) |
Definition at line 699 of file ck_parallel_train.c.
References ck_threadpool_dispatch_n(), ck_threadpool_global(), ck_threadpool_n_threads(), ck_train_gemm_backward_serial(), ck_train_gemm_backward_work(), ck_train_gemm_nn_work(), ck_train_outer_t1_compute_range(), ck_train_outer_t1_work(), ck_train_pick_active_threads(), and gemm_nn_simd().
| void gemm_bias_gelu_fused | ( | const float * | A, |
| const float * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 131 of file gemm_fused_kernels.c.
References C, and fast_gelu_scalar().
| void gemm_bias_relu_fused | ( | const float * | A, |
| const float * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 84 of file gemm_fused_kernels.c.
References C.
| void gemm_bias_silu_fused | ( | const float * | A, |
| const float * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 177 of file gemm_fused_kernels.c.
References C.
| void gemm_blocked_serial | ( | const float * | A, |
| const float * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 849 of file gemm_kernels.c.
References C, ck_gemm_add_bias(), ck_get_num_threads(), ck_min(), ck_strict_parity_enabled(), gemm_microkernel(), gemm_naive_serial_float(), and gemm_nt_matvec_parallel().
Referenced by ck_attention_project_head_major(), ck_gemm_nt_quant(), ck_mlp_swiglu_forward(), ck_mlp_swiglu_forward_fused_token(), ck_qkv_project_head_major(), ck_qkv_project_head_major_token(), ck_train_gemm_work(), gemm_blocked_serial_train_parallel_dispatch(), mlp_token_parallel(), and mlp_token_parallel_exact().
| void gemm_blocked_serial_bf16 | ( | const uint16_t * | A, |
| const uint16_t * | B, | ||
| const uint16_t * | bias, | ||
| uint16_t * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 424 of file gemm_kernels_bf16.c.
References C.
| void gemm_blocked_serial_train_parallel_dispatch | ( | const float * | A, |
| const float * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 167 of file ck_parallel_train.c.
References C, ck_threadpool_dispatch_n(), ck_threadpool_global(), ck_threadpool_n_threads(), ck_train_gemm_work(), and gemm_blocked_serial().
| void gemm_fine_grained_parallel | ( | const float * | A, |
| const float * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 286 of file gemm_kernels.c.
References C, ck_min(), ck_strict_parity_enabled(), gemm_naive_parallel(), and gemm_naive_serial_float().
| void gemm_microkernel | ( | const float * | A, |
| const float * | B, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K, | ||
| int | B_transposed | ||
| ) |
Definition at line 1134 of file gemm_microkernel.c.
References C, gemm_microkernel_blocked(), gemm_microkernel_blocked_bt(), gemm_microkernel_packed(), and PACK_THRESHOLD.
Referenced by gemm_blocked_serial().
| void gemm_microkernel_blocked | ( | const float * | A, |
| const float * | B, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 934 of file gemm_microkernel.c.
References C, gemm_init_threads(), gemm_microkernel_edge(), gemm_microkernel_sequential(), KC, MR, and NR.
Referenced by gemm_microkernel(), and gemm_microkernel_packed().
| void gemm_microkernel_blocked_bt | ( | const float * | A, |
| const float * | B, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 1058 of file gemm_microkernel.c.
References C, KC, MC, MR, NC, and NR.
Referenced by gemm_microkernel().
| void gemm_microkernel_packed | ( | const float * | A, |
| const float * | B, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 840 of file gemm_microkernel.c.
References C, and gemm_microkernel_blocked().
Referenced by gemm_microkernel().
| void gemm_naive_parallel | ( | const float * | A, |
| const float * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 206 of file gemm_kernels.c.
References C, ck_strict_parity_enabled(), and gemm_naive_serial_float().
Referenced by ck_attention_project_head_major_ref(), ck_mlp_swiglu_forward_ref(), ck_qkv_project_head_major_ref(), gemm_avx512_parallel(), and gemm_fine_grained_parallel().
| void gemm_nn_avx512 | ( | const float * | A, |
| const float * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 420 of file gemm_kernels.c.
References C, ck_strict_parity_enabled(), gemm_nn_parallel(), and gemm_nn_serial_double().
Referenced by gemm_nn_simd().
| void gemm_nn_blocked | ( | const float * | A, |
| const float * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 590 of file gemm_kernels.c.
References C, ck_min(), ck_strict_parity_enabled(), and gemm_nn_serial_double().
| void gemm_nn_parallel | ( | const float * | A, |
| const float * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 398 of file gemm_kernels.c.
References C, ck_strict_parity_enabled(), and gemm_nn_serial_double().
Referenced by gemm_nn_avx512(), and gemm_nn_avx512_probe().
| void gemm_nn_simd | ( | const float * | A, |
| const float * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 577 of file gemm_kernels.c.
References C, ck_gemm_nn_impl_probe_enabled(), gemm_nn_avx512(), and gemm_nn_avx512_probe().
Referenced by fc1_backward_kernel(), fc2_backward_kernel(), gemm_backward_f32_train_parallel_dispatch(), and gemm_backward_f32_train_parallel_dispatch_v2().
| void gemm_nt_bf16 | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 748 of file gemm_kernels_bf16.c.
References C, and gemm_nt_bf16_row_range().
Referenced by gemm_nt_bf16_parallel_dispatch().
| void gemm_nt_bf16_amx_bf16_storage | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 1311 of file gemm_kernels_bf16.c.
References C, and gemm_nt_bf16_amx_bf16_storage_workspace().
Referenced by gemm_nt_bf16_prefill_shape_safe_bf16_storage().
| void gemm_nt_bf16_amx_bf16_storage_workspace | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K, | ||
| uint16_t * | a_bf16, | ||
| size_t | a_bf16_bytes | ||
| ) |
Definition at line 1258 of file gemm_kernels_bf16.c.
References C, ck_bf16_convert_work(), ck_bf16_round_work(), ck_gemm_bf16_amx_work(), ck_threadpool_dispatch_n(), ck_threadpool_global(), and ck_threadpool_n_threads().
Referenced by gemm_nt_bf16_amx_bf16_storage(), and gemm_nt_bf16_prefill_shape_safe_bf16_storage_workspace().
| void gemm_nt_bf16_bf16_storage | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 2034 of file gemm_kernels_bf16.c.
References C, and gemm_nt_bf16_bf16_storage_parallel_dispatch().
| void gemm_nt_bf16_bf16_storage_parallel_dispatch | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 2010 of file gemm_kernels_bf16.c.
References C, ck_gemm_nt_bf16_storage_exact_rows(), ck_threadpool_global(), ck_threadpool_n_threads(), ck_threadpool_parallel_for_n(), and gemm_nt_bf16_bf16_storage_row_range().
Referenced by gemm_nt_bf16_bf16_storage().
| void gemm_nt_bf16_bf16_storage_row_range | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K, | ||
| int | row_begin, | ||
| int | row_end | ||
| ) |
Definition at line 1985 of file gemm_kernels_bf16.c.
References bf16_to_float(), C, float_to_bf16(), and gemm_nt_bf16_row_range().
Referenced by ck_gemm_nt_bf16_storage_exact_rows(), and gemm_nt_bf16_bf16_storage_parallel_dispatch().
| void gemm_nt_bf16_native_bf16_storage | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 1071 of file gemm_kernels_bf16.c.
References C, ck_gemm_bf16_native_work(), ck_threadpool_dispatch_n(), ck_threadpool_global(), and ck_threadpool_n_threads().
Referenced by gemm_nt_bf16_prefill_shape_safe_bf16_storage(), and gemm_nt_bf16_prefill_shape_safe_bf16_storage_workspace().
| void gemm_nt_bf16_parallel_dispatch | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 777 of file gemm_kernels_bf16.c.
References C, ck_gemm_nt_bf16_exact_rows(), ck_threadpool_global(), ck_threadpool_n_threads(), ck_threadpool_parallel_for_n(), and gemm_nt_bf16().
| void gemm_nt_bf16_prefill_shape_safe_bf16_storage | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 1347 of file gemm_kernels_bf16.c.
References C, ck_gemm_bf16_amx_available(), gemm_nt_bf16_amx_bf16_storage(), and gemm_nt_bf16_native_bf16_storage().
| void gemm_nt_bf16_prefill_shape_safe_bf16_storage_workspace | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K, | ||
| uint16_t * | a_bf16, | ||
| size_t | a_bf16_bytes | ||
| ) |
Definition at line 1333 of file gemm_kernels_bf16.c.
References C, ck_gemm_bf16_amx_available(), gemm_nt_bf16_amx_bf16_storage_workspace(), and gemm_nt_bf16_native_bf16_storage().
| void gemm_nt_bf16_pytorch_onednn_3_12_brgemm_bf16_storage | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 1551 of file gemm_kernels_bf16.c.
References C, and gemm_nt_bf16_pytorch_onednn_brgemm_bf16_storage_impl().
| void gemm_nt_bf16_pytorch_onednn_brgemm_bf16_storage | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 1536 of file gemm_kernels_bf16.c.
References C, and gemm_nt_bf16_pytorch_onednn_brgemm_bf16_storage_impl().
| void gemm_nt_bf16_row_range | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K, | ||
| int | row_begin, | ||
| int | row_end | ||
| ) |
Definition at line 720 of file gemm_kernels_bf16.c.
References bf16_to_float(), C, and float_to_bf16().
Referenced by ck_gemm_nt_bf16_exact_rows(), gemm_nt_bf16(), and gemm_nt_bf16_bf16_storage_row_range().
| void gemm_nt_f16 | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
NT GEMM wrapper for FP16 weights with the engine's standard ABI.
Contract: A: [M, K] fp32 activation matrix B: [N, K] fp16 weight matrix stored row-major (transposed layout) C: [M, N] fp32 output matrix
This wrapper follows llama.cpp's CPU F16 mul_mat contract: activation rows are rounded to FP16 first, then the dot runs as F16 x F16 with FP32 output accumulation. The lower-level gemm_f16() helper remains the direct F16-weight x FP32-activation operator for generic use.
Definition at line 970 of file gemm_kernels_f16.c.
References C, ck_strict_parity_enabled(), gemm_f16_input_fp16_ref(), gemm_f16_input_fp16_threadpool(), and gemm_nt_f16_ggml_strict().
| void gemm_nt_f16_clipped | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| const float * | input_min, | ||
| const float * | input_max, | ||
| const float * | output_min, | ||
| const float * | output_max, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 998 of file gemm_kernels_f16.c.
References C, fp16_to_fp32, and fp32_to_fp16.
| void gemm_nt_f32_llama_production | ( | const float * | A, |
| const float * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 1062 of file gemm_kernels.c.
References C, and ck_gemm_nt_f32_llama_production_output().
Referenced by ck_moe_shared_q4k_gated_workspace(), and moe_swiglu_shared_forward_q8_0_gated_workspace().
| void gemm_nt_f32_llama_production_output_range | ( | const float * | A, |
| const float * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K, | ||
| int | output_begin, | ||
| int | output_end | ||
| ) |
Definition at line 1049 of file gemm_kernels.c.
References C, and ck_gemm_nt_f32_llama_production_output().
| void gemm_nt_fp32_exact_parallel_dispatch | ( | const float * | A, |
| const float * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 179 of file gemm_kernels.c.
References C, ck_gemm_nt_fp32_exact_rows(), ck_strict_parity_enabled(), ck_threadpool_global(), ck_threadpool_n_threads(), and ck_threadpool_parallel_for_n().
| void gemm_nt_q4_0 | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Matrix-matrix multiply: C[M,N] = A[M,K] @ B[N,K]^T + bias.
| A | Input matrix [M x K], row-major FP32 |
| B | Weight matrix in Q4_0 format, [N x K] stored row-major |
| bias | Optional bias [N], NULL if not used |
| C | Output [M x N], row-major FP32 |
| M | Batch size (number of tokens) |
| N | Output dimension (number of rows in B) |
| K | Input dimension |
Definition at line 176 of file gemm_kernels_q4_0.c.
References C, CK_FP16_TO_FP32, block_q4_0::d, QK4_0, and block_q4_0::qs.
Referenced by ck_gemm_nt_quant().
| void gemm_nt_q4_1 | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
GEMM with transposed Q4_1 weights: C = A @ B^T.
| A | Input activations [M x K], row-major FP32 |
| B | Weight matrix in Q4_1 format [N x K], row-major quantized |
| bias | Optional bias [N], NULL if not used |
| C | Output [M x N], row-major FP32 |
| M | Batch size (number of tokens) |
| N | Output dimension |
| K | Input dimension |
Definition at line 256 of file gemm_kernels_q4_1.c.
References C, CK_FP16_TO_FP32, block_q4_1::d, block_q4_1::m, QK4_1, and block_q4_1::qs.
Referenced by ck_gemm_nt_quant().
| void gemm_nt_q4_k | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 708 of file gemm_kernels_q4k.c.
References C, and gemm_q4_k().
Referenced by ck_attention_project_head_major_q4_k(), ck_gemm_nt_quant(), ck_layer_forward_rmsnorm_swiglu_decode_q4_k(), ck_mlp_swiglu_forward_q4_k(), ck_qkv_project_head_major_q4_k(), ck_qkv_project_head_major_token_q4_k(), model_decode_token(), model_decode_token(), model_layer_0_decode(), model_layer_0_decode(), model_layer_0_prefill(), model_layer_0_prefill(), model_layer_0_prefill(), model_layer_0_prefill(), model_layer_10_decode(), model_layer_10_decode(), model_layer_10_prefill(), model_layer_10_prefill(), model_layer_10_prefill(), model_layer_10_prefill(), model_layer_11_decode(), model_layer_11_decode(), model_layer_11_prefill(), model_layer_11_prefill(), model_layer_11_prefill(), model_layer_11_prefill(), model_layer_12_decode(), model_layer_12_decode(), model_layer_12_prefill(), model_layer_12_prefill(), model_layer_12_prefill(), model_layer_12_prefill(), model_layer_13_decode(), model_layer_13_decode(), model_layer_13_prefill(), model_layer_13_prefill(), model_layer_13_prefill(), model_layer_13_prefill(), model_layer_14_decode(), model_layer_14_decode(), model_layer_14_prefill(), model_layer_14_prefill(), model_layer_14_prefill(), model_layer_14_prefill(), model_layer_15_decode(), model_layer_15_decode(), model_layer_15_prefill(), model_layer_15_prefill(), model_layer_15_prefill(), model_layer_15_prefill(), model_layer_16_decode(), model_layer_16_decode(), model_layer_16_prefill(), model_layer_16_prefill(), model_layer_16_prefill(), model_layer_16_prefill(), model_layer_17_decode(), model_layer_17_decode(), model_layer_17_prefill(), model_layer_17_prefill(), model_layer_17_prefill(), model_layer_17_prefill(), model_layer_18_decode(), model_layer_18_decode(), model_layer_18_prefill(), model_layer_18_prefill(), model_layer_18_prefill(), model_layer_18_prefill(), model_layer_19_decode(), model_layer_19_decode(), model_layer_19_prefill(), model_layer_19_prefill(), model_layer_19_prefill(), model_layer_19_prefill(), model_layer_1_decode(), model_layer_1_decode(), model_layer_1_prefill(), model_layer_1_prefill(), model_layer_1_prefill(), model_layer_1_prefill(), model_layer_20_decode(), model_layer_20_decode(), model_layer_20_prefill(), model_layer_20_prefill(), model_layer_20_prefill(), model_layer_20_prefill(), model_layer_21_decode(), model_layer_21_decode(), model_layer_21_prefill(), model_layer_21_prefill(), model_layer_21_prefill(), model_layer_21_prefill(), model_layer_22_decode(), model_layer_22_decode(), model_layer_22_prefill(), model_layer_22_prefill(), model_layer_22_prefill(), model_layer_22_prefill(), model_layer_23_decode(), model_layer_23_decode(), model_layer_23_prefill(), model_layer_23_prefill(), model_layer_23_prefill(), model_layer_23_prefill(), model_layer_2_decode(), model_layer_2_decode(), model_layer_2_prefill(), model_layer_2_prefill(), model_layer_2_prefill(), model_layer_2_prefill(), model_layer_3_decode(), model_layer_3_decode(), model_layer_3_prefill(), model_layer_3_prefill(), model_layer_3_prefill(), model_layer_3_prefill(), model_layer_4_decode(), model_layer_4_decode(), model_layer_4_prefill(), model_layer_4_prefill(), model_layer_4_prefill(), model_layer_4_prefill(), model_layer_5_decode(), model_layer_5_decode(), model_layer_5_prefill(), model_layer_5_prefill(), model_layer_5_prefill(), model_layer_5_prefill(), model_layer_6_decode(), model_layer_6_decode(), model_layer_6_prefill(), model_layer_6_prefill(), model_layer_6_prefill(), model_layer_6_prefill(), model_layer_7_decode(), model_layer_7_decode(), model_layer_7_prefill(), model_layer_7_prefill(), model_layer_7_prefill(), model_layer_7_prefill(), model_layer_8_decode(), model_layer_8_decode(), model_layer_8_prefill(), model_layer_8_prefill(), model_layer_8_prefill(), model_layer_8_prefill(), model_layer_9_decode(), model_layer_9_decode(), model_layer_9_prefill(), model_layer_9_prefill(), model_layer_9_prefill(), model_layer_9_prefill(), qwen2_0_5b_decode_decode_token(), qwen2_0_5b_decode_decode_token(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_9_decode(), qwen2_0_5b_decode_layer_9_decode(), qwen2_0_5b_decode_layer_9_prefill(), qwen2_0_5b_decode_layer_9_prefill(), qwen2_0_5b_decode_layer_9_prefill(), and qwen2_0_5b_decode_layer_9_prefill().
| void gemm_nt_q4_k_q8_k | ( | const void * | A_q8, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 397 of file gemm_kernels_q4k_q8k.c.
References C, and gemm_q4_k_q8_k().
Referenced by ck_attention_project_head_major_q4_k_q8_k(), ck_layer_forward_rmsnorm_swiglu_decode_q4_k(), ck_mlp_swiglu_forward_q4_k_q8_k(), ck_mlp_swiglu_forward_q4_k_q8_k_prefill(), ck_qkv_project_head_major_token_q4_k_q8_k(), gemm_nt_q8_k_mlp_dispatch(), gemm_nt_q8_k_qkv_dispatch(), model_forward_prefill_impl(), model_forward_prefill_impl(), model_forward_prefill_impl(), model_forward_prefill_impl(), qwen2_0_5b_decode_forward_prefill_impl(), qwen2_0_5b_decode_forward_prefill_impl(), qwen2_0_5b_decode_forward_prefill_impl(), and qwen2_0_5b_decode_forward_prefill_impl().
| void gemm_nt_q5_0 | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 833 of file gemm_kernels_q5_0.c.
References C, gemm_q5_0(), and gemv_q5_0().
Referenced by ck_gemm_nt_quant(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_8_decode(), and qwen2_0_5b_decode_layer_9_decode().
| void gemm_nt_q5_1 | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
GEMM with transposed Q5_1 weights: C = A @ B^T.
| A | Input activations [M x K], row-major FP32 |
| B | Weight matrix in Q5_1 format [N x K], row-major quantized |
| bias | Optional bias [N], NULL if not used |
| C | Output [M x N], row-major FP32 |
| M | Batch size (number of tokens) |
| N | Output dimension |
| K | Input dimension |
Definition at line 314 of file gemm_kernels_q5_1.c.
References C, CK_FP16_TO_FP32, block_q5_1::d, block_q5_1::m, block_q5_1::qh, QK5_1, and block_q5_1::qs.
Referenced by ck_gemm_nt_quant().
| void gemm_nt_q5_1_q8_1 | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 289 of file gemm_kernels_q5_1_q8_1.c.
References C, CK_Q51_STACK_Q8_BLOCKS, dot_q5_1_q8_1_block(), QK5_1, and quantize_row_q8_1_scalar().
Referenced by gemm_nt_q5_1_q8_1_m4().
| void gemm_nt_q5_1_q8_1_ref | ( | const void * | A_q8, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 242 of file gemm_kernels_q5_1_q8_1.c.
References C, dot_q5_1_q8_1_block(), and QK5_1.
| void gemm_nt_q5_k | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 1001 of file gemm_kernels_q5_k.c.
References C, and gemm_nt_q5_k_ref().
| void gemm_nt_q5_k_q8_k | ( | const void * | A_q8, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 914 of file gemm_kernels_q5_k.c.
References C, and gemm_nt_q5_k_q8_k_ref().
| void gemm_nt_q6_k | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 212 of file gemm_kernels_q6k.c.
References C, and gemm_q6_k().
Referenced by ck_gemm_nt_quant(), gemm_nt_q6_k_ref(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_8_decode(), and qwen2_0_5b_decode_layer_9_decode().
| void gemm_nt_q6_k_q8_k | ( | const void * | A_q8, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
NT GEMM: C = A @ B^T where A is Q8_K and B is Q6_K.
This is the typical inference pattern:
| A_q8 | Input activations in Q8_K format |
| B | Weight matrix in Q6_K format |
| bias | Optional bias vector [N] |
| C | Output matrix |
| M | Batch size (number of tokens) |
| N | Output dimension |
| K | Input dimension |
Definition at line 1515 of file gemm_kernels_q6k_q8k.c.
References C, ck_dot_q6_k_q8_k_fast_or_ref(), and QK_K.
Referenced by gemm_nt_q8_k_mlp_dispatch(), and gemm_nt_q8_k_qkv_dispatch().
| void gemm_nt_q6_k_q8_k_m4_tile | ( | const void * | A_q8, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K, | ||
| int | m0, | ||
| int | m1, | ||
| int | n0, | ||
| int | n1 | ||
| ) |
Definition at line 1702 of file gemm_kernels_q6k_q8k.c.
References C, ck_q6k_q8k_force_ref(), ck_strict_parity_enabled(), gemm_nt_q6_k_q8_k_tile(), and QK_K.
| void gemm_nt_q6_k_q8_k_tile | ( | const void * | A_q8, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K, | ||
| int | m0, | ||
| int | m1, | ||
| int | n0, | ||
| int | n1 | ||
| ) |
Compute one C[m0:m1, n0:n1] tile for Q8_K activations x Q6_K weights.
Pure tile math only: no threadpool, no global scheduling, no allocation. The orchestrator decides how to split tile jobs across cores.
Definition at line 1665 of file gemm_kernels_q6k_q8k.c.
References C, ck_dot_q6_k_q8_k_fast_or_ref(), and QK_K.
Referenced by gemm_nt_q6_k_q8_k_m4_tile(), and gemm_nt_q6_k_q8_k_tiled().
| void gemm_nt_q6_k_q8_k_tiled | ( | const void * | A_q8, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Experimental single-thread tiled NT GEMM wrapper.
Kept as a separate symbol from gemm_nt_q6_k_q8_k for benchmarks and parity. Production prefill should prefer the v8 2D tile scheduler when enabled.
Definition at line 1763 of file gemm_kernels_q6k_q8k.c.
References C, and gemm_nt_q6_k_q8_k_tile().
| void gemm_nt_q8_0 | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 879 of file gemm_kernels_q8_0.c.
References C, ck_q8_0_fp32_m4n4_enabled(), gemm_nt_q8_0_rowloop(), and QK8_0.
Referenced by ck_gemm_nt_quant(), qwen2_0_5b_decode_decode_token(), qwen2_0_5b_decode_forward_prefill_impl(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_8_decode(), and qwen2_0_5b_decode_layer_9_decode().
| void gemm_nt_q8_0_q8_0 | ( | const void * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
gemm_nt_q8_0_q8_0 with optional bias (matches header signature)
C[m,n] = A[m,K] @ B[n,K]^T + bias[n]
Definition at line 552 of file gemm_batch_int8.c.
References C, and gemm_nt_q8_0_q8_0_ref().
Referenced by gemm_nt_q8_0_dispatch(), and gemm_nt_q8_0_mlp_dispatch().
| void gemm_nt_q8_0_q8_0_contract | ( | const float * | A, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 414 of file gemm_kernels_q8_0_q8_0_contract.c.
References C, ck_q80_contract_cached_gemm_seq, ck_q80_contract_cached_input_enabled(), ck_q80_contract_dump_enabled(), ck_q80_contract_dump_tensor(), ck_strict_consume_next_gemm_a(), ck_strict_parity_enabled(), gemm_nt_q8_0_q8_0_ggml_strict(), and gemv_q8_0_q8_0_contract().
| void gemm_nt_q8_0_q8_0_m2n4 | ( | const void * | A_q8, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 586 of file gemm_batch_int8.c.
References C, and gemm_q8_0_q8_0_m2n4().
| void gemm_nt_q8_0_q8_0_m2n4_tile | ( | const void * | A_q8, |
| const void * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K, | ||
| int | ldc | ||
| ) |
Definition at line 603 of file gemm_batch_int8.c.
References C, and gemm_q8_0_q8_0_m2n4_strided().
| void gemm_q4_k | ( | float * | Y, |
| const void * | W, | ||
| const float * | X, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Auto-dispatch GEMM based on available SIMD.
Definition at line 486 of file gemm_kernels_q4k.c.
References gemm_q4_k_ref().
Referenced by gemm_nt_q4_k().
| void gemm_q4_k_q8_k | ( | float * | Y, |
| const void * | W, | ||
| const void * | X_q8, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 354 of file gemm_kernels_q4k_q8k.c.
References ck_threadpool_dispatch_n(), ck_threadpool_global(), ck_threadpool_n_threads(), gemm_q4_k_q8_k_thread_fn(), gemv_q4_k_q8_k(), and QK_K.
Referenced by gemm_nt_q4_k_q8_k().
| void gemm_q6_k | ( | float * | Y, |
| const void * | W, | ||
| const float * | X, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 195 of file gemm_kernels_q6k.c.
References gemv_q6_k().
Referenced by gemm_nt_q6_k().
| void gemm_q6_k_q8_k | ( | float * | Y, |
| const void * | W, | ||
| const void * | X_q8, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
GEMM: Y = W @ X^T where W is Q6_K and X is Q8_K.
| Y | Output matrix [N x M] in row-major |
| W | Weight matrix in Q6_K format [M x K] |
| X_q8 | Input matrix in Q8_K format [N x K] |
| M | Number of output rows (output dim) |
| N | Number of input vectors (batch size) |
| K | Input dimension |
Definition at line 1481 of file gemm_kernels_q6k_q8k.c.
References gemv_q6_k_q8_k(), and QK_K.
| void gemm_swiglu_fused | ( | const float * | x, |
| const float * | W_gate, | ||
| const float * | W_up, | ||
| const float * | b_gate, | ||
| const float * | b_up, | ||
| float * | output, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 241 of file gemm_fused_kernels.c.
Referenced by ck_mlp_swiglu_forward_fused_token().
| void gemm_tn_avx512 | ( | const float * | A, |
| const float * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 709 of file gemm_kernels.c.
References C, ck_strict_parity_enabled(), gemm_tn_parallel(), and gemm_tn_serial_double().
| void gemm_tn_blocked | ( | const float * | A, |
| const float * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 769 of file gemm_kernels.c.
References C, ck_min(), ck_strict_parity_enabled(), and gemm_tn_serial_double().
| void gemm_tn_parallel | ( | const float * | A, |
| const float * | B, | ||
| const float * | bias, | ||
| float * | C, | ||
| int | M, | ||
| int | N, | ||
| int | K | ||
| ) |
Definition at line 687 of file gemm_kernels.c.
References C, ck_strict_parity_enabled(), and gemm_tn_serial_double().
Referenced by fc1_backward_kernel(), fc2_backward_kernel(), and gemm_tn_avx512().
| void gemma4_final_logit_softcap_forward | ( | float * | logits, |
| int | tokens, | ||
| int | vocab_size, | ||
| float | cap | ||
| ) |
Definition at line 405 of file gemma4_per_layer_embed.c.
References vocab_size.
| void gemma4_per_layer_embed_forward | ( | float * | hidden, |
| const float * | per_layer_input, | ||
| const float * | inp_gate, | ||
| const float * | proj, | ||
| const float * | post_norm, | ||
| const float * | out_scale, | ||
| int | tokens, | ||
| int | layer, | ||
| int | num_layers, | ||
| int | embed_dim, | ||
| int | per_layer_dim, | ||
| float | eps | ||
| ) |
Definition at line 348 of file gemma4_per_layer_embed.c.
References ck_gemma4_embed_range(), ck_threadpool_global(), ck_threadpool_n_threads(), ck_threadpool_parallel_for_n(), and QK_K.
| void gemma4_per_layer_prepare_bf16_forward | ( | float * | per_layer_input, |
| const float * | hidden, | ||
| const int32_t * | token_ids, | ||
| const uint16_t * | per_layer_token_emb, | ||
| const uint16_t * | per_layer_model_proj, | ||
| const float * | per_layer_proj_norm, | ||
| int | tokens, | ||
| int | num_layers, | ||
| int | embed_dim, | ||
| int | per_layer_dim, | ||
| int | vocab_size, | ||
| float | eps | ||
| ) |
Definition at line 254 of file gemma4_per_layer_embed.c.
References ck_gemma4_prepare_bf16_range(), ck_gemma4_prepare_parallel(), QK_K, and vocab_size.
| void gemma4_per_layer_prepare_forward | ( | float * | per_layer_input, |
| const float * | hidden, | ||
| const int32_t * | token_ids, | ||
| const void * | per_layer_token_emb, | ||
| const uint16_t * | per_layer_model_proj, | ||
| const float * | per_layer_proj_norm, | ||
| int | tokens, | ||
| int | num_layers, | ||
| int | embed_dim, | ||
| int | per_layer_dim, | ||
| int | vocab_size, | ||
| float | eps | ||
| ) |
Definition at line 218 of file gemma4_per_layer_embed.c.
References ck_gemma4_prepare_parallel(), ck_gemma4_prepare_q5_range(), QK_K, and vocab_size.
| void gemma4_v_norm_forward | ( | const float * | input, |
| float * | output, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | num_kv_heads, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
Definition at line 687 of file rmsnorm_kernels.c.
References rmsnorm_forward_no_weight().
| void gemma4_v_norm_forward_parallel_dispatch | ( | const float * | input, |
| float * | output, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | num_kv_heads, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
| void gemma4_vision_projector_prep_forward | ( | const float * | input, |
| float * | output, | ||
| int | tokens, | ||
| int | dim, | ||
| float | scale, | ||
| float | eps | ||
| ) |
Definition at line 633 of file vision_kernels.c.
| void gemv_bf16 | ( | float * | y, |
| const void * | W, | ||
| const float * | x, | ||
| int | M, | ||
| int | K | ||
| ) |
Definition at line 622 of file gemm_kernels_bf16.c.
References gemv_bf16_row_range().
Referenced by gemv_bf16_parallel_dispatch().
| void gemv_bf16_bf16_storage | ( | float * | y, |
| const void * | W, | ||
| const float * | x, | ||
| int | M, | ||
| int | K | ||
| ) |
Definition at line 712 of file gemm_kernels_bf16.c.
References gemv_bf16_bf16_storage_parallel_dispatch().
| void gemv_bf16_bf16_storage_parallel_dispatch | ( | float * | y, |
| const void * | W, | ||
| const float * | x, | ||
| int | M, | ||
| int | K | ||
| ) |
Definition at line 688 of file gemm_kernels_bf16.c.
References ck_gemv_bf16_storage_rows(), ck_threadpool_global(), ck_threadpool_n_threads(), ck_threadpool_parallel_for_n(), and gemv_bf16_bf16_storage_row_range().
Referenced by gemv_bf16_bf16_storage().
| void gemv_bf16_parallel_dispatch | ( | float * | y, |
| const void * | W, | ||
| const float * | x, | ||
| int | M, | ||
| int | K | ||
| ) |
Definition at line 646 of file gemm_kernels_bf16.c.
References ck_gemv_bf16_rows(), ck_threadpool_global(), ck_threadpool_n_threads(), ck_threadpool_parallel_for_n(), and gemv_bf16().
| void gemv_fused_q5_0_bias_dispatch | ( | float * | y, |
| const void * | W, | ||
| const float * | x, | ||
| const float * | bias, | ||
| int | M, | ||
| int | K | ||
| ) |
Definition at line 510 of file gemv_fused_quant_bias.c.
References gemv_fused_q5_0_bias().
| void gemv_fused_q8_0_bias_dispatch | ( | float * | y, |
| const void * | W, | ||
| const float * | x, | ||
| const float * | bias, | ||
| int | M, | ||
| int | K | ||
| ) |
Definition at line 525 of file gemv_fused_quant_bias.c.
References gemv_fused_q8_0_bias().
| void gemv_q4_0 | ( | float * | y, |
| const void * | W, | ||
| const float * | x, | ||
| int | M, | ||
| int | K | ||
| ) |
Auto-dispatch GEMV.
Definition at line 132 of file gemm_kernels_q4_0.c.
References gemv_q4_0_ref().
Referenced by dot_q4_0(), and gemm_q4_0().
| void gemv_q4_k | ( | float * | y, |
| const void * | W, | ||
| const float * | x, | ||
| int | M, | ||
| int | K | ||
| ) |
Auto-dispatch GEMV based on available SIMD.
Definition at line 301 of file gemm_kernels_q4k.c.
References ck_q4k_debug_q8_contract(), CK_Q4K_STACK_Q8_BLOCKS, gemv_q4_k_q8_k(), gemv_q4_k_ref(), QK_K, and quantize_row_q8_k().
Referenced by attention_mlp_fused_q4k(), dot_q4_k(), gemm_q4_k_ref(), layer_fused_attn_mlp_qkv_q4k(), and rmsnorm_qkv_q4k_fused().
| void gemv_q4_k_q8_k | ( | float * | y, |
| const void * | W, | ||
| const void * | x_q8, | ||
| int | M, | ||
| int | K | ||
| ) |
Definition at line 273 of file gemm_kernels_q4k_q8k.c.
References ck_q4k_q8k_force_ref(), gemv_q4_k_q8_k_avx(), gemv_q4_k_q8_k_avx2(), gemv_q4_k_q8_k_ref(), gemv_q4_k_q8_k_sse(), and gemv_q4_k_q8_k_vnni().
Referenced by ck_moe_q4k_llama_projection(), ck_moe_q4k_mixed_route_work(), ck_moe_q4k_q5k_route_work(), gemm_q4_k_q8_k_compact_rows4(), model_decode_token(), model_decode_token(), model_layer_0_decode(), model_layer_0_decode(), model_layer_10_decode(), model_layer_10_decode(), model_layer_11_decode(), model_layer_11_decode(), model_layer_12_decode(), model_layer_12_decode(), model_layer_13_decode(), model_layer_13_decode(), model_layer_14_decode(), model_layer_14_decode(), model_layer_15_decode(), model_layer_15_decode(), model_layer_16_decode(), model_layer_16_decode(), model_layer_17_decode(), model_layer_17_decode(), model_layer_18_decode(), model_layer_18_decode(), model_layer_19_decode(), model_layer_19_decode(), model_layer_1_decode(), model_layer_1_decode(), model_layer_20_decode(), model_layer_20_decode(), model_layer_21_decode(), model_layer_21_decode(), model_layer_22_decode(), model_layer_22_decode(), model_layer_23_decode(), model_layer_23_decode(), model_layer_2_decode(), model_layer_2_decode(), model_layer_3_decode(), model_layer_3_decode(), model_layer_4_decode(), model_layer_4_decode(), model_layer_5_decode(), model_layer_5_decode(), model_layer_6_decode(), model_layer_6_decode(), model_layer_7_decode(), model_layer_7_decode(), model_layer_8_decode(), model_layer_8_decode(), model_layer_9_decode(), model_layer_9_decode(), moe_swiglu_expert_forward_q4k_q4k_workspace(), moe_swiglu_expert_forward_q4k_q5k_workspace(), moe_swiglu_expert_forward_q4k_q6k_workspace(), moe_swiglu_shared_forward_q4k_q4k_workspace(), moe_swiglu_shared_forward_q4k_q6k_workspace(), qwen2_0_5b_decode_decode_token(), qwen2_0_5b_decode_decode_token(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_9_decode(), and qwen2_0_5b_decode_layer_9_decode().
| void gemv_q4_k_q8_k_parallel | ( | float * | y, |
| const void * | W, | ||
| const void * | x_q8, | ||
| int | M, | ||
| int | K, | ||
| int | ith, | ||
| int | nth | ||
| ) |
Definition at line 240 of file gemm_kernels_q4k_q8k.c.
References dot_q4_k_q8_k_ref(), and QK_K.
| void gemv_q4_k_q8_k_parallel_simd | ( | float * | y, |
| const void * | W, | ||
| const void * | x_q8, | ||
| int | M, | ||
| int | K, | ||
| int | ith, | ||
| int | nth | ||
| ) |
Definition at line 263 of file gemm_kernels_q4k_avx.c.
References gemv_q4_k_q8_k_parallel().
Referenced by decode_layer_parallel(), mlp_parallel(), and qkv_projection_parallel().
| void gemv_q4_k_q8_k_ref | ( | float * | y, |
| const void * | W, | ||
| const void * | x_q8, | ||
| int | M, | ||
| int | K | ||
| ) |
Definition at line 201 of file gemm_kernels_q4k_q8k.c.
References dot_q4_k_q8_k_ref(), and QK_K.
| void gemv_q5_0 | ( | float * | y, |
| const void * | W, | ||
| const float * | x, | ||
| int | M, | ||
| int | K | ||
| ) |
Auto-dispatch GEMV for Q5_0 weights based on CPU features.
Dispatch priority (best available):
Uses ck_features.h for standardized feature detection.
| y | Output vector [M] |
| W | Weight matrix in Q5_0 format [M x K] |
| x | Input vector [K] |
| M | Number of output rows |
| K | Number of input columns (hidden dimension) |
Definition at line 550 of file gemm_kernels_q5_0.c.
References gemv_q5_0_ref().
| void gemv_q5_0_parallel | ( | float * | y, |
| const void * | W, | ||
| const float * | x, | ||
| int | M, | ||
| int | K, | ||
| int | ith, | ||
| int | nth | ||
| ) |
Parallel reference GEMV for Q5_0 × FP32.
Definition at line 579 of file gemm_kernels_q5_0.c.
References CK_FP16_TO_FP32, block_q5_0::d, block_q5_0::qh, QK5_0, and block_q5_0::qs.
Referenced by gemv_q5_0_parallel_simd().
| void gemv_q5_0_parallel_simd | ( | float * | y, |
| const void * | W, | ||
| const float * | x, | ||
| int | M, | ||
| int | K, | ||
| int | ith, | ||
| int | nth | ||
| ) |
Parallel SIMD GEMV for Q5_0 × FP32 with prefetching.
Definition at line 625 of file gemm_kernels_q5_0.c.
References gemv_q5_0_parallel(), gemv_q5_0_ref(), and QK5_0.
| void gemv_q5_0_q8_0 | ( | float * | y, |
| const void * | W, | ||
| const void * | x_q8, | ||
| int | M, | ||
| int | K | ||
| ) |
Matrix-vector multiply with Q5_0 weights and Q8_0 input.
| y | Output vector [M] |
| W | Weight matrix in Q5_0 format [M x K] |
| x_q8 | Input vector in Q8_0 format [K] |
| M | Number of output rows |
| K | Number of columns (must be multiple of 32) |
Definition at line 1640 of file gemm_kernels_q5_0.c.
References QK5_0, and vec_dot_q5_0_q8_0().
Referenced by ck_moe_q4k_mixed_route_work(), moe_swiglu_expert_forward_q4k_q5_0_workspace(), and moe_swiglu_shared_forward_q4k_q5_0_gated_workspace().
| void gemv_q5_1 | ( | float * | y, |
| const void * | W, | ||
| const float * | x, | ||
| int | M, | ||
| int | K | ||
| ) |
Auto-dispatch GEMV.
Definition at line 187 of file gemm_kernels_q5_1.c.
References gemv_q5_1_ref().
Referenced by dot_q5_1(), and gemm_q5_1().
| void gemv_q5_1_q8_1 | ( | float * | y, |
| const void * | W, | ||
| const float * | x, | ||
| int | M, | ||
| int | K | ||
| ) |
Definition at line 269 of file gemm_kernels_q5_1_q8_1.c.
References CK_Q51_STACK_Q8_BLOCKS, gemv_q5_1_q8_1_ref(), QK5_1, and quantize_row_q8_1_scalar().
| void gemv_q5_1_q8_1_ref | ( | float * | y, |
| const void * | W, | ||
| const void * | x_q8, | ||
| int | M, | ||
| int | K | ||
| ) |
Definition at line 219 of file gemm_kernels_q5_1_q8_1.c.
References dot_q5_1_q8_1_block(), and QK5_1.
Referenced by gemv_q5_1_q8_1().
| void gemv_q5_k | ( | float * | y, |
| const void * | W, | ||
| const float * | x, | ||
| int | M, | ||
| int | K | ||
| ) |
Definition at line 982 of file gemm_kernels_q5_k.c.
References gemv_q5_k_ref().
| void gemv_q5_k_q8_k | ( | float * | y, |
| const void * | W, | ||
| const void * | x_q8, | ||
| int | M, | ||
| int | K | ||
| ) |
Definition at line 892 of file gemm_kernels_q5_k.c.
References gemv_q5_k_q8_k_ref().
Referenced by ck_moe_q4k_q5k_route_work(), gemm_q5_k_q8_k_compact_rows4(), and moe_swiglu_expert_forward_q4k_q5k_workspace().
| void gemv_q6_k | ( | float * | y, |
| const void * | W, | ||
| const float * | x, | ||
| int | M, | ||
| int | K | ||
| ) |
Definition at line 169 of file gemm_kernels_q6k.c.
References dot_q6_k_ref(), and QK_K.
Referenced by gemm_q6_k().
| void gemv_q6_k_q8_k | ( | float * | y, |
| const void * | W, | ||
| const void * | x_q8, | ||
| int | M, | ||
| int | K | ||
| ) |
GEMV: y = W @ x where W is Q6_K and x is Q8_K.
Definition at line 1341 of file gemm_kernels_q6k_q8k.c.
References ck_q6k_q8k_force_ref(), ck_strict_parity_enabled(), gemv_q6_k_q8_k_avx(), gemv_q6_k_q8_k_avx2(), gemv_q6_k_q8_k_ref(), and gemv_q6_k_q8_k_sse().
Referenced by ck_moe_q4k_mixed_route_work(), moe_swiglu_expert_forward_q4k_q6k_workspace(), and moe_swiglu_shared_forward_q4k_q6k_workspace().
| void gemv_q6_k_q8_k_parallel | ( | float * | y, |
| const void * | W, | ||
| const void * | x_q8, | ||
| int | M, | ||
| int | K, | ||
| int | ith, | ||
| int | nth | ||
| ) |
Parallel reference GEMV for Q6_K × Q8_K.
Caller provides ith (thread index) and nth (total threads). Each thread processes rows [r0, r1).
Definition at line 1398 of file gemm_kernels_q6k_q8k.c.
References dot_q6_k_q8_k_ref(), and QK_K.
| void gemv_q6_k_q8_k_parallel_simd | ( | float * | y, |
| const void * | W, | ||
| const void * | x_q8, | ||
| int | M, | ||
| int | K, | ||
| int | ith, | ||
| int | nth | ||
| ) |
Parallel SIMD GEMV for Q6_K × Q8_K.
Uses best available SIMD (AVX/SSE) with row prefetching. Caller provides ith/nth from OpenMP region.
Definition at line 1430 of file gemm_kernels_q6k_q8k.c.
References ck_q6k_q8k_force_ref(), ck_strict_parity_enabled(), dot_q6_k_q8_k_ref(), and QK_K.
| void gemv_q8_0 | ( | float * | y, |
| const void * | W, | ||
| const float * | x, | ||
| int | M, | ||
| int | K | ||
| ) |
Auto-dispatch GEMV for Q8_0 weights based on CPU features.
Dispatch priority (best available):
Uses ck_features.h for standardized feature detection.
| y | Output vector [M] |
| W | Weight matrix in Q8_0 format [M x K] |
| x | Input vector [K] |
| M | Number of output rows |
| K | Number of input columns (hidden dimension) |
Definition at line 694 of file gemm_kernels_q8_0.c.
References ck_q8_0_debug_ref(), and gemv_q8_0_ref().
Referenced by gemv_q8_0_q8_0_contract().
| void gemv_q8_0_q8_0 | ( | float * | y, |
| const void * | W, | ||
| const void * | x_q8, | ||
| int | M, | ||
| int | K | ||
| ) |
Matrix-vector multiply with Q8_0 weights and Q8_0 input.
| y | Output vector [M] |
| W | Weight matrix in Q8_0 format [M x K] |
| x_q8 | Input vector in Q8_0 format [K] |
| M | Number of output rows |
| K | Number of columns (must be multiple of 32) |
Definition at line 1405 of file gemm_kernels_q8_0.c.
References QK8_0, and vec_dot_q8_0_q8_0().
Referenced by ck_moe_q4k_mixed_route_work(), moe_swiglu_expert_forward_q4k_q8_0_workspace(), moe_swiglu_shared_forward_q4k_q8_0_gated_workspace(), and moe_swiglu_shared_forward_q8_0_gated_workspace().
| void gemv_q8_0_q8_0_contract | ( | float * | y, |
| const void * | W, | ||
| const float * | x, | ||
| int | M, | ||
| int | K | ||
| ) |
Definition at line 383 of file gemm_kernels_q8_0_q8_0_contract.c.
References CK_Q80_STACK_Q8_BLOCKS, ck_strict_parity_enabled(), gemv_q8_0(), gemv_q8_0_q8_0_ref_rows(), gemv_q8_0_q8_0_x4(), QK8_0, quantize_row_q8_0(), and quantize_row_q8_0_ref_local().
Referenced by gemm_nt_q8_0_q8_0_contract().
| void gemv_q8_0_q8_0_x4 | ( | float * | y, |
| const void * | W, | ||
| const void * | x_q8, | ||
| int | M, | ||
| int | K | ||
| ) |
Definition at line 1428 of file gemm_kernels_q8_0.c.
References CK_FP16_TO_FP32, ck_q8_0_q8_0_debug_ref(), gemv_q8_0_q8_0(), and QK8_0.
Referenced by gemv_q8_0_q8_0_contract().
| void gradient_accumulate_f32 | ( | float * | dst, |
| const float * | src, | ||
| size_t | numel | ||
| ) |
Definition at line 925 of file optimizer_kernels.c.
References ck_accum_parallel_work(), CK_OPT_PAR_MAX_THREADS, CK_OPT_PAR_MIN_NUMEL, ck_opt_pick_active_threads(), ck_threadpool_dispatch_n(), ck_threadpool_global(), ck_threadpool_n_threads(), and gradient_accumulate_f32_impl().
| void gradient_accumulate_multi_f32 | ( | float *const * | dsts, |
| const float *const * | srcs, | ||
| const size_t * | numels, | ||
| int | tensor_count | ||
| ) |
Definition at line 951 of file optimizer_kernels.c.
References ck_accum_multi_parallel_work(), CK_OPT_PAR_MAX_THREADS, CK_OPT_PAR_MIN_NUMEL, ck_opt_pick_active_threads(), ck_threadpool_dispatch_n(), ck_threadpool_global(), ck_threadpool_n_threads(), and gradient_accumulate_f32_impl().
| float gradient_clip_norm_f32 | ( | float * | grad, |
| size_t | numel, | ||
| float | max_norm | ||
| ) |
Clip gradient norm (fp32)
If ||grad||_2 > max_norm, scale grad so that ||grad||_2 = max_norm
| grad | Gradient tensor to clip (in-place) [numel] |
| numel | Number of elements |
| max_norm | Maximum allowed L2 norm |
Definition at line 1169 of file optimizer_kernels.c.
References CK_OPT_PAR_MAX_THREADS, CK_OPT_PAR_MIN_NUMEL, ck_opt_pick_active_threads(), ck_sum_sq_parallel_work(), ck_threadpool_dispatch_n(), ck_threadpool_global(), ck_threadpool_n_threads(), gradient_scale_f32(), and gradient_sum_sq_f32_impl().
| float gradient_global_norm_multi_f32 | ( | const float *const * | grads, |
| const size_t * | numels, | ||
| int | tensor_count | ||
| ) |
Definition at line 1207 of file optimizer_kernels.c.
References CK_OPT_PAR_MAX_THREADS, CK_OPT_PAR_MIN_NUMEL, ck_opt_pick_active_threads(), ck_sum_sq_multi_parallel_work(), ck_threadpool_dispatch_n(), ck_threadpool_global(), ck_threadpool_n_threads(), and gradient_sum_sq_f32_impl().
Referenced by adamw_clip_update_multi_f32().
| void gradient_scale_f32 | ( | float * | grad, |
| size_t | numel, | ||
| float | scale | ||
| ) |
Definition at line 1073 of file optimizer_kernels.c.
References CK_OPT_PAR_MAX_THREADS, CK_OPT_PAR_MIN_NUMEL, ck_opt_pick_active_threads(), ck_scale_parallel_work(), ck_threadpool_dispatch_n(), ck_threadpool_global(), ck_threadpool_n_threads(), and gradient_scale_f32_impl().
| void group_limited_topk_router_sigmoid_f32 | ( | const float * | logits, |
| const float * | correction_bias, | ||
| int * | indices, | ||
| float * | weights, | ||
| int | rows, | ||
| int | n_experts, | ||
| int | top_k, | ||
| int | n_group, | ||
| int | topk_group, | ||
| int | norm_topk_prob, | ||
| float | routed_scaling_factor | ||
| ) |
Definition at line 798 of file topk_kernels.c.
References group_limited_topk_router_f32_impl().
| void hyper_connection_mix_bf16 | ( | const float * | hyper_input, |
| const float * | norm_weight, | ||
| const uint16_t * | mix_down_weight, | ||
| const uint16_t * | mix_up_weight, | ||
| const uint16_t * | inject_weight, | ||
| float * | mixed_output, | ||
| float * | injection_output, | ||
| float * | normalized_scratch, | ||
| float * | dynamic_scratch, | ||
| float * | mix_scratch, | ||
| int | rows, | ||
| int | streams, | ||
| int | hidden_dim, | ||
| int | dynamic_dim, | ||
| float | eps, | ||
| int | emit_injection | ||
| ) |
Definition at line 71 of file hyper_connection_kernels.c.
References bf16_to_float(), ck_bf16_round(), ck_sigmoid_bf16(), and rmsnorm_forward_qwen3next_pytorch_bf16_storage().
| void hyper_connection_mix_q4k_q5_0_q4k | ( | const float * | hyper_input, |
| const float * | norm_weight, | ||
| const void * | mix_down_weight, | ||
| const void * | mix_up_weight, | ||
| const void * | inject_weight, | ||
| float * | mixed_output, | ||
| float * | injection_output, | ||
| float * | normalized_scratch, | ||
| float * | dynamic_scratch, | ||
| float * | mix_scratch, | ||
| int | rows, | ||
| int | streams, | ||
| int | hidden_dim, | ||
| int | dynamic_dim, | ||
| float | eps, | ||
| int | emit_injection | ||
| ) |
Definition at line 344 of file hyper_connection_kernels.c.
References gemm_nt_q4_k_q8_k_pairwise_split_min_parallel_dispatch(), hyper_connection_mix_quantized(), and hyper_injection_q4k_q8k_llama_dispatch().
| void hyper_connection_mix_q6k_q5_0_q4k | ( | const float * | hyper_input, |
| const float * | norm_weight, | ||
| const void * | mix_down_weight, | ||
| const void * | mix_up_weight, | ||
| const void * | inject_weight, | ||
| float * | mixed_output, | ||
| float * | injection_output, | ||
| float * | normalized_scratch, | ||
| float * | dynamic_scratch, | ||
| float * | mix_scratch, | ||
| int | rows, | ||
| int | streams, | ||
| int | hidden_dim, | ||
| int | dynamic_dim, | ||
| float | eps, | ||
| int | emit_injection | ||
| ) |
Definition at line 368 of file hyper_connection_kernels.c.
References gemm_nt_q6_k_q8_k_parallel_dispatch(), hyper_connection_mix_quantized(), and hyper_injection_q4k_q8k_llama_dispatch().
| void hyper_stream_expand_bf16 | ( | const float * | input, |
| float * | output, | ||
| int | rows, | ||
| int | streams, | ||
| int | hidden_dim | ||
| ) |
Definition at line 51 of file hyper_connection_kernels.c.
References ck_bf16_round().
| void hyper_stream_expand_f32 | ( | const float * | input, |
| float * | output, | ||
| int | rows, | ||
| int | streams, | ||
| int | hidden_dim | ||
| ) |
Definition at line 32 of file hyper_connection_kernels.c.
| void hyper_stream_inject_bf16 | ( | const float * | hyper_input, |
| const float * | block_output, | ||
| const float * | injection_weight, | ||
| float * | output, | ||
| int | rows, | ||
| int | streams, | ||
| int | hidden_dim | ||
| ) |
Definition at line 392 of file hyper_connection_kernels.c.
References ck_bf16_round().
| void hyper_stream_inject_f32 | ( | const float * | hyper_input, |
| const float * | block_output, | ||
| const float * | injection_weight, | ||
| float * | output, | ||
| int | rows, | ||
| int | streams, | ||
| int | hidden_dim | ||
| ) |
Definition at line 423 of file hyper_connection_kernels.c.
| void im2patch | ( | const float * | image, |
| float * | patches, | ||
| int | C, | ||
| int | H, | ||
| int | W, | ||
| int | P | ||
| ) |
im2patch: Transforms an image into a sequence of flattened patches.
Image Layout: [C, H, W] (Row-major: W is fastest moving) Output Layout: [num_patches, C * P * P]
num_patches = (H/P) * (W/P) P = patch_size
Definition at line 82 of file vision_kernels.c.
References C.
| void im2patch_bf16 | ( | const uint16_t * | image, |
| uint16_t * | patches, | ||
| int | C, | ||
| int | H, | ||
| int | W, | ||
| int | P | ||
| ) |
Definition at line 22 of file vision_kernels_bf16.c.
References C.
| void kv_cache_repack_head_major_inplace | ( | float * | buf, |
| int | num_heads, | ||
| int | tokens, | ||
| int | cache_capacity, | ||
| int | aligned_head_dim | ||
| ) |
Definition at line 49 of file kv_cache_kernels.c.
Referenced by qwen2_0_5b_decode_forward_prefill_impl(), qwen2_0_5b_decode_forward_prefill_impl(), and qwen2_0_5b_decode_forward_prefill_impl().
| void kv_cache_store | ( | float *__restrict | kv_cache_k, |
| float *__restrict | kv_cache_v, | ||
| const float *__restrict | k, | ||
| const float *__restrict | v, | ||
| int | layer, | ||
| int | pos, | ||
| int | num_kv_heads, | ||
| int | head_dim, | ||
| int | max_seq_len | ||
| ) |
Definition at line 122 of file kv_cache_kernels.c.
References kv_cache_write_head_major().
| void kv_cache_store_batch_bf16 | ( | uint16_t *__restrict | kv_cache_k, |
| uint16_t *__restrict | kv_cache_v, | ||
| const float *__restrict | k, | ||
| const float *__restrict | v, | ||
| int | start_pos, | ||
| int | num_tokens, | ||
| int | num_kv_heads, | ||
| int | head_dim, | ||
| int | max_seq_len | ||
| ) |
Definition at line 291 of file kv_cache_kernels.c.
References ck_local_fp32_to_bf16_row().
| void kv_cache_store_batch_f16 | ( | uint16_t *__restrict | kv_cache_k, |
| uint16_t *__restrict | kv_cache_v, | ||
| const float *__restrict | k, | ||
| const float *__restrict | v, | ||
| int | start_pos, | ||
| int | num_tokens, | ||
| int | num_kv_heads, | ||
| int | head_dim, | ||
| int | max_seq_len | ||
| ) |
Definition at line 255 of file kv_cache_kernels.c.
References ck_local_fp32_to_fp16_row().
| void kv_cache_store_batch_f32 | ( | float *__restrict | kv_cache_k, |
| float *__restrict | kv_cache_v, | ||
| const float *__restrict | k, | ||
| const float *__restrict | v, | ||
| int | start_pos, | ||
| int | num_tokens, | ||
| int | num_kv_heads, | ||
| int | head_dim, | ||
| int | max_seq_len | ||
| ) |
Definition at line 223 of file kv_cache_kernels.c.
| void kv_cache_store_bf16 | ( | uint16_t *__restrict | kv_cache_k, |
| uint16_t *__restrict | kv_cache_v, | ||
| const float *__restrict | k, | ||
| const float *__restrict | v, | ||
| int | layer, | ||
| int | pos, | ||
| int | num_kv_heads, | ||
| int | head_dim, | ||
| int | max_seq_len | ||
| ) |
Definition at line 195 of file kv_cache_kernels.c.
References ck_local_fp32_to_bf16_row().
| void kv_cache_store_f16 | ( | uint16_t *__restrict | kv_cache_k, |
| uint16_t *__restrict | kv_cache_v, | ||
| const float *__restrict | k, | ||
| const float *__restrict | v, | ||
| int | layer, | ||
| int | pos, | ||
| int | num_kv_heads, | ||
| int | head_dim, | ||
| int | max_seq_len | ||
| ) |
Definition at line 161 of file kv_cache_kernels.c.
References ck_local_fp32_to_fp16_row().
| void kv_cache_store_shared_q | ( | float *__restrict | kv_cache_k, |
| float *__restrict | kv_cache_v, | ||
| const float *__restrict | q, | ||
| int | layer, | ||
| int | pos, | ||
| int | num_heads, | ||
| int | head_dim, | ||
| int | max_seq_len | ||
| ) |
Definition at line 142 of file kv_cache_kernels.c.
References kv_cache_write_head_major().
| void kv_cache_write_head_major | ( | const float *__restrict | k_token, |
| const float *__restrict | v_token, | ||
| float *__restrict | k_cache, | ||
| float *__restrict | v_cache, | ||
| int | num_kv_heads, | ||
| int | token_index, | ||
| int | cache_capacity, | ||
| int | head_dim, | ||
| int | aligned_head_dim | ||
| ) |
Definition at line 81 of file kv_cache_kernels.c.
Referenced by ck_layer_forward_rmsnorm_swiglu_decode(), ck_layer_forward_rmsnorm_swiglu_decode_fused(), ck_layer_forward_rmsnorm_swiglu_decode_fused_attn_impl(), ck_layer_forward_rmsnorm_swiglu_decode_q4_k(), ck_layer_forward_rmsnorm_swiglu_decode_quant(), kv_cache_store(), kv_cache_store_shared_q(), mega_fused_attention_decode_workspace(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_9_decode(), qwen2_0_5b_decode_layer_9_decode(), and qwen2_0_5b_decode_layer_9_decode().
| void layernorm_backward_kernel | ( | const float * | d_output, |
| const float * | input, | ||
| const float * | gamma, | ||
| const float * | mean, | ||
| const float * | rstd, | ||
| float * | d_input, | ||
| float * | d_gamma, | ||
| float * | d_beta, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim | ||
| ) |
Definition at line 1007 of file layernorm_kernels.c.
Referenced by layernorm_backward_kernel_bf16().
| void layernorm_backward_kernel_bf16 | ( | const uint16_t * | d_output, |
| const uint16_t * | input, | ||
| const float * | gamma, | ||
| const float * | mean, | ||
| const float * | rstd, | ||
| uint16_t * | d_input, | ||
| float * | d_gamma, | ||
| float * | d_beta, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim, | ||
| float * | scratch_d_output, | ||
| float * | scratch_input, | ||
| float * | scratch_d_input | ||
| ) |
Definition at line 84 of file layernorm_kernels_bf16.c.
References bf16_tensor_to_float(), float_tensor_to_bf16(), and layernorm_backward_kernel().
| void layernorm_forward_rolled_slice | ( | const float *__restrict | input_slice_base, |
| const float *__restrict | gamma, | ||
| const float *__restrict | beta, | ||
| float *__restrict | output_slice_base, | ||
| float *__restrict | mean_cache_slice, | ||
| float *__restrict | rstd_cache_slice, | ||
| int | num_tokens_in_slice, | ||
| int | d_model, | ||
| int | aligned_embed_dim, | ||
| float | eps | ||
| ) |
Definition at line 398 of file layernorm_kernels.c.
References ck_strict_parity_enabled(), layernorm_forward_ggml_exact(), and layernorm_naive_serial().
Referenced by layernorm_forward_rolled_slice_bf16().
| void layernorm_forward_rolled_slice_bf16 | ( | const uint16_t *__restrict | input_slice_base, |
| const float *__restrict | gamma, | ||
| const float *__restrict | beta, | ||
| uint16_t *__restrict | output_slice_base, | ||
| float *__restrict | mean_cache_slice, | ||
| float *__restrict | rstd_cache_slice, | ||
| int | num_tokens_in_slice, | ||
| int | d_model, | ||
| int | aligned_embed_dim, | ||
| float | eps, | ||
| float * | scratch_input, | ||
| float * | scratch_output | ||
| ) |
Definition at line 30 of file layernorm_kernels_bf16.c.
References bf16_tensor_to_float(), float_tensor_to_bf16(), and layernorm_forward_rolled_slice().
| void layernorm_forward_unrolled_slice | ( | const float *__restrict | input_slice_base, |
| const float *__restrict | gamma, | ||
| const float *__restrict | beta, | ||
| float *__restrict | output_slice_base, | ||
| float *__restrict | mean_cache_slice, | ||
| float *__restrict | rstd_cache_slice, | ||
| int | num_tokens_in_slice, | ||
| int | d_model, | ||
| float | eps | ||
| ) |
Definition at line 730 of file layernorm_kernels.c.
References ck_strict_parity_enabled(), layernorm_forward_ggml_exact(), and layernorm_forward_unrolled_slice_scalar().
Referenced by layernorm_forward_unrolled_slice_bf16().
| void layernorm_forward_unrolled_slice_bf16 | ( | const uint16_t *__restrict | input_slice_base, |
| const float *__restrict | gamma, | ||
| const float *__restrict | beta, | ||
| uint16_t *__restrict | output_slice_base, | ||
| float *__restrict | mean_cache_slice, | ||
| float *__restrict | rstd_cache_slice, | ||
| int | num_tokens_in_slice, | ||
| int | d_model, | ||
| float | eps, | ||
| float * | scratch_input, | ||
| float * | scratch_output | ||
| ) |
Definition at line 57 of file layernorm_kernels_bf16.c.
References bf16_tensor_to_float(), float_tensor_to_bf16(), and layernorm_forward_unrolled_slice().
| void layernorm_naive_serial | ( | const float * | input, |
| const float * | gamma, | ||
| const float * | beta, | ||
| float * | output, | ||
| float * | mean_cache, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim, | ||
| float | eps | ||
| ) |
Definition at line 175 of file layernorm_kernels.c.
Referenced by layernorm_forward_rolled_slice().
| void layernorm_naive_serial_bf16_storage | ( | const float * | input, |
| const float * | gamma, | ||
| const float * | beta, | ||
| float * | output, | ||
| float * | mean_cache, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | d_model, | ||
| float | eps | ||
| ) |
Definition at line 786 of file layernorm_kernels.c.
References bf16_to_float(), float_to_bf16(), and layernorm_forward_ggml_exact().
| void layernorm_naive_serial_matched_precision | ( | const float * | input, |
| const float * | gamma, | ||
| const float * | beta, | ||
| float * | output, | ||
| float * | mean_cache, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | d_model, | ||
| float | eps | ||
| ) |
Definition at line 764 of file layernorm_kernels.c.
References layernorm_forward_ggml_exact().
Referenced by layernorm_forward_unrolled_slice_scalar().
| void layernorm_pytorch_welford_bf16_storage | ( | const float * | input, |
| const float * | gamma, | ||
| const float * | beta, | ||
| float * | output, | ||
| float * | mean_cache, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | d_model, | ||
| float | eps | ||
| ) |
Definition at line 952 of file layernorm_kernels.c.
References bf16_to_float(), and float_to_bf16().
| void mamba2_conv1d_decode_f32 | ( | const float * | state_in, |
| const float * | x, | ||
| const float * | weight, | ||
| const float * | bias, | ||
| float * | conv_out, | ||
| float * | state_out, | ||
| int | rows, | ||
| int | conv_dim, | ||
| int | kernel_size | ||
| ) |
Definition at line 148 of file mamba2_kernels.c.
References ck_mamba_debug_finite(), and mamba2_conv1d_f32_channel_range().
| void mamba2_conv1d_f32_channel_range | ( | const float * | state_in, |
| const float * | x, | ||
| const float * | weight, | ||
| const float * | bias, | ||
| float * | conv_out, | ||
| float * | state_out, | ||
| int | rows, | ||
| int | conv_dim, | ||
| int | kernel_size, | ||
| int | channel_begin, | ||
| int | channel_end | ||
| ) |
Definition at line 102 of file mamba2_kernels.c.
References mamba2_silu_f32().
Referenced by mamba2_conv1d_decode_f32().
| void mamba2_conv1d_f32_parallel_dispatch | ( | const float * | state_in, |
| const float * | x, | ||
| const float * | weight, | ||
| const float * | bias, | ||
| float * | conv_out, | ||
| float * | state_out, | ||
| int | rows, | ||
| int | conv_dim, | ||
| int | kernel_size | ||
| ) |
| void mamba2_dt_softplus_f32 | ( | const float * | dt, |
| const float * | dt_bias, | ||
| float * | dt_out, | ||
| int | rows, | ||
| int | num_heads, | ||
| float | dt_min, | ||
| float | dt_max | ||
| ) |
Definition at line 171 of file mamba2_kernels.c.
References ck_mamba_debug_finite(), and mamba2_softplus_f32().
| void mamba2_in_proj_split_f32 | ( | const float * | projected, |
| float * | gate, | ||
| float * | hidden_bc, | ||
| float * | dt, | ||
| int | rows, | ||
| int | d_mlp, | ||
| int | intermediate_dim, | ||
| int | conv_dim, | ||
| int | num_heads | ||
| ) |
Definition at line 65 of file mamba2_kernels.c.
References ck_mamba_debug_finite().
| void mamba2_rmsnorm_gate_f32 | ( | const float * | x, |
| const float * | gate, | ||
| const float * | weight, | ||
| float * | out, | ||
| int | rows, | ||
| int | inner_dim, | ||
| int | group_size, | ||
| float | eps | ||
| ) |
Definition at line 373 of file mamba2_kernels.c.
References ck_mamba_debug_finite(), end, mamba2_silu_f32(), and start.
| void mamba2_selective_scan_f32 | ( | const float * | state_init, |
| const float * | x, | ||
| const float * | dt, | ||
| const float * | a, | ||
| const float * | b, | ||
| const float * | c, | ||
| const float * | d, | ||
| float * | state_out, | ||
| float * | y, | ||
| int | batch, | ||
| int | seq_len, | ||
| int | num_heads, | ||
| int | head_dim, | ||
| int | state_dim, | ||
| int | num_groups | ||
| ) |
Definition at line 339 of file mamba2_kernels.c.
References ck_mamba_debug_finite(), and mamba2_selective_scan_f32_head_range().
| void mamba2_selective_scan_f32_head_range | ( | const float * | state_init, |
| const float * | x, | ||
| const float * | dt, | ||
| const float * | a, | ||
| const float * | b, | ||
| const float * | c, | ||
| const float * | d, | ||
| float * | state_out, | ||
| float * | y, | ||
| int | batch, | ||
| int | seq_len, | ||
| int | num_heads, | ||
| int | head_dim, | ||
| int | state_dim, | ||
| int | num_groups, | ||
| int | head_begin, | ||
| int | head_end | ||
| ) |
Definition at line 264 of file mamba2_kernels.c.
Referenced by mamba2_selective_scan_f32().
| void mamba2_selective_scan_f32_parallel_dispatch | ( | const float * | state_init, |
| const float * | x, | ||
| const float * | dt, | ||
| const float * | a, | ||
| const float * | b, | ||
| const float * | c, | ||
| const float * | d, | ||
| float * | state_out, | ||
| float * | y, | ||
| int | batch, | ||
| int | seq_len, | ||
| int | num_heads, | ||
| int | head_dim, | ||
| int | state_dim, | ||
| int | num_groups | ||
| ) |
| void mamba2_selective_state_update_decode_f32 | ( | const float * | state_in, |
| const float * | x, | ||
| const float * | dt, | ||
| const float * | a, | ||
| const float * | b, | ||
| const float * | c, | ||
| const float * | d, | ||
| float * | state_out, | ||
| float * | y, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | head_dim, | ||
| int | state_dim, | ||
| int | num_groups | ||
| ) |
Definition at line 204 of file mamba2_kernels.c.
| void mlp_token_parallel | ( | const float * | input, |
| const float * | W_fc1, | ||
| const float * | b_fc1, | ||
| const float * | W_fc2, | ||
| const float * | b_fc2, | ||
| float * | fc1_output, | ||
| float * | output, | ||
| int | T, | ||
| int | aligned_dim, | ||
| int | num_threads | ||
| ) |
Definition at line 49 of file mlp_kernels.c.
References gelu_fast_inplace(), and gemm_blocked_serial().
| void mlp_token_parallel_bf16 | ( | const uint16_t * | input, |
| const uint16_t * | W_fc1, | ||
| const uint16_t * | b_fc1, | ||
| const uint16_t * | W_fc2, | ||
| const uint16_t * | b_fc2, | ||
| float * | fc1_output, | ||
| float * | output, | ||
| int | T, | ||
| int | aligned_dim, | ||
| int | num_threads, | ||
| float * | scratch_bias1_f, | ||
| float * | scratch_bias2_f, | ||
| uint16_t * | scratch_fc1_bf16 | ||
| ) |
Optimized MLP Forward (BF16 weights, FP32 activations)
Caller-provided scratch buffers: scratch_bias1_f: [4*D] floats scratch_bias2_f: [D] floats scratch_fc1_bf16: [T * 4*D] uint16_t (BF16)
Definition at line 104 of file mlp_kernels_bf16.c.
References bf16_to_float(), float_to_bf16(), gelu_scalar(), and gemm_bf16_fp32out().
| void mlp_token_parallel_bf16_backward_mixed | ( | const uint16_t * | input, |
| const uint16_t * | W_fc1, | ||
| const uint16_t * | b_fc1, | ||
| const uint16_t * | W_fc2, | ||
| const uint16_t * | d_output, | ||
| float * | d_input, | ||
| float * | d_W_fc1, | ||
| float * | d_b_fc1, | ||
| float * | d_W_fc2, | ||
| float * | d_b_fc2, | ||
| int | T, | ||
| int | aligned_dim, | ||
| int | num_threads, | ||
| float * | scratch_fc1_pre, | ||
| uint16_t * | scratch_fc1_act_bf16, | ||
| float * | scratch_d_fc1 | ||
| ) |
BF16 MLP backward with FP32 gradient accumulation.
Forward contract matched here: z1 = input_bf16 @ W_fc1_bf16.T + b_fc1_bf16 h = GELU(z1) hq = round_to_bf16(h) y = hq @ W_fc2_bf16.T + b_fc2_bf16
Gradients are accumulated and written as FP32. The BF16 activation cast is treated like PyTorch's mixed-precision cast: gradient flows through to h, while d_W_fc2 uses the rounded hq values that FC2 actually consumed.
Definition at line 268 of file mlp_kernels_bf16.c.
References bf16_to_float(), float_to_bf16(), gelu_derivative_scalar(), and gelu_scalar().
| void mlp_token_parallel_bf16_fp32act | ( | const uint16_t * | input, |
| const uint16_t * | W_fc1, | ||
| const uint16_t * | b_fc1, | ||
| const uint16_t * | W_fc2, | ||
| const uint16_t * | b_fc2, | ||
| float * | fc1_output, | ||
| float * | output, | ||
| int | T, | ||
| int | aligned_dim, | ||
| int | num_threads, | ||
| float * | scratch_input_f, | ||
| float * | scratch_bias1_f, | ||
| float * | scratch_bias2_f, | ||
| uint16_t * | scratch_fc1_bf16 | ||
| ) |
Alternative: Fully FP32 activations throughout
Caller-provided scratch buffers: scratch_input_f: [T * D] floats scratch_bias1_f: [4*D] floats scratch_bias2_f: [D] floats scratch_fc1_bf16: [T * 4*D] uint16_t (BF16)
Definition at line 199 of file mlp_kernels_bf16.c.
References bf16_tensor_to_float(), float_tensor_to_bf16(), gelu_scalar(), and gemm_bf16_fp32out().
| void mlp_token_parallel_exact | ( | const float * | input, |
| const float * | W_fc1, | ||
| const float * | b_fc1, | ||
| const float * | W_fc2, | ||
| const float * | b_fc2, | ||
| float * | fc1_output, | ||
| float * | output, | ||
| int | T, | ||
| int | aligned_dim, | ||
| int | num_threads | ||
| ) |
Definition at line 84 of file mlp_kernels.c.
References gelu_exact_inplace(), and gemm_blocked_serial().
| 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().
| int moe_softmax_topk_router_llama_f32_workspace | ( | const float * | logits, |
| int * | indices, | ||
| float * | weights, | ||
| int | rows, | ||
| int | n_experts, | ||
| int | top_k, | ||
| float | routed_scaling_factor, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 316 of file topk_kernels.c.
References ck_moe_llama_softmax_row(), moe_softmax_topk_router_workspace_bytes(), and topk_f32().
Referenced by moe_softmax_topk_router_pytorch_bf16_workspace().
| int moe_softmax_topk_router_pytorch_bf16_workspace | ( | const float * | logits, |
| int * | indices, | ||
| float * | weights, | ||
| int | rows, | ||
| int | n_experts, | ||
| int | top_k, | ||
| float | routed_scaling_factor, | ||
| void * | workspace, | ||
| size_t | workspace_bytes | ||
| ) |
Definition at line 375 of file topk_kernels.c.
References bf16_to_float(), float_to_bf16(), and moe_softmax_topk_router_llama_f32_workspace().
| size_t moe_softmax_topk_router_workspace_bytes | ( | int | n_experts | ) |
Definition at line 177 of file topk_kernels.c.
Referenced by moe_softmax_topk_router_llama_f32_workspace().
| 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_parallel_dispatch | ( | 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 | ||
| ) |
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_prepared_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 | ||
| ) |
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_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_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_parallel_dispatch | ( | 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 | ||
| ) |
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_parallel_dispatch | ( | 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_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 mrope_qk_imrope_positions | ( | float * | q, |
| float * | k, | ||
| const int32_t * | positions, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | n_dims, | ||
| int | section_0, | ||
| int | section_1, | ||
| int | section_2, | ||
| int | section_3, | ||
| int | n_ctx_orig, | ||
| float | freq_base, | ||
| float | freq_scale, | ||
| float | ext_factor, | ||
| float | attn_factor, | ||
| float | beta_fast, | ||
| float | beta_slow | ||
| ) |
Definition at line 2686 of file rope_kernels.c.
References ck_strict_parity_enabled(), explicit_mrope_apply_ggml_exact(), explicit_mrope_apply_head(), and GGML_ROPE_TYPE_IMROPE.
| void mrope_qk_text | ( | float * | q, |
| float * | k, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | n_dims, | ||
| int | section_0, | ||
| int | section_1, | ||
| int | section_2, | ||
| int | section_3, | ||
| int | n_ctx_orig, | ||
| float | freq_base, | ||
| float | freq_scale, | ||
| float | ext_factor, | ||
| float | attn_factor, | ||
| float | beta_fast, | ||
| float | beta_slow | ||
| ) |
Definition at line 2203 of file rope_kernels.c.
References text_mrope_apply_head().
| void mrope_qk_text_imrope | ( | float * | q, |
| float * | k, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | n_dims, | ||
| int | section_0, | ||
| int | section_1, | ||
| int | section_2, | ||
| int | section_3, | ||
| int | n_ctx_orig, | ||
| float | freq_base, | ||
| float | freq_scale, | ||
| float | ext_factor, | ||
| float | attn_factor, | ||
| float | beta_fast, | ||
| float | beta_slow | ||
| ) |
Definition at line 2273 of file rope_kernels.c.
References text_mrope_apply_head().
| void mrope_qk_text_imrope_bf16_pytorch_storage | ( | float * | q, |
| float * | k, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | n_dims, | ||
| int | section_0, | ||
| int | section_1, | ||
| int | section_2, | ||
| int | section_3, | ||
| int | n_ctx_orig, | ||
| float | freq_base, | ||
| float | freq_scale, | ||
| float | ext_factor, | ||
| float | attn_factor, | ||
| float | beta_fast, | ||
| float | beta_slow | ||
| ) |
Definition at line 2496 of file rope_kernels.c.
References text_mrope_apply_pytorch_bf16_storage().
| void mrope_qk_text_imrope_positions_bf16_pytorch_storage | ( | float * | q, |
| float * | k, | ||
| const int32_t * | positions, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | n_dims, | ||
| int | section_0, | ||
| int | section_1, | ||
| int | section_2, | ||
| int | section_3, | ||
| int | n_ctx_orig, | ||
| float | freq_base, | ||
| float | freq_scale, | ||
| float | ext_factor, | ||
| float | attn_factor, | ||
| float | beta_fast, | ||
| float | beta_slow | ||
| ) |
Definition at line 2460 of file rope_kernels.c.
References text_mrope_apply_positions_pytorch_bf16_storage().
| void mrope_qk_vision | ( | float * | q, |
| float * | k, | ||
| const int32_t * | positions, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | n_dims, | ||
| int | section_0, | ||
| int | section_1, | ||
| int | section_2, | ||
| int | section_3, | ||
| int | n_ctx_orig, | ||
| float | freq_base, | ||
| float | freq_scale, | ||
| float | ext_factor, | ||
| float | attn_factor, | ||
| float | beta_fast, | ||
| float | beta_slow | ||
| ) |
Definition at line 2534 of file rope_kernels.c.
References ck_strict_parity_enabled(), explicit_mrope_apply_ggml_exact(), GGML_ROPE_TYPE_VISION, and vision_mrope_apply_head().
| void mrope_qk_vision_bf16_pytorch_storage | ( | float * | q, |
| float * | k, | ||
| const int32_t * | positions, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | n_dims, | ||
| int | section_0, | ||
| int | section_1, | ||
| int | section_2, | ||
| int | section_3, | ||
| int | n_ctx_orig, | ||
| float | freq_base, | ||
| float | freq_scale, | ||
| float | ext_factor, | ||
| float | attn_factor, | ||
| float | beta_fast, | ||
| float | beta_slow | ||
| ) |
| void mrope_qk_vision_bf16_storage | ( | float * | q, |
| float * | k, | ||
| const int32_t * | positions, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | n_dims, | ||
| int | section_0, | ||
| int | section_1, | ||
| int | section_2, | ||
| int | section_3, | ||
| int | n_ctx_orig, | ||
| float | freq_base, | ||
| float | freq_scale, | ||
| float | ext_factor, | ||
| float | attn_factor, | ||
| float | beta_fast, | ||
| float | beta_slow | ||
| ) |
Definition at line 2645 of file rope_kernels.c.
| void mrope_qk_vision_fp16_storage | ( | float * | q, |
| float * | k, | ||
| const int32_t * | positions, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | n_dims, | ||
| int | section_0, | ||
| int | section_1, | ||
| int | section_2, | ||
| int | section_3, | ||
| int | n_ctx_orig, | ||
| float | freq_base, | ||
| float | freq_scale, | ||
| float | ext_factor, | ||
| float | attn_factor, | ||
| float | beta_fast, | ||
| float | beta_slow | ||
| ) |
Definition at line 2646 of file rope_kernels.c.
| void nemotron_group_limited_topk_router_f32 | ( | const float * | scores, |
| const float * | correction_bias, | ||
| int * | indices, | ||
| float * | weights, | ||
| int | rows, | ||
| int | n_experts, | ||
| int | top_k, | ||
| int | n_group, | ||
| int | topk_group, | ||
| int | norm_topk_prob, | ||
| float | routed_scaling_factor | ||
| ) |
Definition at line 780 of file topk_kernels.c.
References group_limited_topk_router_f32_impl().
| void patch2im | ( | const float * | d_patches, |
| float * | d_image, | ||
| int | C, | ||
| int | H, | ||
| int | W, | ||
| int | P | ||
| ) |
patch2im: Accumulates gradients from patches back into the image. (Backward pass)
d_patches: [num_patches, C * P * P] d_image: [C, H, W] (Accumulated)
Definition at line 123 of file vision_kernels.c.
References C.
| void patch2im_bf16 | ( | const uint16_t * | d_patches, |
| uint16_t * | d_image, | ||
| int | C, | ||
| int | H, | ||
| int | W, | ||
| int | P | ||
| ) |
Definition at line 57 of file vision_kernels_bf16.c.
References bf16_to_float(), C, and float_to_bf16().
| void patch_projection_bf16_pytorch_onednn_conv3d_storage | ( | const float * | input, |
| const void * | weights, | ||
| const float * | bias, | ||
| float * | output, | ||
| int | batch, | ||
| int | out_channels, | ||
| int | in_channels, | ||
| int | temporal, | ||
| int | patch_h, | ||
| int | patch_w | ||
| ) |
Definition at line 1564 of file gemm_kernels_bf16.c.
References bf16_to_float(), and float_to_bf16().
Referenced by patch_projection_image_bf16_pytorch_onednn_conv3d_storage().
| void patch_projection_image_bf16_native_storage | ( | const float * | image, |
| const void * | weights_t0, | ||
| const void * | weights_t1, | ||
| const float * | bias, | ||
| float * | output, | ||
| int | channels, | ||
| int | image_h, | ||
| int | image_w, | ||
| int | patch_size, | ||
| int | out_channels, | ||
| int | merge_size | ||
| ) |
Definition at line 1940 of file gemm_kernels_bf16.c.
References ck_patch_projection_bf16_native_work(), ck_threadpool_dispatch_n(), ck_threadpool_global(), and ck_threadpool_n_threads().
| void patch_projection_image_bf16_pytorch_onednn_conv3d_storage | ( | const float * | image, |
| const void * | weights_t0, | ||
| const void * | weights_t1, | ||
| const float * | bias, | ||
| float * | output, | ||
| int | channels, | ||
| int | image_h, | ||
| int | image_w, | ||
| int | patch_size, | ||
| int | out_channels, | ||
| int | merge_size | ||
| ) |
Definition at line 1750 of file gemm_kernels_bf16.c.
References patch_projection_bf16_pytorch_onednn_conv3d_storage().
| void position_embeddings_add | ( | float * | x, |
| const float * | position_embd, | ||
| int | num_tokens, | ||
| int | embed_dim, | ||
| int | num_positions | ||
| ) |
Add learned absolute position embeddings in-place.
x layout: [num_tokens, embed_dim] position_embd: [num_positions, embed_dim]
This first v8 vision path intentionally assumes native resized embeddings are already materialized in the weight tensor, so token i maps directly to position_embd[i]. This is the correct contract for fixed-size bring-up.
Definition at line 168 of file vision_kernels.c.
| void position_embeddings_add_at_offset | ( | float * | x, |
| const float * | position_embd, | ||
| int | num_tokens, | ||
| int | embed_dim, | ||
| int | num_positions, | ||
| int | start_position | ||
| ) |
Definition at line 187 of file vision_kernels.c.
| void position_embeddings_add_gemma4v_xy | ( | float * | x, |
| const float * | position_embd, | ||
| int | grid_h, | ||
| int | grid_w, | ||
| int | embed_dim, | ||
| int | source_grid_size | ||
| ) |
Definition at line 209 of file vision_kernels.c.
| void position_embeddings_add_tiled_2d | ( | float * | x, |
| const float * | position_embd, | ||
| int | grid_h, | ||
| int | grid_w, | ||
| int | embed_dim, | ||
| int | merge_size, | ||
| int | source_grid_size | ||
| ) |
Definition at line 248 of file vision_kernels.c.
References tile_order_index_2d(), and tile_order_linear_index_2d().
| void position_embeddings_add_tiled_2d_align_corners | ( | float * | x, |
| const float * | position_embd, | ||
| int | grid_h, | ||
| int | grid_w, | ||
| int | embed_dim, | ||
| int | merge_size, | ||
| int | source_grid_size | ||
| ) |
Definition at line 342 of file vision_kernels.c.
References tile_order_index_2d().
| void position_embeddings_add_tiled_2d_align_corners_bf16 | ( | float * | x, |
| const float * | position_embd, | ||
| int | grid_h, | ||
| int | grid_w, | ||
| int | embed_dim, | ||
| int | merge_size, | ||
| int | source_grid_size | ||
| ) |
Definition at line 397 of file vision_kernels.c.
References bf16_to_float(), float_to_bf16(), and tile_order_index_2d().
| void position_embeddings_add_tiled_2d_align_corners_fp32_interp_bf16 | ( | float * | x, |
| const float * | position_embd, | ||
| int | grid_h, | ||
| int | grid_w, | ||
| int | embed_dim, | ||
| int | merge_size, | ||
| int | source_grid_size | ||
| ) |
Definition at line 458 of file vision_kernels.c.
References bf16_to_float(), float_to_bf16(), and tile_order_index_2d().
| void q_norm_forward | ( | float * | q, |
| const float * | q_gamma, | ||
| int | num_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
Forward pass for Gemma4-assistant q-only per-head RMSNorm.
Some Gemma4 assistant/drafter checkpoints project only Q and then reuse Q as the shared K/V stream. This wrapper keeps that public kernel contract explicit while reusing the same row-wise RMSNorm implementation as qk_norm_forward.
Definition at line 405 of file qk_norm_kernels.c.
References rmsnorm_forward().
| void qk_norm_backward | ( | const float * | d_q_out, |
| const float * | d_k_out, | ||
| const float * | q_in, | ||
| const float * | k_in, | ||
| const float * | q_gamma, | ||
| const float * | k_gamma, | ||
| float * | d_q_in, | ||
| float * | d_k_in, | ||
| float * | d_q_gamma, | ||
| float * | d_k_gamma, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
Backward pass for per-head QK RMSNorm.
This computes:
Implementation is reference-first and deterministic: 1) recompute row rstd values from saved q/k inputs 2) call rmsnorm_backward on flattened [rows, head_dim] views
Definition at line 427 of file qk_norm_kernels.c.
References qk_norm_compute_rstd(), and rmsnorm_backward().
| int qk_norm_backward_last_isa | ( | void | ) |
| void qk_norm_forward | ( | float * | q, |
| float * | k, | ||
| const float * | q_gamma, | ||
| const float * | k_gamma, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
Per-head RMSNorm on Q and K.
| q | Q scratch buffer [num_heads * num_tokens * head_dim], in-place |
| k | K scratch buffer [num_kv_heads * num_tokens * head_dim], in-place |
| q_gamma | Q norm gamma weights [head_dim] |
| k_gamma | K norm gamma weights [head_dim] |
| num_heads | Number of query heads (e.g. 32 for Qwen3-8B) |
| num_kv_heads | Number of KV heads (e.g. 8 for Qwen3-8B with GQA) |
| num_tokens | Number of tokens (1 for decode, T for prefill) |
| head_dim | Dimension per head (e.g. 128) |
| eps | RMSNorm epsilon (e.g. 1e-6) |
Definition at line 326 of file qk_norm_kernels.c.
References rmsnorm_forward().
| void qk_norm_forward_decode_exact | ( | float * | q, |
| float * | k, | ||
| const float * | q_gamma, | ||
| const float * | k_gamma, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
| void qk_norm_forward_fp64_sum | ( | float * | q, |
| float * | k, | ||
| const float * | q_gamma, | ||
| const float * | k_gamma, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
Definition at line 342 of file qk_norm_kernels.c.
References rmsnorm_forward_fp64_sum().
| void qk_norm_forward_llama_production | ( | float * | q, |
| float * | k, | ||
| const float * | q_gamma, | ||
| const float * | k_gamma, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
Definition at line 353 of file qk_norm_kernels.c.
References rmsnorm_forward_llama_production().
| void qk_norm_forward_parallel_dispatch | ( | float * | q, |
| float * | k, | ||
| const float * | q_gamma, | ||
| const float * | k_gamma, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
| void qk_norm_forward_prefill_exact | ( | float * | q, |
| float * | k, | ||
| const float * | q_gamma, | ||
| const float * | k_gamma, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
| void qk_norm_forward_pytorch_bf16_storage | ( | float * | q, |
| float * | k, | ||
| const float * | q_gamma, | ||
| const float * | k_gamma, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
Definition at line 366 of file qk_norm_kernels.c.
References rmsnorm_forward_pytorch_bf16_storage().
| void qk_norm_forward_qwen4_pytorch_bf16_storage | ( | float * | q, |
| float * | k, | ||
| const float * | q_gamma, | ||
| const float * | k_gamma, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
Definition at line 381 of file qk_norm_kernels.c.
References rmsnorm_forward_qwen3next_pytorch_bf16_storage().
| void quantize_batch_q8_0 | ( | const float * | x, |
| void * | vy, | ||
| int | num_rows, | ||
| int | k | ||
| ) |
Batch quantize FP32 to Q8_0 format (row-major output)
Quantizes multiple rows of FP32 data to Q8_0 format, placing each row's Q8_0 output at the correct byte offset for GEMM compatibility.
Memory layout: Input: [num_rows, k] FP32, row-major (stride = k * sizeof(float)) Output: [num_rows, q8_row_bytes] Q8_0, row-major (stride = q8_row_bytes)
where q8_row_bytes = (k / 32) * sizeof(block_q8_0) = (k / 32) * 34
| x | Input FP32 values [num_rows * k] |
| vy | Output Q8_0 blocks [num_rows * (k/32) blocks] |
| num_rows | Number of rows (batch size / tokens) |
| k | Elements per row (must be multiple of 32) |
Definition at line 256 of file gemm_kernels_q8_0.c.
References QK8_0, and quantize_row_q8_0().
| void quantize_batch_q8_k | ( | const float * | x, |
| void * | vy, | ||
| int | num_rows, | ||
| int | k | ||
| ) |
Batch quantize FP32 to Q8_K format (row-major output)
Same as quantize_batch_q8_0 but for Q8_K format (super-blocks).
| x | Input FP32 values [num_rows * k] |
| vy | Output Q8_K blocks |
| num_rows | Number of rows (batch size / tokens) |
| k | Elements per row (must be multiple of 256) |
Definition at line 283 of file gemm_kernels_q8_0.c.
References quantize_row_q8_k().
| void quantize_batch_q8_k_4row_nearest_even | ( | const float * | x, |
| void * | y, | ||
| int | num_rows, | ||
| int | k | ||
| ) |
Definition at line 140 of file gemm_kernels_q4k_q8k.c.
References QK_K, and quantize_row_q8_k().
| void quantize_row_q8_0 | ( | const float * | x, |
| void * | vy, | ||
| int | k | ||
| ) |
Quantize FP32 to Q8_0 format (scalar reference)
| x | Input FP32 values |
| vy | Output Q8_0 blocks |
| k | Number of elements (must be multiple of 32) |
Definition at line 125 of file gemm_kernels_q8_0.c.
References CK_FP32_TO_FP16, ck_nearest_int_q8_0(), block_q8_0::d, id, QK8_0, and block_q8_0::qs.
Referenced by ck_moe_q4k_mixed_route_work(), ck_moe_shared_q4k_gated_workspace(), ck_moe_swiglu_nvfp4_projection(), fused_mlp_swiglu_prefill_w1w2_quant(), fused_rmsnorm_qkv_prefill_head_major_quant(), gemv_q8_0_q8_0_contract(), hyper_connection_mix_quantized(), moe_swiglu_expert_forward_q4k_q5_0_workspace(), moe_swiglu_expert_forward_q4k_q8_0_workspace(), moe_swiglu_shared_forward_q8_0_gated_workspace(), quantize_attn_out_head_major_q8_0(), quantize_attn_out_head_major_q8_0(), and quantize_attn_out_head_major_q8_0().
| void quantize_row_q8_k | ( | const float * | x, |
| void * | y, | ||
| int | k | ||
| ) |
Definition at line 121 of file gemm_kernels_q4k_q8k.c.
References quantize_row_q8_k_avx(), quantize_row_q8_k_avx2(), quantize_row_q8_k_avx512(), quantize_row_q8_k_ref(), and quantize_row_q8_k_sse().
Referenced by ck_attention_project_head_major_q4_k_q8_k(), ck_layer_forward_rmsnorm_swiglu_decode_q4_k(), ck_mlp_swiglu_forward_q4_k_q8_k(), ck_mlp_swiglu_forward_q4_k_q8_k_prefill(), ck_moe_q4k_mixed_route_parallel(), ck_moe_q4k_mixed_route_work(), ck_moe_q4k_q5k_bucket_work(), ck_moe_q4k_q5k_quantize_work(), ck_moe_q4k_q5k_route_parallel(), ck_moe_q4k_q5k_route_work(), ck_moe_shared_q4k_gated_workspace(), ck_qkv_project_head_major_q4_k_q8_k(), decode_layer_parallel(), fused_mlp_swiglu_prefill_w1w2_quant(), fused_rmsnorm_qkv_prefill_head_major_quant(), hyper_connection_mix_quantized(), mlp_parallel(), model_decode_token(), model_decode_token(), model_forward_prefill_impl(), model_forward_prefill_impl(), model_forward_prefill_impl(), model_forward_prefill_impl(), model_layer_0_decode(), model_layer_0_decode(), model_layer_10_decode(), model_layer_10_decode(), model_layer_11_decode(), model_layer_11_decode(), model_layer_12_decode(), model_layer_12_decode(), model_layer_13_decode(), model_layer_13_decode(), model_layer_14_decode(), model_layer_14_decode(), model_layer_15_decode(), model_layer_15_decode(), model_layer_16_decode(), model_layer_16_decode(), model_layer_17_decode(), model_layer_17_decode(), model_layer_18_decode(), model_layer_18_decode(), model_layer_19_decode(), model_layer_19_decode(), model_layer_1_decode(), model_layer_1_decode(), model_layer_20_decode(), model_layer_20_decode(), model_layer_21_decode(), model_layer_21_decode(), model_layer_22_decode(), model_layer_22_decode(), model_layer_23_decode(), model_layer_23_decode(), model_layer_2_decode(), model_layer_2_decode(), model_layer_3_decode(), model_layer_3_decode(), model_layer_4_decode(), model_layer_4_decode(), model_layer_5_decode(), model_layer_5_decode(), model_layer_6_decode(), model_layer_6_decode(), model_layer_7_decode(), model_layer_7_decode(), model_layer_8_decode(), model_layer_8_decode(), model_layer_9_decode(), model_layer_9_decode(), 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_shared_forward_q4k_q4k_workspace(), moe_swiglu_shared_forward_q4k_q6k_workspace(), qwen2_0_5b_decode_decode_token(), qwen2_0_5b_decode_decode_token(), qwen2_0_5b_decode_forward_prefill_impl(), qwen2_0_5b_decode_forward_prefill_impl(), qwen2_0_5b_decode_forward_prefill_impl(), qwen2_0_5b_decode_forward_prefill_impl(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_9_decode(), qwen2_0_5b_decode_layer_9_decode(), swiglu_forward_q8_k(), and unfused_rmsnorm_linear_q4k_ref().
| void qwen4_ple_gate_conv_inject_bf16 | ( | const float * | hyper_input, |
| const float * | key_projected, | ||
| const float * | value_projected, | ||
| const float * | norm_key_weight, | ||
| const float * | norm_query_weight, | ||
| const float * | norm_conv_weight, | ||
| const uint16_t * | conv_weight, | ||
| float * | hyper_output, | ||
| float * | key_norm_scratch, | ||
| float * | query_norm_scratch, | ||
| float * | gated_scratch, | ||
| float * | conv_norm_scratch, | ||
| const float * | conv_state_in, | ||
| float * | conv_state_out, | ||
| int | rows, | ||
| int | streams, | ||
| int | hidden_dim, | ||
| int | kernel_size, | ||
| int | dilation, | ||
| float | eps | ||
| ) |
Definition at line 402 of file qwen4_exp_kernels.c.
References qwen4_ple_gate_conv_inject_impl().
| void qwen4_ple_gate_conv_inject_fp16 | ( | const float * | hyper_input, |
| const float * | key_projected, | ||
| const float * | value_projected, | ||
| const float * | norm_key_weight, | ||
| const float * | norm_query_weight, | ||
| const float * | norm_conv_weight, | ||
| const uint16_t * | conv_weight, | ||
| float * | hyper_output, | ||
| float * | key_norm_scratch, | ||
| float * | query_norm_scratch, | ||
| float * | gated_scratch, | ||
| float * | conv_norm_scratch, | ||
| const float * | conv_state_in, | ||
| float * | conv_state_out, | ||
| int | rows, | ||
| int | streams, | ||
| int | hidden_dim, | ||
| int | kernel_size, | ||
| int | dilation, | ||
| float | eps | ||
| ) |
Definition at line 419 of file qwen4_exp_kernels.c.
References qwen4_ple_gate_conv_inject_impl().
| void qwen4_ple_gate_conv_inject_llama_fp16 | ( | const float * | hyper_input, |
| const float * | key_projected, | ||
| const float * | value_projected, | ||
| const float * | norm_key_weight, | ||
| const float * | norm_query_weight, | ||
| const float * | norm_conv_weight, | ||
| const uint16_t * | conv_weight, | ||
| float * | hyper_output, | ||
| float * | key_norm_scratch, | ||
| float * | query_norm_scratch, | ||
| float * | gated_scratch, | ||
| float * | conv_norm_scratch, | ||
| const float * | conv_state_in, | ||
| float * | conv_state_out, | ||
| int | rows, | ||
| int | streams, | ||
| int | hidden_dim, | ||
| int | kernel_size, | ||
| int | dilation, | ||
| float | eps | ||
| ) |
Definition at line 436 of file qwen4_exp_kernels.c.
References qwen4_ple_gate_conv_inject_impl().
| void qwen4_ple_ngram_embed_bf16 | ( | const int32_t * | token_ids, |
| const uint16_t * | embedding, | ||
| const int64_t * | layer_multipliers, | ||
| const int64_t * | head_offsets, | ||
| const int64_t * | head_vocab_sizes, | ||
| float * | output, | ||
| const float * | token_state_in, | ||
| float * | token_state_out, | ||
| int | rows, | ||
| int | ngram_size, | ||
| int | heads_per_ngram, | ||
| int | head_dim, | ||
| int | eos_token_id, | ||
| int | position | ||
| ) |
Definition at line 121 of file qwen4_exp_kernels.c.
References qwen4_ple_ngram_embed_impl().
| void qwen4_ple_ngram_embed_q5_0 | ( | const int32_t * | token_ids, |
| const void * | embedding, | ||
| const int64_t * | layer_multipliers, | ||
| const int64_t * | head_offsets, | ||
| const int64_t * | head_vocab_sizes, | ||
| float * | output, | ||
| const float * | token_state_in, | ||
| float * | token_state_out, | ||
| int | rows, | ||
| int | ngram_size, | ||
| int | heads_per_ngram, | ||
| int | head_dim, | ||
| int | eos_token_id, | ||
| int | position | ||
| ) |
Definition at line 141 of file qwen4_exp_kernels.c.
References qwen4_ple_ngram_embed_impl().
| void qwen4_qsa_index_select_bf16 | ( | const float * | projected_qk, |
| const float * | index_key_cache_in, | ||
| const float * | q_norm_weight, | ||
| const float * | k_norm_weight, | ||
| float * | selected_indices, | ||
| float * | index_key_cache_out, | ||
| float * | q_norm_scratch, | ||
| float * | pooled_key_scratch, | ||
| float * | block_score_scratch, | ||
| int32_t * | block_index_scratch, | ||
| int | rows, | ||
| int | query_heads, | ||
| int | index_head_dim, | ||
| int | token_budget, | ||
| int | compress_ratio, | ||
| int | rotary_dim, | ||
| int | context_length, | ||
| int | position, | ||
| float | rope_theta, | ||
| float | eps | ||
| ) |
Definition at line 488 of file qwen4_exp_kernels.c.
References qwen4_bf16_round(), qwen4_rope_split_inplace(), qwen4_shared_head_rmsnorm(), score, and token.
| void recurrent_conv_state_update_backward | ( | const float * | d_conv_x, |
| const float * | d_state_out, | ||
| float * | d_state_in, | ||
| float * | d_q, | ||
| float * | d_k, | ||
| float * | d_v, | ||
| int | history_len, | ||
| int | num_seqs, | ||
| int | num_tokens, | ||
| int | q_dim, | ||
| int | k_dim, | ||
| int | v_dim | ||
| ) |
Definition at line 160 of file recurrent_state_kernels.c.
References recurrent_conv_backward_extents(), and recurrent_conv_state_update_backward_workspace().
| void recurrent_conv_state_update_backward_workspace | ( | const float * | d_conv_x, |
| const float * | d_state_out, | ||
| float * | d_state_in, | ||
| float * | d_q, | ||
| float * | d_k, | ||
| float * | d_v, | ||
| float * | d_conv_total, | ||
| int | history_len, | ||
| int | num_seqs, | ||
| int | num_tokens, | ||
| int | q_dim, | ||
| int | k_dim, | ||
| int | v_dim | ||
| ) |
Definition at line 91 of file recurrent_state_kernels.c.
References recurrent_conv_backward_extents().
Referenced by recurrent_conv_state_update_backward().
| void recurrent_conv_state_update_forward | ( | const float * | state_in, |
| const float * | q, | ||
| const float * | k, | ||
| const float * | v, | ||
| float * | conv_x, | ||
| float * | state_out, | ||
| int | history_len, | ||
| int | num_seqs, | ||
| int | num_tokens, | ||
| int | q_dim, | ||
| int | k_dim, | ||
| int | v_dim | ||
| ) |
Definition at line 8 of file recurrent_state_kernels.c.
| void recurrent_dt_gate_backward | ( | const float * | d_gate, |
| const float * | alpha, | ||
| const float * | dt_bias, | ||
| const float * | a, | ||
| float * | d_alpha, | ||
| float * | d_dt_bias, | ||
| float * | d_a, | ||
| int | rows, | ||
| int | dim | ||
| ) |
Definition at line 104 of file recurrent_gate_kernels.c.
References recurrent_sigmoid(), and recurrent_softplus().
| void recurrent_dt_gate_expanded_forward | ( | const float * | alpha, |
| const float * | dt_bias, | ||
| const float * | a, | ||
| float * | gate, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | state_dim | ||
| ) |
Definition at line 83 of file recurrent_gate_kernels.c.
References recurrent_softplus().
| void recurrent_dt_gate_forward | ( | const float * | alpha, |
| const float * | dt_bias, | ||
| const float * | a, | ||
| float * | gate, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | state_dim | ||
| ) |
Definition at line 65 of file recurrent_gate_kernels.c.
References recurrent_softplus().
| void recurrent_dt_gate_forward_pytorch_fp32 | ( | const float * | alpha, |
| const float * | dt_bias, | ||
| const float * | a, | ||
| float * | gate, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | state_dim | ||
| ) |
Definition at line 179 of file recurrent_gate_kernels.c.
References __attribute__(), ck_bind_recurrent_llama_libm(), ck_recurrent_libm_once, ck_recurrent_llama_expf, and ck_recurrent_pytorch_log1pf.
| void recurrent_norm_gate_backward | ( | const float * | d_out, |
| const float * | x, | ||
| const float * | gate, | ||
| const float * | weight, | ||
| float * | d_x, | ||
| float * | d_gate, | ||
| float * | d_weight, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
Definition at line 182 of file recurrent_norm_kernels.c.
References recurrent_sigmoid_local(), and silu().
| void recurrent_norm_gate_forward | ( | const float * | x, |
| const float * | gate, | ||
| const float * | weight, | ||
| float * | out, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
Definition at line 18 of file recurrent_norm_kernels.c.
References recurrent_sigmoid_local(), and silu().
| void recurrent_norm_gate_llama_avx2_forward | ( | const float * | x, |
| const float * | gate, | ||
| const float * | weight, | ||
| float * | out, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
Definition at line 53 of file recurrent_norm_kernels.c.
References recurrent_silu_forward_ggml(), rmsnorm_forward_llama_production(), and silu().
| void recurrent_norm_gate_pytorch_bf16_storage | ( | const float * | x, |
| const float * | gate, | ||
| const float * | weight, | ||
| float * | out, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
Definition at line 111 of file recurrent_norm_kernels.c.
References bf16_to_float(), float_to_bf16(), recurrent_silu_forward_pytorch_bf16_input_fp32_output(), rmsnorm_forward_pytorch_bf16_storage(), and silu().
| void recurrent_norm_sigmoid_gate_llama_avx2_forward | ( | const float * | x, |
| const float * | gate, | ||
| const float * | weight, | ||
| float * | out, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
Definition at line 82 of file recurrent_norm_kernels.c.
References recurrent_sigmoid_forward_ggml(), and rmsnorm_forward_llama_production().
| void recurrent_norm_sigmoid_gate_pytorch_bf16_storage | ( | const float * | x, |
| const float * | gate, | ||
| const float * | weight, | ||
| float * | out, | ||
| int | rows, | ||
| int | num_heads, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
Definition at line 149 of file recurrent_norm_kernels.c.
References bf16_to_float(), float_to_bf16(), recurrent_sigmoid_forward_pytorch_bf16_input_fp32_output(), and rmsnorm_forward_pytorch_bf16_storage().
| void recurrent_qk_l2_norm_backward | ( | const float * | d_q_out, |
| const float * | d_k_out, | ||
| const float * | q, | ||
| const float * | k, | ||
| float * | d_q, | ||
| float * | d_k, | ||
| int | rows, | ||
| int | q_dim, | ||
| int | k_dim, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
Definition at line 383 of file recurrent_qk_norm_kernels.c.
References recurrent_l2_norm_rows_backward_one().
| void recurrent_qk_l2_norm_forward | ( | float * | q, |
| float * | k, | ||
| int | rows, | ||
| int | q_dim, | ||
| int | k_dim, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
Definition at line 86 of file recurrent_qk_norm_kernels.c.
References recurrent_l2_norm_rows_forward_one().
| void recurrent_qk_l2_norm_pytorch_bf16_storage | ( | float * | q, |
| float * | k, | ||
| int | rows, | ||
| int | q_dim, | ||
| int | k_dim, | ||
| int | expanded_heads, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
Definition at line 368 of file recurrent_qk_norm_kernels.c.
References recurrent_pytorch_bf16_l2_rows().
| void recurrent_qk_l2_norm_pytorch_fp32_output | ( | float * | q, |
| float * | k, | ||
| int | rows, | ||
| int | q_dim, | ||
| int | k_dim, | ||
| int | head_dim, | ||
| float | eps | ||
| ) |
Definition at line 246 of file recurrent_qk_norm_kernels.c.
References recurrent_pytorch_fp32_l2_rows().
| void recurrent_sigmoid_forward_ggml | ( | const float * | x, |
| float * | out, | ||
| int | rows, | ||
| int | dim | ||
| ) |
Definition at line 501 of file recurrent_gate_kernels.c.
Referenced by hyper_connection_mix_quantized(), and recurrent_norm_sigmoid_gate_llama_avx2_forward().
| void recurrent_sigmoid_forward_pytorch_bf16_input_fp32_output | ( | const float * | x, |
| float * | out, | ||
| int | rows, | ||
| int | dim | ||
| ) |
Definition at line 339 of file recurrent_gate_kernels.c.
References __attribute__(), bf16_to_float(), and float_to_bf16().
Referenced by attn_gate_sigmoid_mul_pytorch_bf16_storage(), and recurrent_norm_sigmoid_gate_pytorch_bf16_storage().
| void recurrent_silu_backward | ( | const float * | d_out, |
| const float * | x, | ||
| float * | d_x, | ||
| int | rows, | ||
| int | dim | ||
| ) |
Definition at line 515 of file recurrent_gate_kernels.c.
References recurrent_sigmoid().
| void recurrent_silu_forward | ( | const float * | x, |
| float * | out, | ||
| int | rows, | ||
| int | dim | ||
| ) |
Definition at line 137 of file recurrent_gate_kernels.c.
References recurrent_sigmoid().
| void recurrent_silu_forward_ggml | ( | const float * | x, |
| float * | out, | ||
| int | rows, | ||
| int | dim | ||
| ) |
Definition at line 468 of file recurrent_gate_kernels.c.
Referenced by hyper_connection_mix_quantized(), qwen4_ple_gate_conv_inject_impl(), and recurrent_norm_gate_llama_avx2_forward().
| void recurrent_silu_forward_pytorch_bf16_input_fp32_output | ( | const float * | x, |
| float * | out, | ||
| int | rows, | ||
| int | dim | ||
| ) |
Definition at line 299 of file recurrent_gate_kernels.c.
References __attribute__(), bf16_to_float(), and float_to_bf16().
Referenced by recurrent_norm_gate_pytorch_bf16_storage().
| void recurrent_silu_forward_pytorch_bf16_storage | ( | const float * | x, |
| float * | out, | ||
| int | rows, | ||
| int | dim | ||
| ) |
Definition at line 252 of file recurrent_gate_kernels.c.
References __attribute__(), bf16_to_float(), float_to_bf16(), and silu().
| void recurrent_split_conv_qkv_backward | ( | const float * | d_q, |
| const float * | d_k, | ||
| const float * | d_v, | ||
| float * | d_packed_qkv, | ||
| int | rows, | ||
| int | q_dim, | ||
| int | k_dim, | ||
| int | v_dim | ||
| ) |
Definition at line 108 of file recurrent_split_kernels.c.
References recurrent_split_qkv_backward().
| void recurrent_split_conv_qkv_forward | ( | const float * | packed_qkv, |
| float * | q, | ||
| float * | k, | ||
| float * | v, | ||
| int | rows, | ||
| int | q_dim, | ||
| int | k_dim, | ||
| int | v_dim | ||
| ) |
Definition at line 97 of file recurrent_split_kernels.c.
References recurrent_split_qkv_forward().
| void recurrent_split_qkv_backward | ( | const float * | d_q, |
| const float * | d_k, | ||
| const float * | d_v, | ||
| float * | d_packed_qkv, | ||
| int | rows, | ||
| int | q_dim, | ||
| int | k_dim, | ||
| int | v_dim | ||
| ) |
Definition at line 77 of file recurrent_split_kernels.c.
Referenced by recurrent_split_conv_qkv_backward().
| void recurrent_split_qkv_forward | ( | const float * | packed_qkv, |
| float * | q, | ||
| float * | k, | ||
| float * | v, | ||
| int | rows, | ||
| int | q_dim, | ||
| int | k_dim, | ||
| int | v_dim | ||
| ) |
Definition at line 5 of file recurrent_split_kernels.c.
| void relu2_backward | ( | const float * | input, |
| const float * | d_output, | ||
| float * | d_input, | ||
| size_t | n | ||
| ) |
Definition at line 147 of file relu_kernels.c.
References mask.
| void relu2_forward | ( | const float * | input, |
| float * | output, | ||
| size_t | n | ||
| ) |
Definition at line 120 of file relu_kernels.c.
| void relu_backward | ( | const float * | input, |
| const float * | d_output, | ||
| float * | d_input, | ||
| size_t | n | ||
| ) |
Definition at line 84 of file relu_kernels.c.
References mask.
| void relu_backward_bf16 | ( | const uint16_t * | input, |
| const uint16_t * | d_output, | ||
| uint16_t * | d_input, | ||
| size_t | n | ||
| ) |
Definition at line 69 of file relu_kernels_bf16.c.
References mask.
| void relu_forward | ( | const float * | input, |
| float * | output, | ||
| size_t | n | ||
| ) |
Definition at line 26 of file relu_kernels.c.
| void relu_forward_bf16 | ( | const uint16_t * | input, |
| uint16_t * | output, | ||
| size_t | n | ||
| ) |
Definition at line 27 of file relu_kernels_bf16.c.
References mask.
| void relu_forward_inplace | ( | float * | data, |
| size_t | n | ||
| ) |
Definition at line 54 of file relu_kernels.c.
| void relu_forward_inplace_bf16 | ( | uint16_t * | data, |
| size_t | n | ||
| ) |
Definition at line 48 of file relu_kernels_bf16.c.
References mask.
| void rmsnorm_backward | ( | const float * | d_output, |
| const float * | input, | ||
| const float * | gamma, | ||
| const float * | rstd_cache, | ||
| float * | d_input, | ||
| float * | d_gamma, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim | ||
| ) |
RMSNorm backward pass
test_rmsnorm.py::TestRMSNormBackward::test_backward_tokens
test_rmsnorm.py::TestRMSNormBackward::test_backward_single
test_parity.py::test_rmsnorm_backward_parity
Computes dX and dGamma given dY, X, gamma, and cached rstd. dX_i = rstd * (dY_i * gamma_i - x_hat_i * m) dGamma_i = sum_t (dY_i * x_hat_i)
After changes: make test && make llamacpp-parity-full
Definition at line 715 of file rmsnorm_kernels.c.
References ck_strict_parity_enabled(), and rmsnorm_backward_strict_scalar().
Referenced by ck_layer_backward_rmsnorm_swiglu(), rmsnorm_backward_int4(), and rmsnorm_backward_int8().
| void rmsnorm_backward_bf16 | ( | const uint16_t * | d_output, |
| const uint16_t * | input, | ||
| const float * | gamma, | ||
| const float * | rstd_cache, | ||
| uint16_t * | d_input, | ||
| float * | d_gamma, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim | ||
| ) |
Definition at line 113 of file rmsnorm_kernels_bf16.c.
References bf16_to_float(), and float_to_bf16().
| void rmsnorm_backward_int4 | ( | const uint8_t * | d_output, |
| const uint8_t * | input, | ||
| const float * | gamma, | ||
| const float * | rstd_cache, | ||
| uint8_t * | d_input, | ||
| float * | d_gamma, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim, | ||
| float * | scratch_d_output, | ||
| float * | scratch_input, | ||
| float * | scratch_d_input | ||
| ) |
Definition at line 104 of file rmsnorm_kernels_int4.c.
References convert_float_to_int4(), convert_int4_to_float(), and rmsnorm_backward().
| void rmsnorm_backward_int8 | ( | const int8_t * | d_output, |
| const int8_t * | input, | ||
| const float * | gamma, | ||
| const float * | rstd_cache, | ||
| int8_t * | d_input, | ||
| float * | d_gamma, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim, | ||
| float * | scratch_d_output, | ||
| float * | scratch_input, | ||
| float * | scratch_d_input | ||
| ) |
Definition at line 84 of file rmsnorm_kernels_int8.c.
References convert_float_to_int8(), convert_int8_to_float(), and rmsnorm_backward().
| void rmsnorm_forward | ( | const float * | input, |
| const float * | gamma, | ||
| float * | output, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim, | ||
| float | eps | ||
| ) |
Definition at line 621 of file rmsnorm_kernels.c.
References rmsnorm_forward_strided_f32().
Referenced by ck_layer_forward_rmsnorm_swiglu(), ck_layer_forward_rmsnorm_swiglu_decode(), ck_layer_forward_rmsnorm_swiglu_decode_fused(), ck_layer_forward_rmsnorm_swiglu_decode_fused_attn_impl(), ck_layer_forward_rmsnorm_swiglu_decode_q4_k(), ck_layer_forward_rmsnorm_swiglu_decode_quant(), ck_layer_forward_rmsnorm_swiglu_q4_k(), ck_layer_forward_rmsnorm_swiglu_quant(), ck_layer_forward_rmsnorm_swiglu_ref(), mega_fused_outproj_mlp_prefill(), model_decode_token(), model_decode_token(), model_decode_token(), model_decode_token(), model_forward_prefill_impl(), model_forward_prefill_impl(), model_forward_prefill_impl(), model_forward_prefill_impl(), model_layer_0_decode(), model_layer_0_decode(), model_layer_0_decode(), model_layer_0_decode(), model_layer_0_prefill(), model_layer_0_prefill(), model_layer_0_prefill(), model_layer_0_prefill(), model_layer_10_decode(), model_layer_10_decode(), model_layer_10_decode(), model_layer_10_decode(), model_layer_10_prefill(), model_layer_10_prefill(), model_layer_10_prefill(), model_layer_10_prefill(), model_layer_11_decode(), model_layer_11_decode(), model_layer_11_decode(), model_layer_11_decode(), model_layer_11_prefill(), model_layer_11_prefill(), model_layer_11_prefill(), model_layer_11_prefill(), model_layer_12_decode(), model_layer_12_decode(), model_layer_12_decode(), model_layer_12_decode(), model_layer_12_prefill(), model_layer_12_prefill(), model_layer_12_prefill(), model_layer_12_prefill(), model_layer_13_decode(), model_layer_13_decode(), model_layer_13_decode(), model_layer_13_decode(), model_layer_13_prefill(), model_layer_13_prefill(), model_layer_13_prefill(), model_layer_13_prefill(), model_layer_14_decode(), model_layer_14_decode(), model_layer_14_decode(), model_layer_14_decode(), model_layer_14_prefill(), model_layer_14_prefill(), model_layer_14_prefill(), model_layer_14_prefill(), model_layer_15_decode(), model_layer_15_decode(), model_layer_15_decode(), model_layer_15_decode(), model_layer_15_prefill(), model_layer_15_prefill(), model_layer_15_prefill(), model_layer_15_prefill(), model_layer_16_decode(), model_layer_16_decode(), model_layer_16_decode(), model_layer_16_decode(), model_layer_16_prefill(), model_layer_16_prefill(), model_layer_16_prefill(), model_layer_16_prefill(), model_layer_17_decode(), model_layer_17_decode(), model_layer_17_decode(), model_layer_17_decode(), model_layer_17_prefill(), model_layer_17_prefill(), model_layer_17_prefill(), model_layer_17_prefill(), model_layer_18_decode(), model_layer_18_decode(), model_layer_18_decode(), model_layer_18_decode(), model_layer_18_prefill(), model_layer_18_prefill(), model_layer_18_prefill(), model_layer_18_prefill(), model_layer_19_decode(), model_layer_19_decode(), model_layer_19_decode(), model_layer_19_decode(), model_layer_19_prefill(), model_layer_19_prefill(), model_layer_19_prefill(), model_layer_19_prefill(), model_layer_1_decode(), model_layer_1_decode(), model_layer_1_decode(), model_layer_1_decode(), model_layer_1_prefill(), model_layer_1_prefill(), model_layer_1_prefill(), model_layer_1_prefill(), model_layer_20_decode(), model_layer_20_decode(), model_layer_20_decode(), model_layer_20_decode(), model_layer_20_prefill(), model_layer_20_prefill(), model_layer_20_prefill(), model_layer_20_prefill(), model_layer_21_decode(), model_layer_21_decode(), model_layer_21_decode(), model_layer_21_decode(), model_layer_21_prefill(), model_layer_21_prefill(), model_layer_21_prefill(), model_layer_21_prefill(), model_layer_22_decode(), model_layer_22_decode(), model_layer_22_decode(), model_layer_22_decode(), model_layer_22_prefill(), model_layer_22_prefill(), model_layer_22_prefill(), model_layer_22_prefill(), model_layer_23_decode(), model_layer_23_decode(), model_layer_23_decode(), model_layer_23_decode(), model_layer_23_prefill(), model_layer_23_prefill(), model_layer_23_prefill(), model_layer_23_prefill(), model_layer_2_decode(), model_layer_2_decode(), model_layer_2_decode(), model_layer_2_decode(), model_layer_2_prefill(), model_layer_2_prefill(), model_layer_2_prefill(), model_layer_2_prefill(), model_layer_3_decode(), model_layer_3_decode(), model_layer_3_decode(), model_layer_3_decode(), model_layer_3_prefill(), model_layer_3_prefill(), model_layer_3_prefill(), model_layer_3_prefill(), model_layer_4_decode(), model_layer_4_decode(), model_layer_4_decode(), model_layer_4_decode(), model_layer_4_prefill(), model_layer_4_prefill(), model_layer_4_prefill(), model_layer_4_prefill(), model_layer_5_decode(), model_layer_5_decode(), model_layer_5_decode(), model_layer_5_decode(), model_layer_5_prefill(), model_layer_5_prefill(), model_layer_5_prefill(), model_layer_5_prefill(), model_layer_6_decode(), model_layer_6_decode(), model_layer_6_decode(), model_layer_6_decode(), model_layer_6_prefill(), model_layer_6_prefill(), model_layer_6_prefill(), model_layer_6_prefill(), model_layer_7_decode(), model_layer_7_decode(), model_layer_7_decode(), model_layer_7_decode(), model_layer_7_prefill(), model_layer_7_prefill(), model_layer_7_prefill(), model_layer_7_prefill(), model_layer_8_decode(), model_layer_8_decode(), model_layer_8_decode(), model_layer_8_decode(), model_layer_8_prefill(), model_layer_8_prefill(), model_layer_8_prefill(), model_layer_8_prefill(), model_layer_9_decode(), model_layer_9_decode(), model_layer_9_decode(), model_layer_9_decode(), model_layer_9_prefill(), model_layer_9_prefill(), model_layer_9_prefill(), model_layer_9_prefill(), qwen2_0_5b_decode_decode_token(), qwen2_0_5b_decode_decode_token(), qwen2_0_5b_decode_decode_token(), qwen2_0_5b_decode_decode_token(), qwen2_0_5b_decode_decode_token(), qwen2_0_5b_decode_forward_prefill_impl(), qwen2_0_5b_decode_forward_prefill_impl(), qwen2_0_5b_decode_forward_prefill_impl(), qwen2_0_5b_decode_forward_prefill_impl(), qwen2_0_5b_decode_forward_prefill_impl(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_9_decode(), qwen2_0_5b_decode_layer_9_decode(), qwen2_0_5b_decode_layer_9_decode(), qwen2_0_5b_decode_layer_9_decode(), qwen2_0_5b_decode_layer_9_decode(), qwen2_0_5b_decode_layer_9_prefill(), qwen2_0_5b_decode_layer_9_prefill(), qwen2_0_5b_decode_layer_9_prefill(), qwen2_0_5b_decode_layer_9_prefill(), rmsnorm_forward_int4(), and rmsnorm_forward_int8().
| void rmsnorm_forward_bf16 | ( | const uint16_t * | input, |
| const float * | gamma, | ||
| uint16_t * | output, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim, | ||
| float | eps | ||
| ) |
Definition at line 24 of file rmsnorm_kernels_bf16.c.
References bf16_to_float(), and float_to_bf16().
| void rmsnorm_forward_fp32_square_fp64_sum | ( | const float * | input, |
| const float * | gamma, | ||
| float * | output, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim, | ||
| float | eps | ||
| ) |
| void rmsnorm_forward_fp64_sum | ( | const float * | input, |
| const float * | gamma, | ||
| float * | output, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim, | ||
| float | eps | ||
| ) |
Definition at line 137 of file rmsnorm_kernels.c.
| void rmsnorm_forward_int4 | ( | const uint8_t * | input, |
| const float * | gamma, | ||
| uint8_t * | output, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim, | ||
| float | eps, | ||
| float * | scratch_input, | ||
| float * | scratch_output | ||
| ) |
Definition at line 78 of file rmsnorm_kernels_int4.c.
References convert_float_to_int4(), convert_int4_to_float(), and rmsnorm_forward().
| void rmsnorm_forward_int8 | ( | const int8_t * | input, |
| const float * | gamma, | ||
| int8_t * | output, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim, | ||
| float | eps, | ||
| float * | scratch_input, | ||
| float * | scratch_output | ||
| ) |
Definition at line 58 of file rmsnorm_kernels_int8.c.
References convert_float_to_int8(), convert_int8_to_float(), and rmsnorm_forward().
| void rmsnorm_forward_kv_lora | ( | const float * | input, |
| const float * | gamma, | ||
| float * | output, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim, | ||
| float | eps | ||
| ) |
Definition at line 643 of file rmsnorm_kernels.c.
References rmsnorm_forward().
| void rmsnorm_forward_llama_production | ( | const float * | input, |
| const float * | gamma, | ||
| float * | output, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim, | ||
| float | eps | ||
| ) |
Definition at line 196 of file rmsnorm_kernels.c.
References rmsnorm_llama_production_rstd().
Referenced by qwen4_group_rmsnorm_llama(), recurrent_norm_gate_llama_avx2_forward(), and recurrent_norm_sigmoid_gate_llama_avx2_forward().
| void rmsnorm_forward_no_weight | ( | const float * | input, |
| float * | output, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim, | ||
| float | eps | ||
| ) |
Definition at line 655 of file rmsnorm_kernels.c.
Referenced by gemma4_v_norm_forward().
| void rmsnorm_forward_parallel_dispatch | ( | const float * | input, |
| const float * | gamma, | ||
| float * | output, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim, | ||
| float | eps | ||
| ) |
| void rmsnorm_forward_pytorch_bf16_storage | ( | const float * | input, |
| const float * | gamma, | ||
| float * | output, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim, | ||
| float | eps | ||
| ) |
Definition at line 395 of file rmsnorm_kernels.c.
References rmsnorm_forward_pytorch_bf16_storage_impl().
Referenced by recurrent_norm_gate_pytorch_bf16_storage(), and recurrent_norm_sigmoid_gate_pytorch_bf16_storage().
| void rmsnorm_forward_qwen3next_pytorch_bf16_storage | ( | const float * | input, |
| const float * | gamma, | ||
| float * | output, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | aligned_embed_dim, | ||
| float | eps | ||
| ) |
Definition at line 424 of file rmsnorm_kernels.c.
References rmsnorm_forward_pytorch_bf16_storage_impl().
Referenced by hyper_connection_mix_bf16(), and qwen4_group_rmsnorm_pytorch_bf16().
| void rmsnorm_forward_strided_f32 | ( | const float * | input, |
| const float * | gamma, | ||
| float * | output, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | input_stride, | ||
| int | output_stride, | ||
| float | eps | ||
| ) |
RMSNorm forward pass
test_rmsnorm.py::TestRMSNormForward::test_fp32_tokens
test_rmsnorm.py::TestRMSNormForward::test_fp32_single
test_rmsnorm.py::TestRMSNormForward::test_perf_rolled
test_layernorm.py::TestLayerNormForward::test_rmsnorm_compat
test_parity.py::test_rmsnorm_parity
RMSNorm: y[i] = gamma[i] * x[i] / sqrt(mean(x^2) + eps)
After changes: make test && make llamacpp-parity-full
Definition at line 492 of file rmsnorm_kernels.c.
References ck_strict_parity_enabled(), and rmsnorm_forward_strict_scalar().
Referenced by rmsnorm_forward().
| void rmsnorm_forward_strided_pytorch_bf16_storage | ( | const float * | input, |
| const float * | gamma, | ||
| float * | output, | ||
| float * | rstd_cache, | ||
| int | tokens, | ||
| int | d_model, | ||
| int | input_stride, | ||
| int | output_stride, | ||
| float | eps | ||
| ) |
Definition at line 409 of file rmsnorm_kernels.c.
References rmsnorm_forward_pytorch_bf16_storage_impl().
| void rope_backward | ( | const float * | d_out, |
| float * | d_x, | ||
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset | ||
| ) |
RoPE backward (inverse rotation)
test_rope.py::TestRoPEBackward::test_rope_backward
test_rope.py::TestRoPEBackward::test_rope_backward_vs_separate
RoPE backward: inverse rotation (rotate by -θ). Since cos(-θ) = cos(θ) and sin(-θ) = -sin(θ): d_x[2i] = d0 * c + d1 * s d_x[2i+1] = -d0 * s + d1 * c
After changes: make test
Definition at line 884 of file rope_kernels.c.
Referenced by rope_backward_bf16(), and rope_backward_qk().
| void rope_backward_bf16 | ( | const uint16_t * | d_out, |
| uint16_t * | d_x, | ||
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| float * | scratch_d_out, | ||
| float * | scratch_d_x | ||
| ) |
Definition at line 67 of file rope_kernels_bf16.c.
References bf16_tensor_to_float(), float_tensor_to_bf16(), and rope_backward().
Referenced by rope_backward_qk_bf16().
| void rope_backward_inplace | ( | float * | d_x, |
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset | ||
| ) |
RoPE backward in-place (overwrite with inverse rotation)
In-place backward: overwrite d_out with inverse-rotated gradients. Useful when d_x == d_out is acceptable (saves memory).
After changes: make test
Definition at line 991 of file rope_kernels.c.
| void rope_backward_qk | ( | const float * | d_q_out, |
| const float * | d_k_out, | ||
| float * | d_q, | ||
| float * | d_k, | ||
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset | ||
| ) |
RoPE backward for both dQ and dK
Combined RoPE backward for both dQ and dK gradients.
After changes: make test
Definition at line 2826 of file rope_kernels.c.
References rope_backward().
Referenced by ck_layer_backward_rmsnorm_swiglu().
| void rope_backward_qk_bf16 | ( | const uint16_t * | d_q_out, |
| const uint16_t * | d_k_out, | ||
| uint16_t * | d_q, | ||
| uint16_t * | d_k, | ||
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| float * | scratch_dq_out, | ||
| float * | scratch_dq, | ||
| float * | scratch_dk_out, | ||
| float * | scratch_dk | ||
| ) |
Definition at line 139 of file rope_kernels_bf16.c.
References rope_backward_bf16().
| void rope_backward_qk_pairwise_with_rotary_dim | ( | const float * | d_q_out, |
| const float * | d_k_out, | ||
| float * | d_q, | ||
| float * | d_k, | ||
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | rotary_dim | ||
| ) |
Definition at line 2843 of file rope_kernels.c.
References rope_backward_apply_head_pairwise().
| void rope_forward | ( | float * | x, |
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset | ||
| ) |
RoPE forward (head-major layout, in-place)
test_rope.py::TestRoPEForward::test_rope_forward
test_rope.py::TestRoPEForward::test_rope_vs_separate
test_parity.py::test_rope_parity
Applies rotary position embeddings in-place to Q or K tensor. x: [num_heads, num_tokens, head_dim] head-major
After changes: make test && make llamacpp-parity-full
Definition at line 796 of file rope_kernels.c.
References rope_forward_with_rotary_dim().
Referenced by model_layer_0_decode(), model_layer_0_decode(), model_layer_0_decode(), model_layer_0_decode(), model_layer_10_decode(), model_layer_10_decode(), model_layer_10_decode(), model_layer_10_decode(), model_layer_11_decode(), model_layer_11_decode(), model_layer_11_decode(), model_layer_11_decode(), model_layer_12_decode(), model_layer_12_decode(), model_layer_12_decode(), model_layer_12_decode(), model_layer_13_decode(), model_layer_13_decode(), model_layer_13_decode(), model_layer_13_decode(), model_layer_14_decode(), model_layer_14_decode(), model_layer_14_decode(), model_layer_14_decode(), model_layer_15_decode(), model_layer_15_decode(), model_layer_15_decode(), model_layer_15_decode(), model_layer_16_decode(), model_layer_16_decode(), model_layer_16_decode(), model_layer_16_decode(), model_layer_17_decode(), model_layer_17_decode(), model_layer_17_decode(), model_layer_17_decode(), model_layer_18_decode(), model_layer_18_decode(), model_layer_18_decode(), model_layer_18_decode(), model_layer_19_decode(), model_layer_19_decode(), model_layer_19_decode(), model_layer_19_decode(), model_layer_1_decode(), model_layer_1_decode(), model_layer_1_decode(), model_layer_1_decode(), model_layer_20_decode(), model_layer_20_decode(), model_layer_20_decode(), model_layer_20_decode(), model_layer_21_decode(), model_layer_21_decode(), model_layer_21_decode(), model_layer_21_decode(), model_layer_22_decode(), model_layer_22_decode(), model_layer_22_decode(), model_layer_22_decode(), model_layer_23_decode(), model_layer_23_decode(), model_layer_23_decode(), model_layer_23_decode(), model_layer_2_decode(), model_layer_2_decode(), model_layer_2_decode(), model_layer_2_decode(), model_layer_3_decode(), model_layer_3_decode(), model_layer_3_decode(), model_layer_3_decode(), model_layer_4_decode(), model_layer_4_decode(), model_layer_4_decode(), model_layer_4_decode(), model_layer_5_decode(), model_layer_5_decode(), model_layer_5_decode(), model_layer_5_decode(), model_layer_6_decode(), model_layer_6_decode(), model_layer_6_decode(), model_layer_6_decode(), model_layer_7_decode(), model_layer_7_decode(), model_layer_7_decode(), model_layer_7_decode(), model_layer_8_decode(), model_layer_8_decode(), model_layer_8_decode(), model_layer_8_decode(), model_layer_9_decode(), model_layer_9_decode(), model_layer_9_decode(), model_layer_9_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_9_decode(), and qwen2_0_5b_decode_layer_9_decode().
| void rope_forward_bf16 | ( | uint16_t * | x, |
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| float * | scratch | ||
| ) |
Definition at line 28 of file rope_kernels_bf16.c.
References rope_forward_bf16_with_rotary_dim().
| void rope_forward_bf16_with_rotary_dim | ( | uint16_t * | x, |
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | rotary_dim, | ||
| float * | scratch | ||
| ) |
Definition at line 42 of file rope_kernels_bf16.c.
References bf16_tensor_to_float(), float_tensor_to_bf16(), and rope_forward_with_rotary_dim().
Referenced by rope_forward_bf16(), and rope_forward_qk_bf16_with_rotary_dim().
| void rope_forward_q_split_direct_f32 | ( | float * | q, |
| const float * | freq_factors, | ||
| int | use_freq_factors, | ||
| int | num_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | rotary_dim, | ||
| float | freq_base | ||
| ) |
Definition at line 1301 of file rope_kernels.c.
References rope_forward_split_direct_one().
| void rope_forward_qk | ( | float * | q, |
| float * | k, | ||
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset | ||
| ) |
RoPE forward for both Q and K (common inference pattern)
test_rope.py::TestRoPEForward::test_rope_forward_qk
test_fused_attention_decode.py::TestFusedAttentionDecode::test_qk_rope
test_parity.py::test_rope_qk_parity
Combined RoPE forward for both Q and K in one call. q: [num_heads, num_tokens, head_dim] k: [num_kv_heads, num_tokens, head_dim]
After changes: make test && make llamacpp-parity-full
Definition at line 1094 of file rope_kernels.c.
References rope_forward_qk_with_rotary_dim().
Referenced by ck_layer_forward_rmsnorm_swiglu(), ck_layer_forward_rmsnorm_swiglu_decode(), ck_layer_forward_rmsnorm_swiglu_decode_fused(), ck_layer_forward_rmsnorm_swiglu_decode_fused_attn_impl(), ck_layer_forward_rmsnorm_swiglu_decode_q4_k(), ck_layer_forward_rmsnorm_swiglu_decode_quant(), ck_layer_forward_rmsnorm_swiglu_q4_k(), ck_layer_forward_rmsnorm_swiglu_quant(), ck_layer_forward_rmsnorm_swiglu_ref(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_9_decode(), qwen2_0_5b_decode_layer_9_decode(), qwen2_0_5b_decode_layer_9_decode(), qwen2_0_5b_decode_layer_9_prefill(), and qwen2_0_5b_decode_layer_9_prefill().
| void rope_forward_qk_bf16 | ( | uint16_t * | q, |
| uint16_t * | k, | ||
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| float * | scratch_q, | ||
| float * | scratch_k | ||
| ) |
Definition at line 94 of file rope_kernels_bf16.c.
References rope_forward_qk_bf16_with_rotary_dim().
| void rope_forward_qk_bf16_with_rotary_dim | ( | uint16_t * | q, |
| uint16_t * | k, | ||
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | rotary_dim, | ||
| float * | scratch_q, | ||
| float * | scratch_k | ||
| ) |
Definition at line 112 of file rope_kernels_bf16.c.
References rope_forward_bf16_with_rotary_dim().
Referenced by rope_forward_qk_bf16().
| void rope_forward_qk_gemma4_direct | ( | float * | q, |
| float * | k, | ||
| const float * | freq_factors, | ||
| int | use_freq_factors, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | rotary_dim, | ||
| float | freq_base | ||
| ) |
Definition at line 1317 of file rope_kernels.c.
References rope_forward_qk_split_direct_f32().
| void rope_forward_qk_gemma4v_vision_xy | ( | float * | q, |
| float * | k, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | grid_w, | ||
| int | rotary_dim, | ||
| float | freq_base | ||
| ) |
Definition at line 1404 of file rope_kernels.c.
References rope_forward_gemma4v_vision_xy_one().
| void rope_forward_qk_pairwise_llama_cpu | ( | float * | q, |
| float * | k, | ||
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | rotary_dim | ||
| ) |
Definition at line 1540 of file rope_kernels.c.
References rope_apply_decode_pairwise_llama_cpu(), and token.
| void rope_forward_qk_pairwise_with_rotary_dim | ( | float * | q, |
| float * | k, | ||
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | rotary_dim | ||
| ) |
Definition at line 1483 of file rope_kernels.c.
References rope_apply_head_pairwise().
| void rope_forward_qk_split_direct_f32 | ( | float * | q, |
| float * | k, | ||
| const float * | freq_factors, | ||
| int | use_freq_factors, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | rotary_dim, | ||
| float | freq_base | ||
| ) |
Definition at line 1180 of file rope_kernels.c.
References rope_forward_split_direct_one().
Referenced by rope_forward_qk_gemma4_direct().
| void rope_forward_qk_split_direct_token_range_f32 | ( | float * | q, |
| float * | k, | ||
| const float * | freq_factors, | ||
| int | use_freq_factors, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | rotary_dim, | ||
| float | freq_base, | ||
| int | token_begin, | ||
| int | token_end | ||
| ) |
Definition at line 1201 of file rope_kernels.c.
| void rope_forward_qk_split_llama_token_range_f32 | ( | float * | q, |
| float * | k, | ||
| const float * | freq_factors, | ||
| int | use_freq_factors, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | rotary_dim, | ||
| float | freq_base, | ||
| int | token_begin, | ||
| int | token_end | ||
| ) |
Definition at line 1265 of file rope_kernels.c.
References ck_rope_reference_cosf(), ck_rope_reference_powf(), and ck_rope_reference_sinf().
| void rope_forward_qk_strided | ( | float * | q, |
| float * | k, | ||
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | q_stride_tokens, | ||
| int | k_stride_tokens | ||
| ) |
RoPE forward for both Q and K with custom strides (KV cache layouts)
test_rope.py::TestRoPEForward::test_rope_forward_qk_strided
test_kv_cache_attention.py::TestKVCacheAttention::test_qk_rope_strided
Combined QK RoPE with configurable strides for KV cache layouts.
After changes: make test
Definition at line 2778 of file rope_kernels.c.
References rope_forward_qk_strided_with_rotary_dim().
Referenced by mega_fused_attention_prefill(), mega_fused_attention_prefill_q8_0(), model_layer_0_prefill(), model_layer_0_prefill(), model_layer_0_prefill(), model_layer_0_prefill(), model_layer_10_prefill(), model_layer_10_prefill(), model_layer_10_prefill(), model_layer_10_prefill(), model_layer_11_prefill(), model_layer_11_prefill(), model_layer_11_prefill(), model_layer_11_prefill(), model_layer_12_prefill(), model_layer_12_prefill(), model_layer_12_prefill(), model_layer_12_prefill(), model_layer_13_prefill(), model_layer_13_prefill(), model_layer_13_prefill(), model_layer_13_prefill(), model_layer_14_prefill(), model_layer_14_prefill(), model_layer_14_prefill(), model_layer_14_prefill(), model_layer_15_prefill(), model_layer_15_prefill(), model_layer_15_prefill(), model_layer_15_prefill(), model_layer_16_prefill(), model_layer_16_prefill(), model_layer_16_prefill(), model_layer_16_prefill(), model_layer_17_prefill(), model_layer_17_prefill(), model_layer_17_prefill(), model_layer_17_prefill(), model_layer_18_prefill(), model_layer_18_prefill(), model_layer_18_prefill(), model_layer_18_prefill(), model_layer_19_prefill(), model_layer_19_prefill(), model_layer_19_prefill(), model_layer_19_prefill(), model_layer_1_prefill(), model_layer_1_prefill(), model_layer_1_prefill(), model_layer_1_prefill(), model_layer_20_prefill(), model_layer_20_prefill(), model_layer_20_prefill(), model_layer_20_prefill(), model_layer_21_prefill(), model_layer_21_prefill(), model_layer_21_prefill(), model_layer_21_prefill(), model_layer_22_prefill(), model_layer_22_prefill(), model_layer_22_prefill(), model_layer_22_prefill(), model_layer_23_prefill(), model_layer_23_prefill(), model_layer_23_prefill(), model_layer_23_prefill(), model_layer_2_prefill(), model_layer_2_prefill(), model_layer_2_prefill(), model_layer_2_prefill(), model_layer_3_prefill(), model_layer_3_prefill(), model_layer_3_prefill(), model_layer_3_prefill(), model_layer_4_prefill(), model_layer_4_prefill(), model_layer_4_prefill(), model_layer_4_prefill(), model_layer_5_prefill(), model_layer_5_prefill(), model_layer_5_prefill(), model_layer_5_prefill(), model_layer_6_prefill(), model_layer_6_prefill(), model_layer_6_prefill(), model_layer_6_prefill(), model_layer_7_prefill(), model_layer_7_prefill(), model_layer_7_prefill(), model_layer_7_prefill(), model_layer_8_prefill(), model_layer_8_prefill(), model_layer_8_prefill(), model_layer_8_prefill(), model_layer_9_prefill(), model_layer_9_prefill(), model_layer_9_prefill(), model_layer_9_prefill(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_9_prefill(), and qwen2_0_5b_decode_layer_9_prefill().
| void rope_forward_qk_strided_with_rotary_dim | ( | float * | q, |
| float * | k, | ||
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | q_stride_tokens, | ||
| int | k_stride_tokens, | ||
| int | rotary_dim | ||
| ) |
Definition at line 2796 of file rope_kernels.c.
References rope_forward_strided_with_rotary_dim().
Referenced by rope_forward_qk_strided().
| void rope_forward_qk_with_rotary_dim | ( | float * | q, |
| float * | k, | ||
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | rotary_dim | ||
| ) |
Definition at line 1109 of file rope_kernels.c.
References rope_forward_with_rotary_dim().
Referenced by rope_forward_qk().
| void rope_forward_qk_with_rotary_dim_cache_stride | ( | float * | q, |
| float * | k, | ||
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_kv_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | rotary_dim, | ||
| int | cache_rotary_dim | ||
| ) |
Definition at line 1419 of file rope_kernels.c.
| void rope_forward_strided | ( | float * | x, |
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | head_stride_tokens | ||
| ) |
RoPE forward with custom head stride (for KV cache layouts)
test_rope.py::TestRoPEForward::test_rope_strided
test_kv_cache_attention.py::TestKVCacheAttention::test_rope_decode
Variant with configurable head_stride_tokens for non-contiguous head layouts.
After changes: make test
Definition at line 837 of file rope_kernels.c.
References rope_forward_strided_with_rotary_dim().
| void rope_forward_strided_with_rotary_dim | ( | float * | x, |
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | head_stride_tokens, | ||
| int | rotary_dim | ||
| ) |
Definition at line 852 of file rope_kernels.c.
References rope_apply_head().
Referenced by rope_forward_qk_strided_with_rotary_dim(), and rope_forward_strided().
| void rope_forward_with_rotary_dim | ( | float * | x, |
| const float * | cos_cache, | ||
| const float * | sin_cache, | ||
| int | num_heads, | ||
| int | num_tokens, | ||
| int | head_dim, | ||
| int | aligned_head_dim, | ||
| int | pos_offset, | ||
| int | rotary_dim | ||
| ) |
Definition at line 809 of file rope_kernels.c.
References rope_apply_head().
Referenced by rope_forward(), rope_forward_bf16_with_rotary_dim(), and rope_forward_qk_with_rotary_dim().
| void rope_precompute_cache | ( | float * | cos_cache, |
| float * | sin_cache, | ||
| int | max_seq_len, | ||
| int | head_dim, | ||
| float | base, | ||
| int | rotary_dim, | ||
| const char * | scaling_type, | ||
| float | scaling_factor | ||
| ) |
Precompute RoPE cos/sin cache with rotary_dim and scaling support
test_rope.py::TestRoPECache::test_cache_computation
test_rope.py::TestRoPECache::test_cache_values
Precomputes cos(m * theta_i) and sin(m * theta_i) for positions 0..max_seq_len-1. Only computes for first rotary_dim channels; remaining head_dim - rotary_dim channels are NOT rotated (pass through unchanged).
Scaling types:
| cos_cache | Output: [max_seq_len, rotary_dim/2] cos values |
| sin_cache | Output: [max_seq_len, rotary_dim/2] sin values |
| max_seq_len | Maximum sequence length for cache |
| head_dim | Full head dimension (for frequency computation) |
| base | RoPE base frequency (theta) |
| rotary_dim | Number of dimensions to rotate (0 = use head_dim) |
| scaling_type | Scaling type string: "none", "linear", "dynamic", "yarn" |
| scaling_factor | Scaling factor (1.0 = no scaling) |
After changes: make test
Definition at line 384 of file rope_kernels.c.
| void rope_precompute_cache_llama_cpu | ( | float * | cos_cache, |
| float * | sin_cache, | ||
| int | max_seq_len, | ||
| int | head_dim, | ||
| float | base, | ||
| int | rotary_dim, | ||
| const char * | scaling_type, | ||
| float | scaling_factor | ||
| ) |
Definition at line 560 of file rope_kernels.c.
References ck_rope_reference_cosf(), ck_rope_reference_powf(), and ck_rope_reference_sinf().
| void rope_precompute_cache_split | ( | float * | cos_cache, |
| float * | sin_cache, | ||
| int | max_seq_len, | ||
| int | head_dim, | ||
| float | base | ||
| ) |
Precompute RoPE cos/sin cache (split layout: head_dim/2) Legacy layout used before rotary_dim/scaling support.
| cos_cache | Output: [max_seq_len, head_dim/2] cos values |
| sin_cache | Output: [max_seq_len, head_dim/2] sin values |
| max_seq_len | Maximum sequence length for cache |
| head_dim | Full head dimension |
| base | RoPE base frequency (theta) |
Definition at line 340 of file rope_kernels.c.
| void rowwise_bias_add | ( | float * | x, |
| const float * | bias, | ||
| int | rows, | ||
| int | dim | ||
| ) |
Definition at line 696 of file vision_kernels.c.
| 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 sigmoid_backward | ( | const float * | input, |
| const float * | d_output, | ||
| float * | d_input, | ||
| size_t | n | ||
| ) |
Definition at line 138 of file sigmoid_kernels.c.
References sigmoid_scalar().
Referenced by sigmoid_backward_bf16().
| void sigmoid_backward_bf16 | ( | const uint16_t * | input, |
| const uint16_t * | d_output, | ||
| uint16_t * | d_input, | ||
| size_t | n, | ||
| float * | scratch_input, | ||
| float * | scratch_d_output, | ||
| float * | scratch_d_input | ||
| ) |
Definition at line 45 of file sigmoid_kernels_bf16.c.
References bf16_tensor_to_float(), float_tensor_to_bf16(), and sigmoid_backward().
| void sigmoid_forward | ( | const float * | input, |
| float * | output, | ||
| size_t | n | ||
| ) |
Definition at line 122 of file sigmoid_kernels.c.
References sigmoid_scalar().
Referenced by sigmoid_forward_bf16().
| void sigmoid_forward_bf16 | ( | const uint16_t * | input, |
| uint16_t * | output, | ||
| size_t | n, | ||
| float * | scratch_input, | ||
| float * | scratch_output | ||
| ) |
Definition at line 27 of file sigmoid_kernels_bf16.c.
References bf16_tensor_to_float(), float_tensor_to_bf16(), and sigmoid_forward().
| float sigmoid_scalar | ( | float | x | ) |
Definition at line 26 of file sigmoid_kernels.c.
Referenced by sigmoid_backward(), sigmoid_forward(), swiglu_backward(), swiglu_backward_bf16(), swiglu_forward(), swiglu_forward_bf16(), and swiglu_forward_q8_k().
| void softmax_cross_entropy_loss | ( | const float * | logits, |
| const int32_t * | targets, | ||
| int | tokens, | ||
| int | vocab_size, | ||
| float * | d_logits, | ||
| float * | loss_out | ||
| ) |
Definition at line 259 of file loss_kernels.c.
References ce_legacy_mode_enabled(), ce_targets_all_valid_no_ignore(), softmax_cross_entropy_loss_index_mean_impl(), softmax_cross_entropy_loss_legacy_mean_impl(), and vocab_size.
Referenced by softmax_cross_entropy_loss_bf16().
| void softmax_cross_entropy_loss_bf16 | ( | const uint16_t * | logits, |
| const int32_t * | targets, | ||
| int | tokens, | ||
| int | vocab_size, | ||
| uint16_t * | d_logits, | ||
| float * | loss_out, | ||
| float * | scratch_logits, | ||
| float * | scratch_d_logits | ||
| ) |
Definition at line 25 of file loss_kernels_bf16.c.
References bf16_tensor_to_float(), float_tensor_to_bf16(), softmax_cross_entropy_loss(), and vocab_size.
| void softmax_cross_entropy_loss_ptref | ( | const float * | logits, |
| const int32_t * | targets, | ||
| int | tokens, | ||
| int | vocab_size, | ||
| float * | d_logits, | ||
| float * | loss_out | ||
| ) |
Definition at line 292 of file loss_kernels.c.
References softmax_cross_entropy_loss_index_mean_impl(), and vocab_size.
| void spatial_average_pool_contiguous | ( | const float * | input, |
| float * | output, | ||
| int | grid_h, | ||
| int | grid_w, | ||
| int | embed_dim, | ||
| int | merge_size | ||
| ) |
Definition at line 657 of file vision_kernels.c.
| void spatial_merge_2x2 | ( | const float * | input, |
| float * | output, | ||
| int | grid_h, | ||
| int | grid_w, | ||
| int | embed_dim | ||
| ) |
Merge 2x2 neighboring tokens into a single wider token.
Input layout: [grid_h * grid_w, embed_dim] Output layout: [(grid_h/2) * (grid_w/2), embed_dim * 4]
Pack order within each merged token: top-left, top-right, bottom-left, bottom-right
Definition at line 577 of file vision_kernels.c.
| void spatial_merge_contiguous_tiled | ( | const float * | input, |
| float * | output, | ||
| int | grid_h, | ||
| int | grid_w, | ||
| int | embed_dim, | ||
| int | merge_size | ||
| ) |
Definition at line 616 of file vision_kernels.c.
| void speculative_commit_one_i32 | ( | int | accepted, |
| int | verified_token, | ||
| int * | token_buffer, | ||
| int * | token_count, | ||
| int | max_tokens, | ||
| int * | target_position, | ||
| int * | draft_position, | ||
| int * | accepted_count, | ||
| int * | rejected_count | ||
| ) |
Commit one verified speculative token and update decode counters.
This is the minimal state transition for the first Gemma4 assistant bridge: greedy, one draft token, target remains authoritative. For this milestone the draft cache is kept synchronized with the target position after each token. Multi-token speculative decoding can later replace this with prefix accept and partial draft-cache rollback.
Definition at line 611 of file topk_kernels.c.
| void speculative_verify_greedy_f32 | ( | const float * | target_logits, |
| int | vocab_size, | ||
| int | draft_token, | ||
| int * | accepted, | ||
| int * | verified_token | ||
| ) |
Greedy one-token speculative verification.
The draft model proposes draft_token. The target model is authoritative: if draft_token equals argmax(target_logits), the candidate is accepted and emitted. Otherwise the target argmax is emitted and the draft path must be reset or rewound by the runtime loop.
| target_logits | Target/backbone logits [vocab_size] |
| vocab_size | Number of logits |
| draft_token | Candidate token from draft/assistant model |
| accepted | Output scalar: 1 if accepted, 0 otherwise |
| verified_token | Output scalar: accepted draft token or target argmax |
Definition at line 585 of file topk_kernels.c.
References argmax_f32(), and vocab_size.
| void split_q_gate_backward | ( | const float * | d_q, |
| const float * | d_gate, | ||
| float * | d_packed_qg, | ||
| int | rows, | ||
| int | q_dim, | ||
| int | gate_dim, | ||
| int | group_dim | ||
| ) |
Definition at line 77 of file hybrid_attention_kernels.c.
| void split_q_gate_forward | ( | const float * | packed_qg, |
| float * | q, | ||
| float * | gate, | ||
| int | rows, | ||
| int | q_dim, | ||
| int | gate_dim, | ||
| int | group_dim | ||
| ) |
Definition at line 38 of file hybrid_attention_kernels.c.
| void split_qkv_packed_head_major_forward | ( | const float * | packed_qkv, |
| float * | q, | ||
| float * | k, | ||
| float * | v, | ||
| int | rows, | ||
| int | q_dim, | ||
| int | k_dim, | ||
| int | v_dim, | ||
| int | num_heads, | ||
| int | num_kv_heads | ||
| ) |
Definition at line 25 of file recurrent_split_kernels.c.
| void ssm_conv1d_backward | ( | const float * | d_out, |
| const float * | conv_x, | ||
| const float * | kernel, | ||
| float * | d_conv_x, | ||
| float * | d_kernel, | ||
| int | kernel_size, | ||
| int | num_channels, | ||
| int | num_tokens, | ||
| int | num_seqs | ||
| ) |
Definition at line 316 of file ssm_kernels.c.
References ssm_conv1d_backward_ref().
| void ssm_conv1d_forward | ( | const float * | conv_x, |
| const float * | kernel, | ||
| float * | out, | ||
| int | kernel_size, | ||
| int | num_channels, | ||
| int | num_tokens, | ||
| int | num_seqs | ||
| ) |
Definition at line 128 of file ssm_kernels.c.
References ssm_conv1d_forward_ref().
| void ssm_conv1d_forward_llama_fma | ( | const float * | conv_x, |
| const float * | kernel, | ||
| float * | out, | ||
| int | kernel_size, | ||
| int | num_channels, | ||
| int | num_tokens, | ||
| int | num_seqs | ||
| ) |
Definition at line 272 of file ssm_kernels.c.
References ck_ssm_conv1d_llama_fma_channel_range(), ck_threadpool_global(), ck_threadpool_n_threads(), and ck_threadpool_parallel_for_n().
| void ssm_conv1d_forward_llama_production | ( | const float * | conv_x, |
| const float * | kernel, | ||
| float * | out, | ||
| int | kernel_size, | ||
| int | num_channels, | ||
| int | num_tokens, | ||
| int | num_seqs | ||
| ) |
Definition at line 207 of file ssm_kernels.c.
References ck_ssm_conv1d_llama_channel_range(), ck_threadpool_global(), ck_threadpool_n_threads(), and ck_threadpool_parallel_for_n().
| void ssm_conv1d_forward_llama_production_serial | ( | const float * | conv_x, |
| const float * | kernel, | ||
| float * | out, | ||
| int | kernel_size, | ||
| int | num_channels, | ||
| int | num_tokens, | ||
| int | num_seqs | ||
| ) |
Definition at line 189 of file ssm_kernels.c.
References ck_ssm_conv1d_llama_channel_range().
| void ssm_conv1d_forward_pytorch_bf16_storage | ( | const float * | conv_x, |
| const float * | kernel, | ||
| float * | out, | ||
| int | kernel_size, | ||
| int | num_channels, | ||
| int | num_tokens, | ||
| int | num_seqs | ||
| ) |
Definition at line 299 of file ssm_kernels.c.
References bf16_to_float(), float_to_bf16(), and ssm_conv1d_forward_ref().
| void swiglu_backward | ( | const float * | input, |
| const float * | d_output, | ||
| float * | d_input, | ||
| int | tokens, | ||
| int | dim | ||
| ) |
SwiGLU backward pass
test_swiglu.py::TestSwiGLUBackward::test_backward_tokens
test_swiglu.py::TestSwiGLUBackward::test_backward_single
test_parity.py::test_swiglu_backward_parity
Computes dGate and dUp given dY. dGate = dy * b * silu'(a), dUp = dy * silu(a)
After changes: make test && make llamacpp-parity-full
Definition at line 386 of file swiglu_kernels.c.
References __attribute__(), ck_strict_parity_enabled(), sigmoid_scalar(), silu(), and swiglu_backward_exact().
Referenced by ck_layer_backward_rmsnorm_swiglu().
| void swiglu_backward_bf16 | ( | const uint16_t * | input, |
| const uint16_t * | d_output, | ||
| uint16_t * | d_input, | ||
| int | tokens, | ||
| int | dim | ||
| ) |
Definition at line 108 of file swiglu_kernels_bf16.c.
References bf16_to_float(), float_to_bf16(), sigmoid_scalar(), and silu().
| void swiglu_backward_exact | ( | const float * | input, |
| const float * | d_output, | ||
| float * | d_input, | ||
| int | tokens, | ||
| int | dim | ||
| ) |
SwiGLU backward pass (exact version using stdlib sigmoid)
test_swiglu.py::TestSwiGLUBackward::test_exact_vs_fast
test_swiglu.py::TestSwiGLUBackward::test_exact_single
Uses standard library expf for numerical accuracy reference.
After changes: make test
Definition at line 719 of file swiglu_kernels.c.
References sigmoid_scalar_parity(), and silu().
Referenced by swiglu_backward().
| void swiglu_forward | ( | const float * | input, |
| float * | output, | ||
| int | tokens, | ||
| int | dim | ||
| ) |
SwiGLU forward pass
test_swiglu.py::TestSwiGLUForward::test_forward_tokens
test_swiglu.py::TestSwiGLUForward::test_forward_single
test_mlp.py::TestMLPForward::test_swiglu_mlp
test_fused_swiglu_decode.py::TestFusedSwiGLUDecode::test_fused_swiglu_decode
test_parity.py::test_swiglu_parity
SwiGLU: y = silu(gate) * up where silu(x) = x * sigmoid(x)
After changes: make test && make llamacpp-parity-full
Definition at line 237 of file swiglu_kernels.c.
References __attribute__(), ck_strict_parity_enabled(), sigmoid_scalar(), silu(), and swiglu_forward_exact().
Referenced by ck_mlp_swiglu_forward(), ck_mlp_swiglu_forward_q4_k(), ck_mlp_swiglu_forward_q4_k_q8_k(), ck_mlp_swiglu_forward_q4_k_q8_k_prefill(), ck_mlp_swiglu_forward_quant(), ck_mlp_swiglu_forward_ref(), model_layer_0_decode(), model_layer_0_decode(), model_layer_0_decode(), model_layer_0_decode(), model_layer_0_prefill(), model_layer_0_prefill(), model_layer_0_prefill(), model_layer_0_prefill(), model_layer_10_decode(), model_layer_10_decode(), model_layer_10_decode(), model_layer_10_decode(), model_layer_10_prefill(), model_layer_10_prefill(), model_layer_10_prefill(), model_layer_10_prefill(), model_layer_11_decode(), model_layer_11_decode(), model_layer_11_decode(), model_layer_11_decode(), model_layer_11_prefill(), model_layer_11_prefill(), model_layer_11_prefill(), model_layer_11_prefill(), model_layer_12_decode(), model_layer_12_decode(), model_layer_12_decode(), model_layer_12_decode(), model_layer_12_prefill(), model_layer_12_prefill(), model_layer_12_prefill(), model_layer_12_prefill(), model_layer_13_decode(), model_layer_13_decode(), model_layer_13_decode(), model_layer_13_decode(), model_layer_13_prefill(), model_layer_13_prefill(), model_layer_13_prefill(), model_layer_13_prefill(), model_layer_14_decode(), model_layer_14_decode(), model_layer_14_decode(), model_layer_14_decode(), model_layer_14_prefill(), model_layer_14_prefill(), model_layer_14_prefill(), model_layer_14_prefill(), model_layer_15_decode(), model_layer_15_decode(), model_layer_15_decode(), model_layer_15_decode(), model_layer_15_prefill(), model_layer_15_prefill(), model_layer_15_prefill(), model_layer_15_prefill(), model_layer_16_decode(), model_layer_16_decode(), model_layer_16_decode(), model_layer_16_decode(), model_layer_16_prefill(), model_layer_16_prefill(), model_layer_16_prefill(), model_layer_16_prefill(), model_layer_17_decode(), model_layer_17_decode(), model_layer_17_decode(), model_layer_17_decode(), model_layer_17_prefill(), model_layer_17_prefill(), model_layer_17_prefill(), model_layer_17_prefill(), model_layer_18_decode(), model_layer_18_decode(), model_layer_18_decode(), model_layer_18_decode(), model_layer_18_prefill(), model_layer_18_prefill(), model_layer_18_prefill(), model_layer_18_prefill(), model_layer_19_decode(), model_layer_19_decode(), model_layer_19_decode(), model_layer_19_decode(), model_layer_19_prefill(), model_layer_19_prefill(), model_layer_19_prefill(), model_layer_19_prefill(), model_layer_1_decode(), model_layer_1_decode(), model_layer_1_decode(), model_layer_1_decode(), model_layer_1_prefill(), model_layer_1_prefill(), model_layer_1_prefill(), model_layer_1_prefill(), model_layer_20_decode(), model_layer_20_decode(), model_layer_20_decode(), model_layer_20_decode(), model_layer_20_prefill(), model_layer_20_prefill(), model_layer_20_prefill(), model_layer_20_prefill(), model_layer_21_decode(), model_layer_21_decode(), model_layer_21_decode(), model_layer_21_decode(), model_layer_21_prefill(), model_layer_21_prefill(), model_layer_21_prefill(), model_layer_21_prefill(), model_layer_22_decode(), model_layer_22_decode(), model_layer_22_decode(), model_layer_22_decode(), model_layer_22_prefill(), model_layer_22_prefill(), model_layer_22_prefill(), model_layer_22_prefill(), model_layer_23_decode(), model_layer_23_decode(), model_layer_23_decode(), model_layer_23_decode(), model_layer_23_prefill(), model_layer_23_prefill(), model_layer_23_prefill(), model_layer_23_prefill(), model_layer_2_decode(), model_layer_2_decode(), model_layer_2_decode(), model_layer_2_decode(), model_layer_2_prefill(), model_layer_2_prefill(), model_layer_2_prefill(), model_layer_2_prefill(), model_layer_3_decode(), model_layer_3_decode(), model_layer_3_decode(), model_layer_3_decode(), model_layer_3_prefill(), model_layer_3_prefill(), model_layer_3_prefill(), model_layer_3_prefill(), model_layer_4_decode(), model_layer_4_decode(), model_layer_4_decode(), model_layer_4_decode(), model_layer_4_prefill(), model_layer_4_prefill(), model_layer_4_prefill(), model_layer_4_prefill(), model_layer_5_decode(), model_layer_5_decode(), model_layer_5_decode(), model_layer_5_decode(), model_layer_5_prefill(), model_layer_5_prefill(), model_layer_5_prefill(), model_layer_5_prefill(), model_layer_6_decode(), model_layer_6_decode(), model_layer_6_decode(), model_layer_6_decode(), model_layer_6_prefill(), model_layer_6_prefill(), model_layer_6_prefill(), model_layer_6_prefill(), model_layer_7_decode(), model_layer_7_decode(), model_layer_7_decode(), model_layer_7_decode(), model_layer_7_prefill(), model_layer_7_prefill(), model_layer_7_prefill(), model_layer_7_prefill(), model_layer_8_decode(), model_layer_8_decode(), model_layer_8_decode(), model_layer_8_decode(), model_layer_8_prefill(), model_layer_8_prefill(), model_layer_8_prefill(), model_layer_8_prefill(), model_layer_9_decode(), model_layer_9_decode(), model_layer_9_decode(), model_layer_9_decode(), model_layer_9_prefill(), model_layer_9_prefill(), model_layer_9_prefill(), model_layer_9_prefill(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_decode(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_0_prefill(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_decode(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_10_prefill(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_decode(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_11_prefill(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_decode(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_12_prefill(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_decode(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_13_prefill(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_decode(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_14_prefill(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_decode(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_15_prefill(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_decode(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_16_prefill(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_decode(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_17_prefill(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_decode(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_18_prefill(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_decode(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_19_prefill(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_decode(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_1_prefill(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_decode(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_20_prefill(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_decode(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_21_prefill(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_decode(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_22_prefill(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_decode(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_23_prefill(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_decode(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_2_prefill(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_decode(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_3_prefill(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_decode(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_4_prefill(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_decode(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_5_prefill(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_decode(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_6_prefill(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_decode(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_7_prefill(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_decode(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_8_prefill(), qwen2_0_5b_decode_layer_9_decode(), qwen2_0_5b_decode_layer_9_decode(), qwen2_0_5b_decode_layer_9_decode(), qwen2_0_5b_decode_layer_9_decode(), qwen2_0_5b_decode_layer_9_decode(), qwen2_0_5b_decode_layer_9_prefill(), qwen2_0_5b_decode_layer_9_prefill(), qwen2_0_5b_decode_layer_9_prefill(), and qwen2_0_5b_decode_layer_9_prefill().
| void swiglu_forward_bf16 | ( | const uint16_t * | input, |
| uint16_t * | output, | ||
| int | tokens, | ||
| int | dim | ||
| ) |
Definition at line 66 of file swiglu_kernels_bf16.c.
References bf16_to_float(), float_to_bf16(), sigmoid_scalar(), and silu().
| void swiglu_forward_exact | ( | const float * | input, |
| float * | output, | ||
| int | tokens, | ||
| int | dim | ||
| ) |
SwiGLU forward pass (exact version using stdlib sigmoid)
test_swiglu.py::TestSwiGLUForward::test_exact_vs_fast
test_swiglu.py::TestSwiGLUForward::test_exact_single
Uses standard library expf for numerical accuracy reference.
After changes: make test
Definition at line 515 of file swiglu_kernels.c.
References sigmoid_scalar_parity(), and silu().
Referenced by ck_mlp_swiglu_forward(), ck_mlp_swiglu_forward_ref(), and swiglu_forward().
| void swiglu_forward_ggml | ( | const float * | input, |
| float * | output, | ||
| int | tokens, | ||
| int | dim | ||
| ) |
Definition at line 538 of file swiglu_kernels.c.
References silu().
Referenced by ck_moe_q4k_mixed_route_work(), ck_moe_q4k_q5k_bucket_work(), ck_moe_q4k_q5k_route_work(), 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_shared_forward_q4k_q4k_workspace(), moe_swiglu_shared_forward_q4k_q6k_workspace(), and moe_swiglu_shared_forward_q8_0_gated_workspace().
| void swiglu_forward_ggml_split | ( | const float * | gate, |
| const float * | up, | ||
| float * | output, | ||
| int | tokens, | ||
| int | dim | ||
| ) |
Definition at line 576 of file swiglu_kernels.c.
References silu().
Referenced by ck_moe_q4k_q5k_bucket_work(), and ck_moe_shared_q4k_gated_workspace().
| void swiglu_forward_pytorch_bf16_storage | ( | const float * | input, |
| float * | output, | ||
| int | tokens, | ||
| int | dim | ||
| ) |
Definition at line 658 of file swiglu_kernels.c.
References __attribute__(), bf16_to_float(), float_to_bf16(), and silu().
Referenced by moe_swiglu_packed_expert_forward_bf16().
| void swiglu_forward_q8_k | ( | const float * | input, |
| void * | output_q8, | ||
| int | tokens, | ||
| int | dim | ||
| ) |
Definition at line 319 of file swiglu_kernels.c.
References ck_strict_parity_enabled(), QK_K, quantize_row_q8_k(), sigmoid_scalar(), and sigmoid_scalar_parity().
| void topk_batched_f32 | ( | const float * | scores, |
| int | num_tokens, | ||
| int | n_experts, | ||
| int | k, | ||
| int * | indices, | ||
| float * | weights | ||
| ) |
Batched top-K selection for multiple tokens.
| scores | Input scores [num_tokens, n_experts] |
| num_tokens | Number of tokens |
| n_experts | Number of experts |
| k | Number of experts to select per token |
| indices | Output: selected expert indices [num_tokens, k] |
| weights | Output: routing weights [num_tokens, k] (can be NULL for no softmax) |
Definition at line 465 of file topk_kernels.c.
References topk_f32(), and topk_softmax_f32().
| void topk_f32 | ( | const float * | scores, |
| int | n, | ||
| int | k, | ||
| int * | indices, | ||
| float * | values | ||
| ) |
Find top-K indices and values from a score vector.
| scores | Input scores [n] |
| n | Number of scores (e.g., number of experts) |
| k | Number of top scores to select |
| indices | Output: indices of top-K scores [k], sorted descending by value |
| values | Output: top-K score values [k], sorted descending (can be NULL) |
Definition at line 51 of file topk_kernels.c.
Referenced by moe_softmax_topk_router_llama_f32_workspace(), topk_batched_f32(), and topk_softmax_f32().
| void topk_softmax_backward_f32 | ( | const int * | indices, |
| const float * | weights, | ||
| const float * | d_weights, | ||
| float * | d_scores, | ||
| int | num_tokens, | ||
| int | n_experts_or_keys, | ||
| int | k | ||
| ) |
Backward for hard top-k followed by softmax over selected values.
Matches PyTorch behavior for: values, indices = torch.topk(scores, k, dim=-1) weights = torch.softmax(values, dim=-1)
The hard selected indices are treated as fixed for this backward pass. Gradients are scattered only to selected scores; unselected scores are zero.
Definition at line 408 of file topk_kernels.c.
| void topk_softmax_f32 | ( | const float * | scores, |
| int | n, | ||
| int | k, | ||
| int * | indices, | ||
| float * | weights | ||
| ) |
Find top-K indices with softmax-normalized weights.
| scores | Input scores [n] (router logits) |
| n | Number of scores |
| k | Number of top scores to select |
| indices | Output: indices of top-K scores [k] |
| weights | Output: softmax-normalized weights for selected [k], sum to 1.0 |
Definition at line 136 of file topk_kernels.c.
References topk_f32().
Referenced by topk_batched_f32().
| void unfused_rmsnorm_qkv_prefill | ( | const float * | x, |
| const float * | gamma, | ||
| const float * | Wq, | ||
| const float * | Wk, | ||
| const float * | Wv, | ||
| float * | x_norm, | ||
| float * | Q, | ||
| float * | K, | ||
| float * | V, | ||
| int | seq_len, | ||
| int | hidden, | ||
| int | q_dim, | ||
| int | kv_dim, | ||
| float | eps | ||
| ) |
Unfused version for benchmarking comparison.
Unfused version for benchmarking comparison.
Definition at line 667 of file prefill_fused_gemm.c.
References gemm_tile_nt_strided(), PREFILL_TILE_M, PREFILL_TILE_N, and rmsnorm_tile().
| void vec_dot_q6_k_q8_k | ( | int | n, |
| float * | s, | ||
| const void * | vx, | ||
| const void * | vy | ||
| ) |
Q6_K x Q8_K dot product (single row)
Definition at line 1324 of file gemm_kernels_q6k_q8k.c.
References dot_q6_k_q8_k_ref().
| void vision_position_ids_2d_merge | ( | int32_t * | positions, |
| int | grid_h, | ||
| int | grid_w, | ||
| int | merge_size | ||
| ) |
Build merged 2D vision position IDs in the layout expected by vision M-RoPE.
Output layout: [4, grid_h * grid_w] flattened as [y_stream | x_stream | y_stream_dup | x_stream_dup]
Tokens are emitted in merged-tile traversal order so the position buffer matches the same 2x2 grouping used by Qwen-style vision encoders.
Definition at line 529 of file vision_kernels.c.
| 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().
| void yarn_rope_cache_contiguous_positions_f32 | ( | float * | cos_cache, |
| float * | sin_cache, | ||
| int | num_tokens, | ||
| int | rotary_dim, | ||
| float | freq_base, | ||
| float | factor, | ||
| int | original_context, | ||
| float | beta_fast, | ||
| float | beta_slow, | ||
| float | mscale, | ||
| float | mscale_all_dim | ||
| ) |
Definition at line 517 of file rope_kernels.c.
References yarn_rope_cache_explicit_positions_impl().
| void yarn_rope_cache_explicit_positions_bf16 | ( | uint16_t * | cos_cache, |
| uint16_t * | sin_cache, | ||
| const int32_t * | positions, | ||
| int | num_tokens, | ||
| int | rotary_dim, | ||
| float | freq_base, | ||
| float | factor, | ||
| int | original_context, | ||
| float | beta_fast, | ||
| float | beta_slow, | ||
| float | mscale, | ||
| float | mscale_all_dim | ||
| ) |
Definition at line 535 of file rope_kernels.c.
References yarn_rope_cache_explicit_positions_impl().
| void yarn_rope_cache_explicit_positions_f32 | ( | float * | cos_cache, |
| float * | sin_cache, | ||
| const int32_t * | positions, | ||
| int | num_tokens, | ||
| int | rotary_dim, | ||
| float | freq_base, | ||
| float | factor, | ||
| int | original_context, | ||
| float | beta_fast, | ||
| float | beta_slow, | ||
| float | mscale, | ||
| float | mscale_all_dim | ||
| ) |
Definition at line 498 of file rope_kernels.c.
References yarn_rope_cache_explicit_positions_impl().