#include "ckernel_engine.h"#include <math.h>#include <stddef.h>#include <stdint.h>#include <string.h>Go to the source code of this file.
Functions | |
| static float | qwen4_bf16_load (const uint16_t *value) |
| static float | qwen4_bf16_round (float value) |
| static void | qwen4_group_rmsnorm_llama (const float *input, const float *weight, float *output, int groups, int hidden_dim, float eps) |
| static void | qwen4_group_rmsnorm_pytorch_bf16 (const float *input, const float *weight, float *output, int groups, int hidden_dim, float eps) |
| static int32_t | qwen4_history_token (const int32_t *tokens, const float *state, int row, int shift, int state_len, int eos_token_id, int position) |
| static float | qwen4_llama_mul_sum_rows (const float *left, const float *right, int dim) |
| 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) |
| static void | qwen4_ple_gate_conv_inject_impl (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 void *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, int conv_weight_is_fp16, int llama_fp32_arithmetic) |
| 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_offset) |
| static void | qwen4_ple_ngram_embed_impl (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_offset, int embedding_is_q5_0) |
| 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_offset) |
| static float | qwen4_pytorch_bf16_dot (const float *left, const float *right, int dim) |
| 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) |
| static void | qwen4_rope_split_inplace (float *vector, int rotary_dim, int position, float theta) |
| static void | qwen4_shared_head_rmsnorm (const float *input, const float *weight, float *output, int heads, int head_dim, float eps) |
|
inlinestatic |
Definition at line 19 of file qwen4_exp_kernels.c.
Referenced by qwen4_ple_gate_conv_inject_impl(), and qwen4_ple_ngram_embed_impl().
|
inlinestatic |
Definition at line 12 of file qwen4_exp_kernels.c.
Referenced by qwen4_ple_gate_conv_inject_impl(), qwen4_pytorch_bf16_dot(), qwen4_qsa_index_select_bf16(), qwen4_rope_split_inplace(), and qwen4_shared_head_rmsnorm().
|
static |
Definition at line 176 of file qwen4_exp_kernels.c.
References rmsnorm_forward_llama_production().
Referenced by qwen4_ple_gate_conv_inject_impl().
|
static |
Definition at line 161 of file qwen4_exp_kernels.c.
References rmsnorm_forward_qwen3next_pytorch_bf16_storage().
Referenced by qwen4_ple_gate_conv_inject_impl().
|
static |
Definition at line 24 of file qwen4_exp_kernels.c.
Referenced by qwen4_ple_ngram_embed_impl().
|
static |
Definition at line 233 of file qwen4_exp_kernels.c.
Referenced by qwen4_ple_gate_conv_inject_impl().
| 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().
|
static |
Definition at line 245 of file qwen4_exp_kernels.c.
References ck_fp16_to_fp32(), qwen4_bf16_load(), qwen4_bf16_round(), qwen4_group_rmsnorm_llama(), qwen4_group_rmsnorm_pytorch_bf16(), qwen4_llama_mul_sum_rows(), qwen4_pytorch_bf16_dot(), recurrent_silu_forward_ggml(), and silu().
Referenced by qwen4_ple_gate_conv_inject_bf16(), qwen4_ple_gate_conv_inject_fp16(), and qwen4_ple_gate_conv_inject_llama_fp16().
| 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_offset | ||
| ) |
Definition at line 121 of file qwen4_exp_kernels.c.
References qwen4_ple_ngram_embed_impl().
|
static |
Definition at line 45 of file qwen4_exp_kernels.c.
References CK_DT_Q5_0, ck_dtype_row_bytes(), dequant_q5_0_row(), qwen4_bf16_load(), qwen4_history_token(), and token.
Referenced by qwen4_ple_ngram_embed_bf16(), and qwen4_ple_ngram_embed_q5_0().
| 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_offset | ||
| ) |
Definition at line 141 of file qwen4_exp_kernels.c.
References qwen4_ple_ngram_embed_impl().
|
static |
Definition at line 191 of file qwen4_exp_kernels.c.
References left, qwen4_bf16_round(), and right.
Referenced by qwen4_ple_gate_conv_inject_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.
|
static |
Definition at line 471 of file qwen4_exp_kernels.c.
References qwen4_bf16_round().
Referenced by qwen4_qsa_index_select_bf16().
|
static |
Definition at line 453 of file qwen4_exp_kernels.c.
References qwen4_bf16_round().
Referenced by qwen4_qsa_index_select_bf16().