Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions crates/metaltile-std/src/ffai/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ pub mod flash_block_scaled_sdpa;
pub mod flash_quantized_sdpa;
pub mod gate_up_swiglu_fused;
pub mod gelu_erf;
// gemm_q4_mpp / gemm_q8 / gemm_q8_mpp migrated to kernels/gemm/.
pub mod gemv_q8;
// gemm_q4_mpp / gemm_q8 / gemm_q8_mpp + gemv_q8 (split by family) → kernels/.
pub mod gguf_dequant_iq2_xxs;
pub mod gguf_dequant_iq2_xxs_raw;
pub mod gguf_dequant_q2_k;
Expand Down
23 changes: 23 additions & 0 deletions crates/metaltile-std/src/kernels/convolution/conv1d_causal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,29 @@ pub fn mt_conv1d_causal_prefill(
store(y[idx], acc * sig);
}

// Causal-conv state roll (prefill->decode handoff for the short conv).
/// Roll a causal-conv state ON-DEVICE: `new = [old[conv_dim..], xbc]` (drop the
/// oldest conv_dim, append the current input) — keeps the Mamba conv history on
/// the GPU. `keep = (kc-2)*conv_dim`; indices clamped so both select branches
/// are in-bounds.
#[kernel]
pub fn mt_conv_roll<T>(
old: Tensor<T>,
xbc: Tensor<T>,
mut newst: Tensor<T>,
#[constexpr] conv_dim: u32,
#[constexpr] keep: u32,
#[constexpr] n: u32,
) {
let i = program_id::<0>();
if i < n {
let oi = select(i < keep, i + conv_dim, 0u32);
let xi = select(i < keep, 0u32, i - keep);
let v = select(i < keep, load(old[oi]), load(xbc[xi]));
store(newst[i], v);
}
}

pub mod kernel_tests {
use metaltile::{test::*, test_kernel};

Expand Down
Loading
Loading