ferrox_models/llama4_engine.rs
1//! Llama 4 dedicated stack stub — not generic GQA.
2//!
3//! Real checkpoints use MoE + a non-generic attention graph (llama.cpp
4//! `LLM_ARCH_LLAMA4`). Required tensors (names from pinned llama.cpp
5//! `LLM_TENSOR_NAMES` / `llama4.cpp`), not implemented here:
6//!
7//! - `token_embd.weight`, `output_norm.weight`, `output.weight`
8//! - Per layer: `blk.{i}.attn_norm.weight`, `blk.{i}.ffn_norm.weight`
9//! - MoE FFN: `blk.{i}.ffn_gate_inp.weight`, `ffn_gate_exps.weight`,
10//! `ffn_up_exps.weight`, `ffn_down_exps.weight`, `ffn_exp_probs_b.bias`
11//! - Llama-4-specific attention projections (not plain GQA `attn_q`/`attn_k`)
12//!
13//! Fail-closed via [`Self::reject`] until a real loader + engine land.
14
15use thiserror::Error;
16
17#[derive(Debug, Error)]
18#[error("llama4 dedicated engine not implemented: {reason}")]
19pub struct Llama4Unavailable {
20 pub reason: &'static str,
21}
22
23pub struct Llama4Engine {
24 pub arch: String,
25}
26
27impl Llama4Engine {
28 pub fn reject(_arch: &str) -> Result<(), Llama4Unavailable> {
29 Err(Llama4Unavailable {
30 reason: "llama4 MoE / non-generic graph not yet implemented (see llama4_engine.rs)",
31 })
32 }
33}
34
35#[cfg(test)]
36mod tests {
37 use super::*;
38
39 #[test]
40 fn reject_is_fail_closed() {
41 assert!(Llama4Engine::reject("llama4").is_err());
42 }
43}