Scan your whole stack
Are you using flashrwkv2?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v0.2.0a5
flashrwkv2 was last scanned on 27 Nov 2026 at version 0.2.0a5. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 0.2.0a5 LATEST | 27 Nov 2026 | No rules fired |
| 0.2.0a4 | 25 Nov 2026 | No rules fired |
| 0.2.0a3 | 25 Nov 2026 | No rules fired |
| 0.2.0a2 | 25 Nov 2026 | Not shown |
| 0.2.0a1 | 19 Nov 2026 | Not shown |
Findings for v0.2.0a5. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 0.2.0a5; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
High-Performance TileLang Operator Library for RWKV-7 — Unified Training, RL Rollout & Packed Serving
English | 简体中文
FlashRWKV2 is the community operator backend for RWKV-7, built on TileLang for both training and high-throughput serving. It exposes RWKV-7's highest semantic fusion islands (tokenshift, wkv_prepare, wkv7, readout, cmix, head, sampling, mtp) while keeping tiling, dispatch, and hardware specialization clean and internal.
Complete models, schedulers, and training frameworks stay lightweight in downstream projects — FlashRWKV2 handles the fast, numerically exact kernels underneath.
Choosing an RWKV-7 kernel backend usually involves trade-offs across backend portability, full-layer serving features, PEFT integration, and train–inference parity. FlashRWKV2 unifies these capabilities in one TileLang codebase:
| Capability | FlashRWKV2 (Ours) | RWKV-CUDA (train_temp) |
Albatross | FLA (flash-linear-attention) |
|---|---|---|---|---|
| Kernel Backend | TileLang (maintainable, GPU-specialized DSL) | Handwritten CUDA only | Handwritten CUDA only | Triton |
| WKV Formulation | Exact recurrence (BF16 IO + FP32 accum) | Exact recurrence | FP16 inference recurrence | Chunk-form & fused recurrent (cu_seqlens + final state) |
| Train–Infer Numerical Parity | Bitwise-exact with FP32 state (fp32io16); optional FP16 serving state (fp16) |
Training-only | FP16-only inference (differs from FP32 training) | Separate chunk / recurrent Triton paths |
| Full-Layer Serving Islands | End-to-end (tokenshift, wkv_prepare, wkv7, readout, cmix, head, sampling) |
WKV training kernel | Full FP16 inference engine (fixed-batch, no varlen) | WKV-focused operators |
| Serving State Pool & Live Graphs | Built-in (FP16 + DeltaLog, COW slots, live CUDA Graph metadata validation) | No | Fixed-batch state (no scheduler / varlen) | Functional state I/O (caller manages pools & graphs) |
| PEFT (LoRA / NoRA) | Built-in (TMix, CMix, LM Head; skips dW when frozen) |
Limited / manual | No | External wrappers |
| RL Rollout & InfCtx | Bitwise learner–rollout parity (fp32io16 + differentiable rl_infctx) |
No serving rollout | Train–infer FP16 mismatch | Functional recurrent state |
| Speculative Decoding | Built-in (batched LightMTP DraftLoop, scratch verification, state-only commit and optional per-token checkpoints) |
No | No | No |
fp32io16), RL rollouts, evaluation, and sampling search reproduce the learner's outputs, states, and selected logprobs bitwise.fp16) on SM89 (RTX 4090) and SM120 (PRO 6000) to halve state VRAM/bandwidth for general serving (per-token FP16 state rounding means outputs can differ from the FP32 learner), or use FP32 state (fp32io16) whenever exact training/RL parity is required.receptance, key, value, output), CMix (key, value), and LM Head projections, skipping dW automatically when base weights are frozen.torch.compile & CUDA Graph: All training operators support torch.compile(fullgraph=True) (including backward and LoRA/NoRA); all serving operators support live-capacity CUDA Graph capture and zero-overhead replay.py3-none-any wheel with no precompiled binaries or architecture fallbacks — TileLang specializes kernels for your active GPU and caches them on disk.flowchart LR
Emb["Embedding LN0"] --> TS["TMix: tokenshift<br/>(PostNorm + 6-way Shift)"]
TS --> Prep["TMix: wkv_prepare<br/>(R/K/V + LowRank W/A/G/V + VRes)"]
Prep --> WKV["TMix: wkv7<br/>(FP32 Train / FP16+DeltaLog Serving)"]
WKV --> RO["TMix: readout<br/>(Head LN + RKV Res + Gate + Out)"]
RO --> CMix["CMix<br/>(PostNorm + Shift + ReLU² FFN)"]
CMix --> PN["PostNorm"]
PN --> Head["LM Head<br/>(FP32 Logits / Chunked CE / L2Wrap)"]
Head --> Sample["6-Param Sampling<br/>& LightMTP DraftLoop"]
python -m pip install --pre FlashRWKV2
Optional — prewarm the small native extension used for packed metadata validation and sampling:
python -m flashrwkv2.compile
uv)git clone https://github.com/rwkv-rs/FlashRWKV2.git
cd FlashRWKV2
uv sync --group dev
Importing
flashrwkv2never compiles kernels or creates caches on CPU. TileLang and the native extension compile lazily on first CUDA invocation and persist to disk (~/.cache/flashrwkv2or$FLASHRWKV2_CACHE_DIR).
torch.compile(fullgraph=True)import torch
import flashrwkv2
B, T, H, D = 2, 1024, 64, 64
C = H * D
device = "cuda"
r, w, k, v, a, b = (
torch.randn(B, T, C, device=device, dtype=torch.bfloat16, requires_grad=True)
for _ in range(6)
)
state = torch.zeros(B, H, D, D, device=device, dtype=torch.float32, requires_grad=True)
# Dense [B, T, C] forward + backward with differentiable FP32 state
y, final_state = flashrwkv2.pretrain_tmix_wkv7_recurrent_bf16(
r, w, k, v, a, b,
head_size=D,
initial_state=state,
return_final_state=True,
)
y.sum().backward()
To preserve exact BF16 intermediate rounding under torch.compile(fullgraph=True):
compiled_model = torch.compile(
model,
fullgraph=True,
options={"emulate_precision_casts": True},
)
import torch
import flashrwkv2
pool_slots, H, D = 64, 64, 64
device = "cuda"
# Bind a contiguous FP16 state pool (preferred for SM89 / SM120 serving)
raw_pool = torch.zeros(pool_slots, H, D, D, device=device, dtype=torch.float16)
state_handle = flashrwkv2.prepare_tmix_wkv7_recurrent_fp16_state_from_tensor(raw_pool)
# Packed batch: seq 0 has 128 tokens (prefill), seq 1 has 1 token (decode)
cu_seqlens = torch.tensor([0, 128, 129], device=device, dtype=torch.int32)
state_indices = torch.tensor([3, 7], device=device, dtype=torch.int32)
N = int(cu_seqlens[-1])
r, w, k, v, a, b = (
torch.randn(N, H, D, device=device, dtype=torch.bfloat16) for _ in range(6)
)
# Validate once and reuse the ticket across all layers in the step
ticket = flashrwkv2.prepare_tmix_wkv7_recurrent_metadata(
cu_seqlens,
state_indices,
state_pool_size=pool_slots,
total_tokens=N,
)
y = flashrwkv2.infer_tmix_wkv7_recurrent_fp16_forward_varlen(
r, w, k, v, a, b,
state=state_handle,
cu_seqlens=cu_seqlens,
state_indices=state_indices,
validated_metadata=ticket,
)
# Always materialize before inspecting or copying the bound raw tensor directly
state_handle.materialize_slots_(state_indices)
LightMTP DraftLoopfrom flashrwkv2.mtp import DraftLoop
loop = DraftLoop.from_state_dict(mtp_weights, lm_head_weight, depth=4)
# CUDA BF16 hidden [B, C] and CUDA int64 token_ids [B]
eager_ids = loop(hidden, token_ids, embed).clone() # [B, 4]
# Capture separate CUDA Graphs for the batch sizes used by the scheduler
for batch_size in (1, 4, 64, 320, 512):
loop.capture(embed, batch_size=batch_size)
graph_ids = loop.replay(hidden, token_ids)
Drafting retains only the token IDs across steps. Each step releases its FP32 [B, V] logits after argmax. The loader supports canonical mtp.* weights, legacy block.* sidecars, and optional LoRA/NoRA parameters for the LM head.
For low-memory verification, copy active WKV slots into a single-layer scratch pool and run Verify with save=False. Pack each sequence's accepted_b + 1 tokens for Commit and advance the main pool with r=None. A live metadata ticket limits each graph replay's slot copy to the active rows. See the WKV7 recurrence API.
| Workload | Recommended WKV API | State Dtype | Why |
|---|---|---|---|
| Pretraining / SFT / LoRA / NoRA | pretrain_tmix_wkv7_recurrent_bf16 |
FP32 | Differentiable state, dense or packed, torch.compile(fullgraph=True) |
| RL Rollout, Eval & Sampling Search | infer_tmix_wkv7_recurrent_fp32io16_forward_varlen + rl_infctx_tmix_wkv7_recurrent_bf16 |
FP32 | Bitwise identical outputs, states, and selected logprobs vs learner |
| General Serving (Prefill + Decode) | infer_tmix_wkv7_recurrent_fp16_forward_varlen |
FP16 (+ DeltaLog) | Halved state bandwidth & VRAM, BF16 IO + FP32 math, per-token FP16 rounding |
The figures below are historical acceptance records measured on SM89 (RTX 4090, 128 SMs) and SM120 (RTX PRO 6000, 188 SMs) at commits a239bc3 and 07c7913 (raw paired samples and numerical evidence are archived in artifacts/cmix-acceptance-a239bc3.json and artifacts/sm120-remaining-acceptance-results-07c7913.json). Validate runtime changes on their own commits using the release acceptance procedure.
Historical Acceptance Metric (a239bc3 / 07c7913) |
SM89 (RTX 4090) | SM120 (PRO 6000) |
|---|---|---|
| Full block GPU test suite (numerics, state, Graph, compile) | 330 / 330 passed | 330 / 330 passed |
| Training workloads within 2% of best internal comparison | 9 / 9 | 9 / 9 |
| Fresh-process disk-cache reuse (cold / warm compilations) | 139 cold / 0 warm | 137 cold / 0 warm |
Selected SM120 training latency from commit 07c7913 (B=1, Layer + LM Head, forward + backward + grad zero, paired ABBA CUDA Graph timing; comparison is the fastest of baseline, earlier offline reference, and previous FlashRWKV2 strategy):
| Model & Workload | Best Internal Comparison (ms) | Prepared Strategy (ms) | Change |
|---|---|---|---|
RWKV-7 1.5B T=128 (torch.compile) |
3.603 | 3.577 | -0.71% |
| RWKV-7 7.2B T=1024 (eager) | 32.786 | 32.196 | -1.80% |
| RWKV-7 13.3B T=128 (eager) | 7.399 | 7.311 | -1.20% |
| RWKV-7 13.3B T=1024 (eager) | 32.897 | 32.267 | -1.91% |
# Run full test suite
./.venv/bin/python -m pytest -q
# Benchmark WKV7 across model geometries (with bitwise verification + CUDA Graph timing)
PYTHONPATH=benchmarks ./.venv/bin/python benchmarks/tmix/wkv7/bench.py \
--shapes h40d64 h64d64 --state-dtype float16 --timing-mode graph \
--metadata live --slot-order random --state-pool-size 320 \
--cases 255x1+1x4 255x1+1x256 1x1024
# Benchmark LightMTP DraftLoop (RWKV-7 G1k 7.2B draft shape, B=1/4/64/320/512)
PYTHONPATH=benchmarks ./.venv/bin/python benchmarks/mtp/bench.py --depth 4
| Document | Audience | Contents |
|---|---|---|
| Quickstart & Recipes | Users | End-to-end training block, LoRA/NoRA, RL rollout, MTP rewind, benchmarks |
| Serving & State Guide | Serving Engineers | FP16 vs FP32 state, DeltaLog memory budgeting, COW pools, live CUDA Graphs |
| Kernel API & Numerical Contract | Integrators | Complete operator table, math definitions, shapes, dtypes, compilation rules |
| Release Acceptance | Maintainers | Dual-GPU SM89/SM120 verification and manual PyPI publishing |
| PR Review Guide | Contributors | Review checklist and upstream consistency rules |
FlashRWKV2 is distributed under the MIT License.
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.