agent-management
Create, manage, and orchestrate AI agents using the AI Maestro CLI. Use when the user asks to "create agent", "list agents",…
RNN+Transformer hybrid with O(n) inference. Linear time, infinite context, no KV cache. Train like GPT (parallel), infer like RNN (sequential). Linux Foundation AI project. Production at Windows, Office, NeMo. RWKV-7 (March 2025). Models up to 14B parameters.
Claude Code
$ npx -y skills add davila7/claude-code-templates --skill model-architecture-rwkv --agent claude-code
Codex
$ npx skills add davila7/claude-code-templates --skill model-architecture-rwkv -a codex -y
Cursor
$ npx skills add davila7/claude-code-templates --skill model-architecture-rwkv -a cursor -y
Gemini CLI
$ npx skills add davila7/claude-code-templates --skill model-architecture-rwkv -a gemini-cli -y
GitHub Copilot
$ npx skills add davila7/claude-code-templates --skill model-architecture-rwkv -a github-copilot -y
OpenCode
$ npx skills add davila7/claude-code-templates --skill model-architecture-rwkv -a opencode -y
Windsurf
$ npx skills add davila7/claude-code-templates --skill model-architecture-rwkv -a windsurf -y
name: model-architecture-rwkv description: RNN+Transformer hybrid with O(n) inference. Linear time, infinite context, no KV cache. Train like GPT (parallel), infer like RNN (sequential). Linux Foundation AI project. Production at Windows, Office, NeMo. RWKV-7 (March 2025). Models up to 14B parameters. license: MIT metadata: version: 1.0.0 author: Orchestra Research tags: [RWKV, Model Architecture, RNN, Transformer Hybrid, Linear Complexity, Infinite Context, Efficient Inference, Linux Foundation, Alternative Architecture] dependencies: [rwkv, torch, transformers]
RWKV (RwaKuv) combines Transformer parallelization (training) with RNN efficiency (inference).
**Installation**:
# Install PyTorch pip install torch --upgrade --extra-index-url https://download.pytorch.org/whl/cu121 # Install dependencies pip install pytorch-lightning==1.9.5 deepspeed wandb ninja --upgrade # Install RWKV pip install rwkv
**Basic usage** (GPT mode + RNN mode):
import os
from rwkv.model import RWKV
os.environ["RWKV_JIT_ON"] = '1'
os.environ["RWKV_CUDA_ON"] = '1' # Use CUDA kernel for speed
# Load model
model = RWKV(
model='/path/to/RWKV-4-Pile-1B5-20220903-8040',
strategy='cuda fp16'
)
# GPT mode (parallel processing)
out, state = model.forward([187, 510, 1563, 310, 247], None)
print(out.detach().cpu().numpy()) # Logits
# RNN mode (sequential processing, same result)
out, state = model.forward([187, 510], None) # First 2 tokens
out, state = model.forward([1563], state) # Next token
out, state = model.forward([310, 247], state) # Last tokens
print(out.detach().cpu().numpy()) # Same logits as above!**Efficient token-by-token generation**:
from rwkv.model import RWKV
from rwkv.utils import PIPELINE
model = RWKV(model='RWKV-4-Pile-14B-20230313-ctx8192-test1050', strategy='cuda fp16')
pipeline = PIPELINE(model, "20B_tokenizer.json")
# Initial prompt
prompt = "The future of AI is"
state = None
# Generate token by token
for token in prompt:
out, state = pipeline.model.forward(pipeline.encode(token), state)
# Continue generation
for _ in range(100):
out, state = pipeline.model.forward(None, state)
token = pipeline.sample_logits(out)
print(pipeline.decode(token), end='', flush=True)**Key advantage**: Constant memory per token (no growing KV cache)
**Process million-token sequences**:
model = RWKV(model='RWKV-4-Pile-14B', strategy='cuda fp16')
# Process very long document
state = None
long_document = load_document() # e.g., 1M tokens
# Stream through entire document
for chunk in chunks(long_document, chunk_size=1024):
out, state = model.forward(chunk, state)
# State now contains information from entire 1M token document
# Memory usage: O(1) (constant, not O(n)!)**Standard fine-tuning workflow**:
# Training script
import pytorch_lightning as pl
from rwkv.model import RWKV
from rwkv.trainer import RWKVTrainer
# Configure model
config = {
'n_layer': 24,
'n_embd': 1024,
'vocab_size': 50277,
'ctx_len': 1024
}
# Setup trainer
trainer = pl.Trainer(
accelerator='gpu',
devices=8,
precision='bf16',
strategy='deepspeed_stage_2',
max_epochs=1
)
# Train
model = RWKV(config)
trainer.fit(model, train_dataloader)**Memory comparison** (1M token sequence):
# Transformer (GPT) # Memory: O(n²) for attention # KV cache: 1M × hidden_dim × n_layers × 2 (keys + values) # Example: 1M × 4096 × 24 × 2 = ~400GB (impractical!) # RWKV # Memory: O(1) per token # State: hidden_dim × n_layers = 4096 × 24 = ~400KB # 1,000,000× more efficient!
**Speed comparison** (inference):
# Transformer: O(n) per token (quadratic overall) # First token: 1 computation # Second token: 2 computations # ... # 1000th token: 1000 computations # RWKV: O(1) per token (linear overall) # Every token: 1 computation # 1000th token: 1 computation (same as first!)
**Use RWKV when**:
**Key advantages**:
**Use alternatives instead**:
**Issue: Out of memory during training**
Use gradient checkpointing and DeepSpeed:
trainer = pl.Trainer(
strategy='deepspeed_stage_3', # Full ZeRO-3
precision='bf16'
)**Issue: Slow inference**
Enable CUDA kernel:
os.environ["RWKV_CUDA_ON"] = '1'
**Issue: Model not loading**
Check model path and strategy:
model = RWKV(
model='/absolute/path/to/model.pth',
strategy='cuda fp16' # Or 'cpu fp32' for CPU
)**Issue: State management in RNN mode**
Always pass state between forward calls:
# WRONG: State lost out1, _ = model.forward(tokens1, None) out2, _ = model.forward(tokens2, None) # No context from tokens1! # CORRECT: State preserved out1, state = model.forward(tokens1, None) out2, state = model.forward(tokens2, state) # Has context from tokens1
**Time-mixing and channel-mixing**: See [references/architecture-details.md](references/architecture-details.md) for WKV operation, time-decay mechanism, and receptance gates.
**State management**: See [referenc
Open-source registry and CLI for Claude Code components: agents, commands, skills, hooks, MCPs, settings and mods
Create, manage, and orchestrate AI agents using the AI Maestro CLI. Use when the user asks to "create agent", "list agents",…
Send and receive cryptographically signed messages between AI agents using the Agent Messaging Protocol (AMP). Use when the user…
Search auto-generated codebase documentation for function signatures, API docs, class definitions, and code comments. Use when…
Query the code graph database to understand component relationships, dependencies, and change impact. Use when the user asks to…
Search conversation history and semantic memory to recall previous discussions, decisions, and context. Use when the user asks to…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.