aboutsummaryrefslogtreecommitdiff
path: root/qwen_kernels.h
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-06-10 15:43:25 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-06-14 08:27:03 +0200
commite8259865f41ceb50dd28b267186d11c62a465135 (patch)
treecd5c8a4dff6936c5a9d511f2eea484393b698152 /qwen_kernels.h
parent5f73e5dc901f47cda6b2a26eea31cf9fc6178bc7 (diff)
downloadffwd-e8259865f41ceb50dd28b267186d11c62a465135.tar.gz
ffwd-e8259865f41ceb50dd28b267186d11c62a465135.zip
kernels: delete dead audio/causal-LM leftovers and unused exports
Diffstat (limited to 'qwen_kernels.h')
-rw-r--r--qwen_kernels.h67
1 files changed, 1 insertions, 66 deletions
diff --git a/qwen_kernels.h b/qwen_kernels.h
index 5281361..fd23c02 100644
--- a/qwen_kernels.h
+++ b/qwen_kernels.h
@@ -1,8 +1,7 @@
/*
- * qwen_kernels.h - Math kernels for Qwen3-ASR inference
+ * qwen_kernels.h - Math kernels for Qwen3-architecture inference
*
* Low-level math operations. All operate on float32 tensors in row-major order.
- * Adapted from voxtral-realtime project.
*/
#ifndef QWEN_KERNELS_H
@@ -16,9 +15,6 @@
* ======================================================================== */
void qwen_add_inplace(float *a, const float *b, int n);
-void qwen_mul_inplace(float *a, const float *b, int n);
-void qwen_scale(float *x, float s, int n);
-void qwen_copy(float *dst, const float *src, int n);
/* ========================================================================
* Matrix Operations
@@ -60,30 +56,9 @@ void qwen_linear_nobias_bf16_qkv(float *q, float *k, float *v, const float *x,
float qwen_dot_f32(const float *a, const float *b, int n);
/* ========================================================================
- * 2D Convolution (for audio encoder conv stem)
- * ======================================================================== */
-
-/*
- * 2D Convolution: out = conv2d(in, weight, bias)
- * in: [C_in, H, W]
- * weight: [C_out, C_in, kH, kW]
- * bias: [C_out] (can be NULL)
- * out: [C_out, H_out, W_out]
- * H_out = (H + 2*padding - kH) / stride + 1
- * W_out = (W + 2*padding - kW) / stride + 1
- */
-void qwen_conv2d(float *out, const float *in, const float *weight, const float *bias,
- int c_in, int c_out, int h_in, int w_in,
- int kh, int kw, int stride, int padding);
-
-/* ========================================================================
* Normalization
* ======================================================================== */
-/* LayerNorm with bias: out = (x - mean) / sqrt(var + eps) * weight + bias */
-void qwen_layer_norm(float *out, const float *x, const float *weight, const float *bias,
- int seq_len, int hidden, float eps);
-
/* RMS Normalization: out = x / rms(x) * weight */
void qwen_rms_norm(float *out, const float *x, const float *weight,
int seq_len, int hidden, float eps);
@@ -98,43 +73,15 @@ void qwen_rms_norm_per_head(float *x, const float *weight,
* Activation Functions
* ======================================================================== */
-void qwen_silu(float *x, int n);
-void qwen_gelu(float *x, int n);
void qwen_softmax(float *x, int rows, int cols);
/* gate = SiLU(gate) * up */
void qwen_silu_mul_inplace(float *gate, const float *up, int n);
-/* out[seq,inter] = SiLU(gate_up[seq,2*inter][:,even]) * gate_up[:,odd] */
-void qwen_swiglu_multiply(float *out, const float *gate_up, int seq_len, int intermediate);
/* ========================================================================
* Attention Operations
* ======================================================================== */
/*
- * Bidirectional windowed attention (encoder).
- * Q, K, V: [seq, n_heads * head_dim]
- * out: [seq, n_heads * head_dim]
- * window_starts: array of window start positions
- * window_starts[n_windows] = seq (sentinel)
- * All heads have same dimensions (no GQA in encoder).
- */
-void qwen_bidirectional_attention(float *out, const float *Q, const float *K,
- const float *V, int seq, int n_heads,
- int head_dim, float scale,
- const int *window_starts, int n_windows);
-
-/*
- * Causal attention with GQA (decoder).
- * Q: [seq_q, n_heads * head_dim]
- * K: [seq_k, n_kv_heads * head_dim]
- * V: [seq_k, n_kv_heads * head_dim]
- * q_offset: global position of first query (for causal mask)
- */
-void qwen_causal_attention(float *out, const float *Q, const float *K, const float *V,
- int seq_q, int seq_k, int n_heads, int n_kv_heads,
- int head_dim, float scale, int q_offset);
-
-/*
* Bidirectional GQA attention over a packed/ragged batch.
*
* Q: [total_seq, n_heads * head_dim]
@@ -163,13 +110,6 @@ void qwen_bidirectional_gqa_attention_packed_with_scratch(
* ======================================================================== */
/*
- * Sinusoidal position embeddings (encoder).
- * pe: output [n_pos, d_model]
- * First half = sin, second half = cos.
- */
-void qwen_sinusoidal_pe(float *pe, int n_pos, int d_model);
-
-/*
* NeoX-style RoPE: compute cos/sin for positions.
* cos_out, sin_out: [seq, head_dim]
* cos[d] and cos[half+d] are the same (duplicated for full head_dim).
@@ -185,11 +125,6 @@ void qwen_compute_rope_neox(float *cos_out, float *sin_out, const int *positions
void qwen_apply_rope_neox(float *x, const float *cos_vals, const float *sin_vals,
int seq, int n_heads, int head_dim);
-/* Streaming argmax: finds argmax(W_bf16 @ x) without materializing full logits.
- * Returns the index of the row with highest dot product. */
-int qwen_argmax_matvec_bf16(const float *x, const uint16_t *W_bf16,
- int in_dim, int out_dim);
-
/* ========================================================================
* Threading
* ======================================================================== */