Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

flashrwkv2

Latest version: v0.2.0a5

Overview

Last scanned
27 Nov 2026
Published
27 Nov 2026
PyPI package Publisher: caizus
6 Stars
2 Forks
11 Versions
861 Downloads
Python Repo language

Scan summary

flashrwkv2 was last scanned on 27 Nov 2026 at version 0.2.0a5. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 11 versions; the latest 4 were published within 3 days (25–27 Nov 2026).
  • Findings: No rules fired in version 0.2.0a5.
  • Downloads: 861 downloads.

Versions

11 versions published
Versions and the rules that fired in each
VersionPublishedStatus
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

No rules fired in 0.2.0a5

Findings

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.

README

The publisher’s own README, as collected from the registry.

FlashRWKV2

High-Performance TileLang Operator Library for RWKV-7 — Unified Training, RL Rollout & Packed Serving

PyPI Python PyTorch TileLang License: MIT

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.


Why FlashRWKV2?

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
Key Highlights
  • Bitwise Train–Infer Parity on FP32 State: Training, prefill, and decode share the same BF16 forward and FP32 accumulation order (fixed key reduction, no split-K). With FP32 state (fp32io16), RL rollouts, evaluation, and sampling search reproduce the learner's outputs, states, and selected logprobs bitwise.
  • Two Serving State Modes: Use FP16 state with DeltaLog (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.
  • First-Class LoRA & NoRA: Built directly into TMix (receptance, key, value, output), CMix (key, value), and LM Head projections, skipping dW automatically when base weights are frozen.
  • Full-Graph 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.
  • Universal Source Wheel: Ships as a lightweight py3-none-any wheel with no precompiled binaries or architecture fallbacks — TileLang specializes kernels for your active GPU and caches them on disk.

Architecture at a Glance

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"]

Requirements & Installation

Requirements
  • Linux with a CUDA GPU of Compute Capability 8.0+ (Ampere, Ada SM89, Hopper SM90, Blackwell SM120)
  • Python 3.10+, PyTorch 2.11–2.14, TileLang 0.1.15
  • System CUDA Toolkit matching PyTorch, a C++20 host compiler, and Ninja
Install from PyPI
python -m pip install --pre FlashRWKV2

Optional — prewarm the small native extension used for packed metadata validation and sampling:

python -m flashrwkv2.compile
Development Install (uv)
git clone https://github.com/rwkv-rs/FlashRWKV2.git
cd FlashRWKV2
uv sync --group dev

Importing flashrwkv2 never compiles kernels or creates caches on CPU. TileLang and the native extension compile lazily on first CUDA invocation and persist to disk (~/.cache/flashrwkv2 or $FLASHRWKV2_CACHE_DIR).


Quickstart

1. Training WKV-7 with 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},
)
2. Packed Inference with FP16 Serving State
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)
3. Speculative Drafting with LightMTP DraftLoop
from 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.


Choosing a Precision & State Mode

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

Historical Acceptance & Performance

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%
Running Tests & Benchmarks
# 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

Documentation

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

Acknowledgements & License

FlashRWKV2 is distributed under the MIT License.

OX Radar and Response Center

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.

Where it’s listed

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).

  • pypi-releases flashrwkv2

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Plug and Pray: Your AI Agents Are Taking Orders From Strangers
Research

Plug and Pray: Your AI Agents Are Taking Orders From Strangers

Cry2Wolf: How to Tell a Real Bug from a Nothingburger
AI & VibeSec

Cry2Wolf: Not Every Branded Bug Deserves a Fire Drill

Copy of Template Design OX Blog (2)
Research

NGINX2Root: Five Critical NGINX Flaws Expose Web Servers to Remote Code Execution

Frame 2085668439 (1)
Group 1261154229