spark_model/model/mod.rs
1// SPDX-License-Identifier: AGPL-3.0-only
2
3//! Generic transformer model.
4//!
5//! The model loop (embed -> layers -> norm -> lm_head) is architecture-
6//! agnostic. Layer-specific logic lives in `TransformerLayer` implementations.
7//!
8//! Wave 4b1 split: this module was originally a single 8,690 LoC `model.rs`.
9//! Sub-modules now hold:
10//! - `types` struct TransformerModel + PinnedMetaStaging
11//! - `ssm_pool` SsmStatePool
12//! - `ssm_snapshot` SsmSnapshotPool
13//! - `block_mgmt` free-fn helpers (apply_evicted_blocks etc.)
14//! - `impl_a1/2/3` first inherent `impl TransformerModel` block
15//! - `impl_b1/2/3` second inherent `impl TransformerModel` block
16//! - `trait_impl` single `impl Model for TransformerModel` block
17//! **FLAGGED ≤500 LoC cap** — Rust does NOT allow
18//! splitting one trait impl across files (E0119),
19//! and breaking it into inherent-helper delegation
20//! is a semantic refactor outside this wave's scope.
21//! - `drop` `impl Drop for TransformerModel`
22//! - `tests` extracted unit tests
23
24#![allow(unused_imports, dead_code)]
25
26pub(crate) mod block_mgmt;
27pub(crate) mod drafter_context;
28pub(crate) mod drop;
29pub(crate) mod impl_a1;
30pub(crate) mod impl_a1_init;
31pub(crate) mod impl_a2;
32pub(crate) mod impl_a3;
33mod impl_a3_embed;
34mod impl_a3_norm;
35pub(crate) mod impl_b1;
36pub(crate) mod impl_b2;
37pub(crate) mod impl_b3;
38pub(crate) mod impl_b3_accessors;
39pub(crate) mod impl_lora;
40pub(crate) mod impl_lora_swap;
41mod impl_ngram;
42pub(crate) mod mtp_carry;
43pub(crate) mod pinned_pack;
44pub(crate) mod seq_memtrace;
45pub(crate) mod ssm_batched_copy;
46pub(crate) mod ssm_pool;
47pub(crate) mod ssm_snapshot;
48pub(crate) mod ssm_snapshot_faultin;
49pub(crate) mod ssm_snapshot_spill;
50mod ssm_snapshot_teardown;
51pub(crate) mod ssm_spill_gate;
52pub(crate) mod ssm_spill_staging;
53pub(crate) mod ssm_tier;
54pub(crate) mod token_overlay;
55pub(crate) mod trait_impl;
56pub(crate) mod types;
57
58// Served NLLB-200 / M2M-100 encoder-decoder model (CUDA/GB10 serving path).
59#[cfg(feature = "cuda")]
60pub mod nllb;
61#[cfg(all(test, not(feature = "cuda")))]
62#[path = "nllb/host_tests.rs"]
63mod nllb_host_tests;
64
65pub use types::TransformerModel;