//! Tiny modern-architecture transformer (Phase T5). //! //! A from-scratch decoder built entirely from the [`xtrain_autodiff`] op set: //! token embedding → `n_layers` × {pre-RMSNorm → multi-head causal attention //! (per-head QK-norm + RoPE) → residual; pre-RMSNorm → SwiGLU MLP → residual} → //! final RMSNorm → LM-head matmul. The forward builds an autograd graph; calling //! `.backward()` on the cross-entropy loss fills every parameter's `.grad()`. //! Per-head QK-norm (Qwen3-style) makes the architecture xserv-compatible (T9). //! //! Conventions (matching the engine, not HuggingFace): //! - Linear weights are `[in, out]` and applied as `x @ W` (no transpose), since //! the engine's GEMM is plain `A @ B`. //! - `dim == n_heads * head_dim` (no separate attention projection size). //! - RoPE position = token row index (the kernel's built-in convention). //! - Causal masking is an additive `[seq,seq]` constant (−1e9 above the diagonal) //! added to the attention scores before softmax. //! //! Everything GPU-facing is gated behind `not(no_cuda)`; on a GPU-less host the //! crate still `cargo check`s (only [`Config`] is visible there). mod config; pub use config::Config; #[cfg(not(no_cuda))] mod model; #[cfg(not(no_cuda))] pub use model::{TinyTransformer, batched_ids_tensor, ids_tensor, param_to_host};