Skip to content

Architecture

Four components in sequence: RWKV time-mixing for temporal dependencies, RWKV channel-mixing for feature transformation, sliding window attention for local context, and Mixture of Experts for capacity scaling.

RWKV TimeMix

Linear complexity attention

RWKV ChannelMix

Feature transformation

Sliding Window

Local context capture

TinyMoE

4 experts, top-1 routing

Configuration

130M parameters total. Trained on the same data as GPT-2 124M for direct comparison.

ParameterValue
Layers8
Attention heads8
Embedding dimension768
MoE experts4
Window size1024
Vocabulary50304
Total parameters130M

Loss comparison

Training and validation loss on the same splits GPT-2 used. MicroRWKV reaches competitive performance with the efficiency benefits of linear attention.

ModelParametersTrain lossVal loss
MicroRWKV (ours)130M2.852.88
GPT-2124M2.822.86

The small gap in training loss reflects the tradeoff made for efficiency. Linear attention cannot attend to all previous tokens equally, but the constant-time inference and linear memory scaling make deployment feasible in resource-constrained environments where transformer inference is not.

Efficiency characteristics

Constant per-token latency

RWKV linear attention processes each token independently. No quadratic dependency on sequence length.

Linear total latency

Processing N tokens takes N × constant time. Transformer inference is O(N²) in the attention layers.

Constant memory

Hidden state is a fixed-size recurrent state. No KV cache that grows with sequence length.

No custom CUDA kernel

Pure PyTorch operations. Runs anywhere PyTorch runs, including CPU-only environments.

CPU-trainable

The model trained to convergence on CPU. Slow, but possible, which is not true for many architectures at this scale.

Visualizations

Loss curves and attention mechanism internals from the training run.

Training and validation loss curves over 10000 iterations
Training and validation loss
MicroRWKV benchmark results across sequence lengths
Benchmark results
RWKV time-mixing attention weights visualization
Time-mixing attention weights
RWKV channel-mixing feature visualization
Channel-mixing features
MicroRWKV inference time comparison across sequence lengths
Inference-time comparison