Expand description
Recurrent Looped Transformer (RLT).
A causal encoder builds global key–value memory; a recurrent decoder merges each
token’s encoder representation with the previous decoder output and maintains the
complete state H_t = (s_t, C_t^D) (recurrent output + per-layer SWA caches)
across every prompt and response token. See Recurrent_Looped_Transformer.pdf
(Zhang, 2026) for the reference semantics.
use rlt_core::{Rlt, RltConfig, ByteTokenizer, Device};
let model = Rlt::new(RltConfig::default(), Device::Cpu)?;
let tok = ByteTokenizer::new(258)?;
let (logits, state) = model.prefill(&tok.encode("Hi", true, false))?;
assert_eq!(logits.len(), 3);Re-exports§
pub use checkpoint::load_checkpoint;pub use checkpoint::save_checkpoint;pub use config::RltConfig;pub use error::Result;pub use error::RltError;pub use model::Rlt;pub use replay::replay;pub use replay::ReplayResult;pub use replay::Rollout;pub use replay::SamplingMetadata;pub use sampling::sample_from_logits;pub use sampling::SampledToken;pub use sampling::Sampler;pub use state::GroupKv;pub use state::LayerKv;pub use state::RltState;pub use tokenizer::ByteTokenizer;pub use tokenizer::BOS_ID;pub use tokenizer::EOS_ID;pub use tokenizer::MIN_VOCAB;
Modules§
- checkpoint
- Checkpointing: safetensors weights (via candle’s VarMap) + JSON config sidecar.
- config
- Model configuration.
- error
- Error type for rlt-core.
- execution
- Execution paths (paper §2.3–2.5, App. A): prefill, incremental step, training.
- model
- The RLT model: encoder stack, decoder stack, merge, readout.
- nn
- Tensor-level primitives: RMSNorm, rotary embeddings, attention.
- replay
- Current-policy RL replay (paper §5.3, §A.4).
- sampling
- Sampling from readout logits: greedy, temperature, top-k.
- state
- Recurrent state:
H_t = (s_t, C_t^D)plus encoder cache and encoder memory. - tokenizer
- Byte-level tokenizer with BOS/EOS specials. Keeps demos self-contained.
Structs§
- Tensor
- The core struct for manipulating tensors.
Enums§
- Device
- Cpu, Cuda, or Metal