Getting Started with Titans-Memory (v0.2.0)
Congratulations on installing titans-memory! This package provides a high-performance, feature-rich implementation of the Titans (Learning to Memorize at Test Time) architecture.
🚀 Quick Start
import torch
from titans.utils import TitansConfig, build_model
# Initialize a small MAC model (~30M parameters)
cfg = TitansConfig.tiny(variant='MAC', vocab_size=32000)
model = build_model(cfg)
# Forward pass
input_ids = torch.randint(0, 32000, (1, 512))
output = model(input_ids)
print(output['logits'].shape) # [1, 512, 32000]
⚡ High-Performance Features (v0.2.0)
1. Parallel Associative Scan
Process massive sequences faster than standard implementations. Our parallel_scan uses a log-depth algorithm optimized for CUDA.
from titans.ops import parallel_scan
# This is automatically used inside the model for GPU tensors
2. HuggingFace Integration
You can now use Titans models with the familiar transformers API:
from titans.utils.hf import TitansModelForCausalLM, TitansHFConfig
config = TitansHFConfig(d_model=512, n_layers=12, variant='MAC')
model = TitansModelForCausalLM(config)
# Save/Load using standard HF methods
model.save_pretrained('./my-titans-model')
3. Distributed Training (DDP)
Scale your training across multiple GPUs seamlessly:
from titans.utils.training import setup_ddp, wrap_ddp
local_rank = setup_ddp()
model = wrap_ddp(model, local_rank)
🛠 Model Variants
| Variant | Best For | Description |
|---|---|---|
| MAC | Long Context | Memory as Context (retrieves long-term memory as a prefix) |
| MAG | Gated Tasks | Memory as a Gate (Sliding Window Attention ⊗ NeuralMemory) |
| MAL | Sequential | Memory as a Layer |
| LMM | Efficiency | Standalone neural memory without attention |
📜 Citation
If you use this implementation in your research:
@article{behrouz2024titans,
title = {Titans: Learning to Memorize at Test Time},
author = {Ali Behrouz, Peilin Zhong, Vahab Mirrokni},
year = {2024}
}
Metadata
Release files for titans-memory 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| titans_memory-0.3.0.tar.gz | 24.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| titans_memory-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 52.5 kB
Release files / titans_memory-0.3.0.tar.gz
| Download URL | titans_memory-0.3.0.tar.gz |
|---|---|
| Size | 24.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dea3bbcbf7cc63c0adb0ef56186abb437eb0a738e2ebdb31debaf402b5068eec
|
|
BLAKE2b-256 checksum How to use checksums |
fc0d2b5d13a545c2d288356149ae9df42a4426d8bb8ea82fe68865a411e096e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|
Release files / titans_memory-0.3.0-py3-none-any.whl
| Download URL | titans_memory-0.3.0-py3-none-any.whl |
|---|---|
| Size | 27.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
95c8d8cd82dd2baf4c4d5b69ad6809637fc3dbf9ca835e0a2cfe6dedbae80dc5
|
|
BLAKE2b-256 checksum How to use checksums |
afce38ca2469f79e58efb4d1360e569d85adf616d1bee50131152106f11bf944
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|