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 RTX 3060 (sm_86, 12GB), the target validation GPU. rwkv_tl and pure_torch run the eager path; the benchmark harness routes through the raw methods so a sweep does not recompile a fresh graph per token count.

Case rwkv_tl pure_torch graph_decoder
1x1 40.48 ms / 24.70 tok/s 13.74 ms / 72.77 tok/s 2.11 ms / 473.14 tok/s
1x32 118.12 ms / 270.92 tok/s 98.20 ms / 325.87 tok/s 58.78 ms / 544.42 tok/s
8x8 206.94 ms / 309.26 tok/s 171.77 ms / 372.58 tok/s not supported
16x16 758.45 ms / 337.53 tok/s 609.80 ms / 419.81 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 Albatross reference (faster3a_2607) still leads all cases by a wide margin (4.32 ms on 1x1, ~7.5 ms on all prefill cases for 0.1B).
  • Compiling prefill gives 1.11-1.43x on 0.1B, but recompiles a fresh graph per prompt length (minutes), so it stays eager. See script/benchmark_rwkv7.md and docs/benchmark_rwkv7_experiments.md.

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.1.tar.gz (19.2 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.1-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rwkv_tl-0.1.1.tar.gz
  • Upload date:
  • Size: 19.2 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.1.tar.gz
Algorithm Hash digest
SHA256 49e25c91b2d2ebaf91a322070400ac05401d524c5981652ed8718a85b71bba90
MD5 bc0860ff421349b35137d6b671aa0ee9
BLAKE2b-256 eb488a5447dba627165554622b1c80138403fee180c63b62d0e5c47dd6d88217

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rwkv_tl-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 25.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e5ee96be4323367ddd4a6db8bfc6bb1b4d4c9cb140c6da7802ca9fd4fe463106
MD5 a547d74d743bc2d526afad11f8fdd6d6
BLAKE2b-256 63693bc9ef218e8e3735e10f7d2a4a41fb13c5e4e1c49897c56f068aa271d7f3

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

This release

0.1.1 This release

2 files

0.1.0

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