SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2504.21463 · 2025

RWKV-X: A Linear Complexity Hybrid Language Model

arXiv · PDF · Open in the Atlas

Code that ran

8 of 12 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 7 have no contract verdict; 1 failure of our instrument; 4 no recorded run), measured 2026-11-24; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2504.21463.json · badge: /api/ran/2504.21463.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
howard-hou/rwkv-x canonical (classifier label)
classifier basis not recorded on the link
8 ran · 4 no recorded run
FunctionStatusWhere it lives
RWKV_x070_CMix_one Ran
ran on a synthesized input
howard-hou/rwkv-x/package/src/rwkv_x/model.py
code served (permissive licence) · get_code("3b1aee5f3ce13a07")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Analyze the function:
# - x: used in arithmetic operations (x_prev - x, x + ..., x @ K_)
#   so it's a tensor
# - x_prev: used in arithmetic (x_prev - x), so it's a tensor
# - x_k: used in arithmetic (xx * x_k), so it's a tensor
# - K_: used in matrix multiplication (k @ K_), so it's a tensor
# - V_: used in matrix multiplication (k @ V_), so it's a tensor

# From the operations:
# xx = x_prev - x: element-wise subtraction
# k = x + xx * x_k: element-wise addition and multiplication
# k = torch.relu(k @ K_) ** 2: matrix multiplication then element-wise operations
# return (k @ V_, x): matrix multiplication

# Let's set dimensions:
# x and x_prev should have compatible shapes for subtraction
# x_k should be compatible for element-wise multiplication
# K_ should be compatible for matrix multiplication with k
# V_ should be compatible for matrix multiplication with k

# Let's say x, x_prev, x_k are shape (batch=2, features=4)
# Then k @ K_ means k is (2, 4) and K_ should be (4, 3) to get (2, 3)
# Then k @ V_ means k is (2, 3) and V_ should be (3, 5) to get (2, 5)

batch_size = 2
feature_dim = 4
intermediate_dim = 3
output_dim = 5

x = torch.randn(batch_size, feature_dim)
x_prev = torch.randn(batch_size, feature_dim)
x_k = torch.randn(batch_size, feature_dim)
K_ = torch.randn(feature_dim, intermediate_dim)
V_ = torch.randn(intermediate_dim, output_dim)

ARGS = {
    'x': x,
    'x_prev': x_prev,
    'x_k': x_k,
    'K_': K_,
    'V_': V_
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
RWKV_x070_CMix_seq Ran
ran on a synthesized input
howard-hou/rwkv-x/package/src/rwkv_x/model.py
code served (permissive licence) · get_code("449b983cd5aa924b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Analyze the function:
# - x: tensor, indexed with [:-1, :] and [-1, :], used in matrix mult with K_, shape (seq, dim)
# - x_prev: tensor, unsqueezed to (1, dim) and cat'd with x[:-1, :]
# - x_k: tensor, multiplied element-wise with xx, shape should be (dim,) or (dim, dim)
# - K_: matrix for @ operation, shape (dim, hidden_dim)
# - V_: matrix for @ operation, shape (hidden_dim, output_dim)

# Dimensions:
# seq_len = 2, input_dim = 4, hidden_dim = 3, output_dim = 5

seq_len = 2
input_dim = 4
hidden_dim = 3
output_dim = 5

x = torch.randn(seq_len, input_dim)  # (2, 4)
x_prev = torch.randn(input_dim)  # (4,)
x_k = torch.randn(input_dim)  # (4,)
K_ = torch.randn(input_dim, hidden_dim)  # (4, 3)
V_ = torch.randn(hidden_dim, output_dim)  # (3, 5)

ARGS = {
    "x": x,
    "x_prev": x_prev,
    "x_k": x_k,
    "K_": K_,
    "V_": V_,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
RWKV_x070_TMix_one Ran
ran; our contract draft was wrong, not the code
howard-hou/rwkv-x/package/src/rwkv_x/model.py
code served (permissive licence) · get_code("1ce560658d1f24ec")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Analyze the function to determine dimensions
# H = number of heads
# N = feature dimension per head
# Total feature dimension = H * N

H = 2
N = 3
D = H * N  # total dimension = 6

layer_id = 0

# Create small tensors for input/output
x = torch.randn(D)
x_prev = torch.randn(D)
v_first = torch.randn(D)
state = torch.randn(H, N, N)

# Shift/mix parameters (scalars)
x_r = torch.tensor(0.1)
x_w = torch.tensor(0.1)
x_k = torch.tensor(0.1)
x_v = torch.tensor(0.1)
x_a = torch.tensor(0.1)
x_g = torch.tensor(0.1)

# w parameters for tanh(xw @ w1) @ w2
w0 = torch.randn(1)
w1 = torch.randn(D, 4)
w2 = torch.randn(4, D)

# a parameters for sigmoid(a0 + xa @ a1 @ a2)
a0 = torch.randn(1)
a1 = torch.randn(D, 5)
a2 = torch.randn(5, D)

# v parameters for sigmoid(v0 + xv @ v1 @ v2)
v0 = torch.randn(1)
v1 = torch.randn(D, 4)
v2 = torch.randn(4, D)

# g parameters for sigmoid(xg @ g1) @ g2
g1 = torch.randn(D, 5)
g2 = torch.randn(5, D)

# k parameters
k_k = torch.tensor(1.0)
k_a = torch.tensor(0.1)

# r parameter
r_k = torch.tensor(0.5)

# Projection matrices
R_ = torch.randn(D, D)
K_ = torch.randn(D, D)
V_ = torch.randn(D, D)
O_ = torch.randn(D, D)

# Layer norm parameters
ln_w = torch.ones(H * N)
ln_b = torch.zeros(H * N)

ARGS = {
    'layer_id': layer_id,
    'H': H,
    'N': N,
    'x': x,
    'x_prev': x_prev,
    'v_first': v_first,
    'state': state,
    'x_r': x_r,
    'x_w': x_w,
    'x_k': x_k,
    'x_v': x_v,
    'x_a': x_a,
    'x_g': x_g,
    'w0': w0,
    'w1': w1,
    'w2': w2,
    'a0': a0,
    'a1': a1,
    'a2': a2,
    'v0': v0,
    'v1': v1,
    'v2': v2,
    'g1': g1,
    'g2': g2,
    'k_k': k_k,
    'k_a': k_a,
    'r_k': r_k,
    'R_': R_,
    'K_': K_,
    'V_': V_,
    'O_': O_,
    'ln_w': ln_w,
    'ln_b': ln_b,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
compute_stats Ran
ran on a synthesized input
howard-hou/rwkv-x/probing/headwise_memory_loss.py
code served (permissive licence) · get_code("847084be6c83567e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# The function takes a list of floats and computes statistics on them
# It converts the list to a tensor and computes count, mean, variance, min, max, and median
values = [1.0, 2.5, 3.7, 4.2, 5.1, 6.8]

ARGS = {
    'values': values
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
generate_prompt_landmark Ran
ran on a synthesized input
howard-hou/rwkv-x/evaluation/pass_key_rwkv.py
code served (permissive licence) · get_code("e5648d7352488652")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

from numpy import random

ARGS = {
    'n_garbage': 500,
    'seed': 42,
    'n_garbage_prefix': 200,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_jsonl Ran
ran on a synthesized input
howard-hou/rwkv-x/evaluation/eval_long_loss.py
code served (permissive licence) · get_code("933d4bd3c4bd2d14")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
import tempfile
import os

# Create a temporary JSONL file with valid JSON lines
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test.jsonl")

# Write valid JSONL data (one JSON object per line)
with open(temp_file, 'w', encoding='utf-8') as f:
    f.write(json.dumps({"key": "value1", "number": 42}) + "\n")
    f.write(json.dumps({"key": "value2", "number": 43}) + "\n")
    f.write(json.dumps({"key": "value3", "number": 44}) + "\n")

ARGS = {
    "filename": temp_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
passkey_retrieval_test Ran
ran on a synthesized input
howard-hou/rwkv-x/evaluation/pass_key_rwkv.py
code served (permissive licence) · get_code("5187fd0702621821")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from numpy import random

torch.manual_seed(0)

class SimpleTokenizer:
    """Minimal tokenizer that encodes/decodes strings as token sequences."""
    def __init__(self):
        self.vocab_size = 256
    
    def encode(self, text):
        """Convert text to list of token ids (using character codes as simple tokens)."""
        # Simple encoding: use character codes modulo vocab_size
        tokens = [ord(c) % self.vocab_size for c in text]
        return tokens
    
    def decode(self, token_ids):
        """Convert list of token ids back to text."""
        if isinstance(token_ids, list):
            chars = [chr(tid % 256) for tid in token_ids]
        else:
            chars = [chr(tid.item() % 256) for tid in token_ids]
        return ''.join(chars)

class SimpleModel(nn.Module):
    """Minimal model that takes token ids and returns logits and state."""
    def __init__(self, vocab_size=256, hidden_size=8):
        super().__init__()
        self.embedding = nn.Embedding(vocab_size, hidden_size)
        self.linear = nn.Linear(hidden_size, vocab_size)
        self.vocab_size = vocab_size
        self.hidden_size = hidden_size
    
    def forward(self, input_ids, state=None):
        """
        Args:
            input_ids: list or tensor of token ids
            state: optional hidden state
        
        Returns:
            logits: tensor of shape (1, vocab_size)
            state: updated hidden state (simple tensor)
        """
        if isinstance(input_ids, list):
            input_ids = torch.tensor(input_ids, dtype=torch.long)
        
        # Embed tokens
        embedded = self.embedding(input_ids)  # shape: (seq_len, hidden_size)
        
        # Process sequence
        if state is None:
            state = torch.zeros(1, self.hidden_size)
        
        # Simple RNN-like update: just take mean of embeddings and add to state
        seq_mean = embedded.mean(dim=0, keepdim=True)  # (1, hidden_size)
        new_state = state + seq_mean * 0.1
        
        # Compute logits from final state
        logits = self.linear(new_state)  # (1, vocab_size)
        
        return logits, new_state

# Create instances
tokenizer = SimpleTokenizer()
model = SimpleModel(vocab_size=256, hidden_size=8)
device = 'cpu'

ARGS = {
    'model': model,
    'tokenizer': tokenizer,
    'device': device,
    'n_garbage_prefix': 1000,
    'n_garbage': 5000,
    'seed': 42,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family int — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
plot_heatmap Ran
ran on a synthesized input
howard-hou/rwkv-x/evaluation/pass_key_rwkv.py
code served (permissive licence) · get_code("c0d04f50608c2981")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned PosixPath. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import pandas as pd
import numpy as np
from pathlib import Path

# Create a minimal args class that has the required attributes
class Args:
    def __init__(self):
        self.log_name = '/tmp/test_log'
        self.base_model = '/tmp/model_checkpoint.pt'
        self.max_tokens = 2048

# Create sample DataFrame with the expected structure
np.random.seed(0)
data = {
    'Score': np.random.uniform(20, 95, 20),
    'Document Depth': [10, 20, 30, 40, 50] * 4,
    'Context Length': [1024, 2048, 4096, 8192, 16384] * 4
}
df = pd.DataFrame(data)

args = Args()

ARGS = {
    'df': df,
    'args': args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
matplotlib, numpy, pandas, seaborn — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PosixPath — a PosixPath output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a PosixPath output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
RWKV_x070_TMix_one Not yet run
unverified (harvested, no recorded run)
howard-hou/rwkv-x/package/src/rwkv_x/model_exp.py
code served (permissive licence) · get_code("9f893ae6059d283e")
How it ran

no invocation recorded.

calculate_headwise_memory_loss Not yet run
unverified (harvested, no recorded run)
howard-hou/rwkv-x/probing/headwise_memory_loss.py
code served (permissive licence) · get_code("f0846b300e2b4057")
How it ran

no invocation recorded.

load_hf Not yet run
unverified (harvested, no recorded run)
howard-hou/rwkv-x/evaluation/eval_long_loss.py
code served (permissive licence) · get_code("74db7dd3f1b3abf4")
How it ran

no invocation recorded.

load_rwkv Not yet run
unverified (harvested, no recorded run)
howard-hou/rwkv-x/evaluation/eval_long_loss.py
code served (permissive licence) · get_code("60ad8220063142d0")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 0 later) and 11 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
RWKV_x070_TMix_one 1 other paper
1 dated earlier
2503.14456 (2025-03)
RWKV-7 "Goose" with Expressive Dynamic State Evolution

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-24.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

In this paper, we introduce RWKV-X, a novel hybrid architecture that combines the efficiency of RWKV for short-range modeling with a sparse attention mechanism designed to capture long-range context. Unlike previous hybrid approaches that rely on full attention layers and retain quadratic complexity, RWKV-X achieves linear-time complexity in training and constant-time complexity in inference decoding. We demonstrate that RWKV-X, when continually pretrained on 64K-token sequences, achieves near-perfect accuracy on the 64K passkey retrieval benchmark. It consistently outperforms prior RWKV-7 models on long-context benchmarks, while maintaining strong performance on short-context tasks. These results highlight RWKV-X as a scalable and efficient backbone for general-purpose language modeling, capable of decoding sequences up to 1 million tokens with stable speed and memory usage. To facilitate further research and analysis, we have made the checkpoints and the associated code publicly accessible at: https://github.com/howard-hou/RWKV-X.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2504.21463")
get_code_for_paper("2504.21463")
have("2504.21463")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2504.21463.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2504.21463.svg)](https://syntology.ai/paper/2504.21463)

Connect an agent — have() is free.