rwkv-architecture

Implements RWKV models for linear-time inference with constant memory and infinite context.

Updated Mar 23, 2026
One-click install
npx skills add https://github.com/hanasho744/codex --skill rwkv-architecture-hanasho744
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: rwkv-architecture
Source: https://github.com/hanasho744/codex/tree/main/.agents/skills/rwkv
Command: npx skills add https://github.com/hanasho744/codex --skill rwkv-architecture-hanasho744

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires rwkv, torch, transformers, and includes references (resource) components.

What problem does it solve? Transformer models suffer from quadratic attention complexity and ever-growing KV caches, making long-context inference slow and memory-hungry. This Skill provides guidance for using RWKV, an RNN-Transformer hybrid that trains in parallel like GPT but infers sequentially with O(1) memory per token. ## Core Features & Use Cases - Dual-mode inference: Run models in GPT mode (parallel) or RNN mode (sequential) with identical outputs, enabling streaming token-by-token generation. - Infinite context processing: Stream through million-token documents with a fixed-size recurrent state instead of a growing KV cache. - Fine-tuning and state management: Train with PyTorch Lightning and DeepSpeed, and save, load, blend, or expire conversation states for multi-session chatbots. - Use Case: Build a document summarization service that processes 100K+ token files on a single GPU, maintaining constant memory while a Transformer equivalent would require hundreds of gigabytes of KV cache. ## Quick Start Install the rwkv and torch packages, then load a pretrained RWKV model and generate text token by token using its RNN mode.

Frequently Asked Questions about rwkv-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run RWKV model inference in Python?▼

Install the rwkv package, load a model with RWKV(model=path, strategy='cuda fp16'), and call model.forward(tokens, state). Set RWKV_CUDA_ON=1 to enable the CUDA kernel for faster inference.

What is the difference between RWKV and Transformer models?▼

RWKV trains in parallel like a Transformer but infers sequentially like an RNN with O(1) memory per token. Transformers use O(n²) attention and a growing KV cache, while RWKV keeps a fixed-size recurrent state regardless of context length.

Can RWKV handle infinite or very long context?▼

Yes, RWKV processes arbitrarily long sequences by streaming tokens through a constant-size state, so memory stays flat even for million-token documents. The trade-off is lossy recall compared to a Transformer's exact KV cache retrieval.

How much VRAM does RWKV inference require?▼

In FP16, the 1.5B model needs about 4GB, the 7B model about 16GB, and the 14B model about 32GB of VRAM. Inference memory stays constant per token because there is no KV cache growth.

Why is my RWKV model losing context between forward calls?▼

Context is lost when the state returned by one forward call is not passed into the next call. Always chain calls as out, state = model.forward(tokens, state) so the recurrent state carries prior context forward.

When should I use Mamba or Transformers instead of RWKV?▼

Choose Transformers when you need the absolute best quality and have ample compute, Mamba for state-space model architectures, and RetNet or Hyena for retention or convolution-based designs. RWKV fits memory-constrained, long-context, or streaming deployments.