Skip to main content

rwkv-tl

RWKV7 inference with TileLang fused CUDA kernels and CUDA Graph. The goal is to make decode and prefill faster than the pure PyTorch baseline and approach the performance of the Albatross reference implementation.

  • Model: RWKV7-g1d (0.1B and 0.4B variants)
  • Precision: bfloat16 compute with float32 accumulation in the DPLR state update
  • Paths:
    • Decode (T=1): fused TMIX/CMIX kernels plus GraphDecoder
    • Prefill (T>1): batched TMIX/CMIX kernels that turn token-wise GEMV into batched GEMM

Project layout

src/rwkv_tl/        # main implementation and fused kernels
script/             # benchmarking and profiling scripts
test/               # correctness and kernel tests
asset/              # tokenizer vocabulary

Install and test

cd rwkv-tl
uv sync
.venv/bin/python -m pytest test/ -v

Benchmark status

The numbers below were collected on an NVIDIA MX450. They are useful for relative comparisons on the same hardware, but they are not the final target validation numbers.

The next validation run will be on an RTX 3060.

Case rwkv_tl pure_torch graph_decoder
1x1 58.21 ms / 17.18 tok/s 22.76 ms / 43.93 tok/s 8.35 ms / 119.79 tok/s
8x8 265.70 ms / 240.87 tok/s 398.34 ms / 160.67 tok/s not supported
16x16 899.69 ms / 284.54 tok/s 1341.51 ms / 190.83 tok/s not supported

Key points:

  • GraphDecoder is best for single-token decode latency.
  • rwkv_tl is the only path that supports both batched prefill and decode.
  • The pure-torch baseline was substantially improved by batching the prefill path.

Run benchmark

.venv/bin/python script/benchmark_rwkv7.py \
  --project-checkpoint <checkpoint.pth> \
  --vocab asset/rwkv_vocab_v20230424.txt \
  --targets rwkv_tl,pure_torch,graph_decoder \
  --device cuda \
  --cases 1x1,1x8,1x32,2x1,8x1,8x8,16x16 \
  --warmup 10 --iters 20

On memory-constrained machines, split large sweeps into separate processes to avoid compiler-cache pressure and OOMs.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rwkv_tl-0.1.0.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rwkv_tl-0.1.0-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

File details

Details for the file rwkv_tl-0.1.0.tar.gz.

File metadata

  • Download URL: rwkv_tl-0.1.0.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for rwkv_tl-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2eb3388c486a9e2dfa1e83a3b72e3728f7a66cfdde77bffa3a2eb0f8273052cc
MD5 26b46f3641f44bc22e5a5ca14a31901b
BLAKE2b-256 007fdc41e2adfeedbad8d7a39f950c0a99a7248d51cedfce8c27e2e0dbb0d3e1

See more details on using hashes here.

File details

Details for the file rwkv_tl-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rwkv_tl-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for rwkv_tl-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4ae47b55551c2968f3786df8f6d3e9098a00384779242ee74f70acdd079416c5
MD5 362f02bd1d981a2f6cc14535659f1ce8
BLAKE2b-256 b4f0c40d9cedce42b1573e8b735ab50f5ff397ad235aceea3c043601b54fac93

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.1

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

This release

0.1.0 This release

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page