跳到主要内容
Octopus Research Institute
TR-2026-0009技术报告同行评审: 未经同行评审证据强度: 实验性状态: 已发布

RWKV in a self-built engine: a second non-attention paradigm (WKV/RNN)

Ran Tao (Octoryn Research)

本文未经同行评审。请将其视为工作文档,而非经验证的结果。

摘要

A correctness-validation port of the RWKV-4-169m hand-written WKV linear-attention/RNN recurrence (pre-LN, token-shift, fp32-state max-trick, time/channel-mix gating; no attention or KV cache) into a self-built dense ROCm engine on one consumer-class AMD GPU. Against a Hugging Face transformers oracle on identical token ids, f16 prefill logits matched at cosine 1.0, argmax 12/12 across 12 positions; a kill-WKV control fell to 0.96 (3/12), so the recurrence is load-bearing. A single-run forward-parity smoke test on one small model; not a quality, throughput, quantized, or larger-model result.

本 Research Object 以其原始语言(英文)发表。

Contribution

Claimed. A hand-written WKV recurrence (RWKV-4 linear-attention / RNN) for RWKV-4-169m, ported into a self-built dense ROCm inference engine, reproduces a Hugging Face transformers f16 prefill-logit oracle at cosine 1.0, argmax 12/12 for the tested prompt(s) and token positions on a single consumer-class AMD GPU (RDNA2, 16 GB). A kill-WKV negative control collapses the same metric to cosine 0.96, argmax 3/12 (FAIL), demonstrating that the WKV recurrence is load-bearing rather than incidental. This is the engine's second non-attention sequence mixer (after a state-space model), implemented directly from the reference equations with no third-party RWKV package and no vendor BLAS in the dependency closure.

NOT claimed. This is a correctness-validation (forward-parity) result, not a novel algorithm and not a performance result. It does not claim: generation quality, decode/throughput numbers, benchmark-scale evaluation, long-context recurrence stability, quantized (q8/q4) parity, correctness of larger RWKV versions (v5/v6), or any hybrid attention+recurrence behavior. The altitude is honest: re-deriving a known recurrence and proving the engine's forward matches an oracle on a small stimulus.

Methods

FieldValue
HardwareConsumer-class AMD GPU (RDNA2, 16 GB)
ModelRWKV-4-169m
StackSelf-built dense ROCm engine, hand-written WKV kernel; internal parity harness
Oracle / baselineHugging Face transformers (recent release)
ProcedureDirect f16 logit parity vs oracle on identical input token ids; per-position cosine + argmax match over 12 rows
Precisionf16 forward; WKV numerator/denominator/max state carried in fp32 (standard max-trick for numerical stability)
Metric + gatePer-position cosine similarity and argmax agreement (12 positions)
Stimulus / inputsPrompt(s) tokenized to identical ids vs oracle (exact prompt text not recorded in source notes)

Results

ConfigurationCosineArgmax match
RWKV-4-169m f16 vs transformers1.012/12
Negative control: kill-WKV recurrence0.963/12 (FAIL)

Ablations / Negative controls

ControlChangeOutcomeInterpretation
kill-WKVRemove the WKV recurrence (the model's memory)cosine 0.96, argmax 3/12 FAILWKV is load-bearing; without it the forward breaks

Threats to validity / Limitations

  • Sample size is a smoke test, not a benchmark. The evidence is parity over 12 token positions for the tested prompt(s) — a correctness smoke test, not a benchmark-scale evaluation.
  • Single run, no variance. Reported as one measurement; no repeated trials, seeds, or variance bands.
  • Parity != quality. Cosine 1.0 / argmax 12/12 establishes forward fidelity against the oracle, NOT generation quality, coherence, or downstream task performance.
  • Precision ceiling. The engine's highest precision here is f16; there is no f32 forward path. f16-tie / sub-ULP ambiguities, where present, are irreducible.
  • Scope bound to one tiny model. RWKV-4-169m only. No claim for larger RWKV-4 sizes, v5/v6, long-context recurrence stability, quantized paths, throughput, or hybrid attention+recurrence designs.
  • Oracle/version not pinned in source. The exact transformers version and prompt text are not recorded in the source notes; the parity is only as trustworthy as the (unrecorded) oracle version. Validate the oracle independently before relying on this.
  • evidenceLevel = experimental is appropriate; this note does not upgrade beyond a single-box, single-run correctness check.

Reproducibility / Provenance

  • Model: RWKV-4-169m (ported into the self-built dense ROCm engine).
  • Implementation: hand-written pre-LN, token-shift (mix current and previous token), WKV recurrence (per-channel numerator/denominator/max in fp32 with the standard max-trick), and time-mix / channel-mix gating; no attention, KV cache, or RoPE.
  • Sovereignty check: the runtime dependency closure shows only the AMD HIP runtime and system libraries — no rocBLAS / hipBLAS / MIOpen / MKL and no third-party RWKV package.
  • Build: compiled directly against the AMD HIP runtime for the target RDNA2 architecture; no vendor math libraries linked.
  • Oracle: Hugging Face transformers (a recent release; exact version not pinned in source notes).

声明边界

作者对范围的明确界定——本工作证明了什么、未证明什么——沿用自 Octoryn Research 的发表模型。

证明

  • A hand-written, self-built WKV recurrence for RWKV-4-169m reproduces a Hugging Face transformers f16 prefill-logit oracle at cosine 1.0 with argmax agreement on all 12 tested token positions for the tested prompt(s).
  • A kill-WKV negative control drops the same metric to cosine 0.96 (argmax 3/12), demonstrating the WKV recurrence is load-bearing rather than incidental.
  • The dense ROCm engine now contains two distinct non-attention sequence mixers: a state-space model and the WKV recurrence.

未证明

  • Generation quality, coherence, decode/throughput, or any downstream task performance of the sequential recurrence.
  • Correctness for larger RWKV-4 sizes, RWKV v5/v6, or long-context recurrence stability.
  • Quantized (q8/q4) parity or behavior, or hybrid attention-plus-recurrence designs.
  • Anything beyond a small single-run correctness smoke test over 12 positions with no variance reporting.

适用于

  • Evaluating f16 prefill-logit parity for RWKV-4-169m against a transformers oracle on identical input token ids on a single consumer-class AMD GPU.

不适用于

  • Quantized, generation-quality, or throughput claims are needed, or other RWKV versions are in scope.
  • Benchmark-scale evaluation or multi-run variance is required.
  • An f32-precision forward path or long-context recurrence stability is expected.

作者

  • Ran Tao — 调查研究, 写作

引用本文

引用格式

Tao, R., Octoryn Research. (2026). RWKV in a self-built engine: a second non-attention paradigm (WKV/RNN) (TR-2026-0009). Octopus Research Institute.

BibTeX

@techreport{oritr20260009,
  title       = {RWKV in a self-built engine: a second non-attention paradigm (WKV/RNN)},
  author      = {Tao, Ran and {Octoryn Research}},
  institution = {Octopus Research Institute},
  year        = {2026},
  note        = {Permanent ID TR-2026-0009. Not peer reviewed.}
}

披露

资助
硬件与基础设施由 Octoryn / Octopus Core Pty Ltd 提供。
利益冲突
Octoryn 提供商业推理与治理工具;相关发现独立报告。