14#ifndef CK_PARITY_API_H
15#define CK_PARITY_API_H
33#define CK_BLOCK_Q4_K_SIZE 144
34#define CK_BLOCK_Q6_K_SIZE 210
35#define CK_BLOCK_Q8_K_SIZE 292
36#define CK_BLOCK_Q4_0_SIZE 18
87 const float *input_f32,
95 const float *input_f32,
109 const float *input_f32,
123 const float *input_f32,
140 const float *input_f32,
157 const float *input_f32,
167 const void *input_q8_k,
173 const void *input_q8_k,
189 const void *input_q8_0,
202 const void *input_q8_0,
223 const float *input_f32,
225 int rows,
int cols,
int n_tokens);
240 const float *input_f32,
242 int rows,
int cols,
int n_tokens);
257 const float *input_f32,
259 int rows,
int cols,
int n_tokens);
274 const float *input_f32,
276 int rows,
int cols,
int n_tokens);
298 int n_tokens,
int dim,
float eps);
319 int n_tokens,
int n_heads,
int n_heads_kv,
int head_dim,
320 int pos_offset,
float theta);
328 int n_tokens,
int n_heads,
int n_heads_kv,
int head_dim,
329 int pos_offset,
float theta);
345 int n_tokens,
int intermediate_dim);
375 const float *state_in,
445 const float *dt_bias,
604 const float *attn_out,
605 const float *residual,
606 const float *ln2_gamma,
void ck_test_quantize_q8_k(const float *src, void *dst, int n)
Quantize FP32 to Q8_K (for activations)
void ck_test_gemm_q4_k(const void *weight_q4k, const float *input_f32, float *output, int rows, int cols, int n_tokens)
Q4_K GEMM - batched matrix multiply with quantized weights.
int ck_get_block_q8_k_size(void)
Get Q8_K block size in bytes.
void ck_test_dequant_q6_k(const void *src, float *dst, int n)
Dequantize Q6_K data to FP32.
void ck_test_rope(float *q, float *k, int n_tokens, int n_heads, int n_heads_kv, int head_dim, int pos_offset, float theta)
RoPE (Rotary Position Embedding)
void ck_test_recurrent_silu(const float *x, float *out, int rows, int dim)
Apply SiLU elementwise to recurrent rows.
void ck_test_recurrent_dt_gate(const float *alpha, const float *dt_bias, const float *a, float *gate, int rows, int dim)
Transform recurrent alpha rows into the DeltaNet gate.
void ck_test_gated_deltanet_autoregressive(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)
Gated DeltaNet autoregressive update.
void ck_test_attn_gate_sigmoid_mul(const float *x, const float *gate, float *out, int rows, int dim)
Multiply attention output rows by sigmoid(gate) elementwise.
void ck_test_split_q_gate(const float *packed_qg, float *q, float *gate, int rows, int q_dim, int gate_dim, int group_dim)
Split a packed full-attention Q+gate matrix into Q rows and gate rows.
void ck_test_gemv_q5_0_q8_0(const void *weight_q5_0, const float *input_f32, float *output, int rows, int cols)
Q5_0 x Q8_0 quantized GEMV - matches llama.cpp's approach.
void ck_test_recurrent_conv_state_update(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)
Build the recurrent convolution input history window.
void ck_test_recurrent_split_conv_qkv(const float *packed_qkv, float *q, float *k, float *v, int rows, int q_dim, int k_dim, int v_dim)
Split the post-convolution recurrent packed QKV rows.
void ck_test_dequant_q4_0(const void *src, float *dst, int n)
Dequantize Q4_0 data to FP32.
void ck_test_softmax(const float *input, float *output, int n)
Softmax (simple, non-causal)
void ck_test_rmsnorm(const float *input, const float *weight, float *output, int n_tokens, int dim, float eps)
RMSNorm.
void ck_test_gemm_q5_0(const void *weight_q5_0, const float *input_f32, float *output, int rows, int cols, int n_tokens)
Q5_0 GEMM - batched matrix multiply with Q5_0 weights (32-element blocks)
void ck_test_dequant_q4_k(const void *src, float *dst, int n)
Dequantize Q4_K data to FP32.
void ck_test_attention_causal(const float *q, const float *k, const float *v, float *out, int num_heads, int num_kv_heads, int tokens, int seq_len, int head_dim)
Multi-head causal attention for prefill (head-major layout)
void ck_test_gemv_q4_k(const void *weight_q4k, const float *input_f32, float *output, int cols)
Q4_K GEMV - dot product of quantized weights and FP32 input.
void ck_test_recurrent_split_qkv(const float *packed_qkv, float *q, float *k, float *v, int rows, int q_dim, int k_dim, int v_dim)
Split a packed recurrent QKV matrix into explicit Q, K, and V outputs.
void ck_test_vec_dot_q6_k_q8_k(const void *weight_q6_k, const void *input_q8_k, float *output, int cols)
void ck_test_gemv_q8_0_q8_0(const void *weight_q8_0, const float *input_f32, float *output, int rows, int cols)
Q8_0 x Q8_0 quantized GEMV - matches llama.cpp's approach.
void ck_test_vec_dot_q8_0_q8_0(const void *weight_q8_0, const void *input_q8_0, float *output, int cols)
Direct Q8_0 x Q8_0 dot product (takes pre-quantized Q8_0 input)
void ck_test_swiglu(const float *gate_up, float *output, int n_tokens, int intermediate_dim)
SwiGLU activation.
void ck_test_gemm_q6_k(const void *weight_q6k, const float *input_f32, float *output, int rows, int cols, int n_tokens)
Q6_K GEMM - batched matrix multiply with Q6_K weights.
void ck_test_vec_dot_q5_0_q8_0(const void *weight_q5_0, const void *input_q8_0, float *output, int cols)
Direct Q5_0 x Q8_0 dot product (takes pre-quantized Q8_0 input)
void ck_test_recurrent_norm_gate(const float *x, const float *gate, const float *weight, float *out, int rows, int num_heads, int head_dim, float eps)
Per-head RMSNorm followed by SiLU(z) gating for recurrent outputs.
int ck_get_qk_k(void)
Get QK_K (elements per super-block)
void ck_test_gemm_q8_0(const void *weight_q8_0, const float *input_f32, float *output, int rows, int cols, int n_tokens)
Q8_0 GEMM - batched matrix multiply with Q8_0 weights (32-element blocks)
void ck_test_gemv_q5_0(const void *weight_q5_0, const float *input_f32, float *output, int rows, int cols)
Q5_0 GEMV - matrix-vector multiply with Q5_0 weights.
void ck_test_ssm_conv1d(const float *conv_x, const float *kernel, float *out, int kernel_size, int num_channels, int num_tokens, int num_seqs)
qwen3next/Qwen3.5 SSM causal depthwise convolution.
void ck_test_recurrent_qk_l2_norm(float *q, float *k, int rows, int q_dim, int k_dim, int head_dim, float eps)
Apply per-head L2 normalization to recurrent Q/K rows in-place.
void ck_test_rope_interleaved(float *q, float *k, int n_tokens, int n_heads, int n_heads_kv, int head_dim, int pos_offset, float theta)
RoPE with interleaved format (for llama.cpp compatibility)
int ck_get_block_q4_k_size(void)
Get Q4_K block size in bytes.
int ck_get_block_q6_k_size(void)
Get Q6_K block size in bytes.
void ck_test_gemv_q8_0(const void *weight_q8_0, const float *input_f32, float *output, int rows, int cols)
Q8_0 GEMV - matrix-vector multiply with Q8_0 weights.
void ck_test_gemv_q6_k(const void *weight_q6k, const float *input_f32, float *output, int cols)
Q6_K GEMV.
void ck_test_vec_dot_q4_k_q8_k(const void *weight_q4_k, const void *input_q8_k, float *output, int cols)
void ck_test_outproj_mlp_fused_q5_0(const float *attn_out, const float *residual, const float *ln2_gamma, const void *wo, const void *w1, const void *w2, float *output, int tokens, int num_heads, int head_dim, int embed_dim, int intermediate, float eps, int w2_is_q6k)
Test mega-fused OutProj + MLP kernel (Q5_0 weights)