Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +9 -0
- README.md +6 -0
- build.toml +31 -0
- build/torch27-cxx11-cu118-x86_64-linux/rwkv/__init__.py +170 -0
- build/torch27-cxx11-cu118-x86_64-linux/rwkv/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch27-cxx11-cu118-x86_64-linux/rwkv/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch27-cxx11-cu118-x86_64-linux/rwkv/_ops.py +9 -0
- build/torch27-cxx11-cu118-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so +3 -0
- build/torch27-cxx11-cu126-x86_64-linux/rwkv/__init__.py +170 -0
- build/torch27-cxx11-cu126-x86_64-linux/rwkv/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch27-cxx11-cu126-x86_64-linux/rwkv/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch27-cxx11-cu126-x86_64-linux/rwkv/_ops.py +9 -0
- build/torch27-cxx11-cu126-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so +3 -0
- build/torch27-cxx11-cu128-x86_64-linux/rwkv/__init__.py +170 -0
- build/torch27-cxx11-cu128-x86_64-linux/rwkv/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch27-cxx11-cu128-x86_64-linux/rwkv/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch27-cxx11-cu128-x86_64-linux/rwkv/_ops.py +9 -0
- build/torch27-cxx11-cu128-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so +3 -0
- build/torch28-cxx11-cu126-x86_64-linux/rwkv/__init__.py +170 -0
- build/torch28-cxx11-cu126-x86_64-linux/rwkv/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch28-cxx11-cu126-x86_64-linux/rwkv/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch28-cxx11-cu126-x86_64-linux/rwkv/_ops.py +9 -0
- build/torch28-cxx11-cu126-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so +3 -0
- build/torch28-cxx11-cu128-x86_64-linux/rwkv/__init__.py +170 -0
- build/torch28-cxx11-cu128-x86_64-linux/rwkv/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch28-cxx11-cu128-x86_64-linux/rwkv/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch28-cxx11-cu128-x86_64-linux/rwkv/_ops.py +9 -0
- build/torch28-cxx11-cu128-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so +3 -0
- build/torch28-cxx11-cu129-x86_64-linux/rwkv/__init__.py +170 -0
- build/torch28-cxx11-cu129-x86_64-linux/rwkv/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch28-cxx11-cu129-x86_64-linux/rwkv/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch28-cxx11-cu129-x86_64-linux/rwkv/_ops.py +9 -0
- build/torch28-cxx11-cu129-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so +3 -0
- build/torch29-cxx11-cu126-x86_64-linux/rwkv/__init__.py +170 -0
- build/torch29-cxx11-cu126-x86_64-linux/rwkv/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch29-cxx11-cu126-x86_64-linux/rwkv/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch29-cxx11-cu126-x86_64-linux/rwkv/_ops.py +9 -0
- build/torch29-cxx11-cu126-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so +3 -0
- build/torch29-cxx11-cu128-x86_64-linux/rwkv/__init__.py +170 -0
- build/torch29-cxx11-cu128-x86_64-linux/rwkv/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch29-cxx11-cu128-x86_64-linux/rwkv/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch29-cxx11-cu128-x86_64-linux/rwkv/_ops.py +9 -0
- build/torch29-cxx11-cu128-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so +3 -0
- build/torch29-cxx11-cu130-x86_64-linux/rwkv/__init__.py +170 -0
- build/torch29-cxx11-cu130-x86_64-linux/rwkv/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch29-cxx11-cu130-x86_64-linux/rwkv/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch29-cxx11-cu130-x86_64-linux/rwkv/_ops.py +9 -0
- build/torch29-cxx11-cu130-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so +3 -0
- flake.lock +168 -0
- flake.nix +17 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,12 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
build/torch27-cxx11-cu118-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
build/torch27-cxx11-cu126-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
build/torch27-cxx11-cu128-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
build/torch28-cxx11-cu126-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
build/torch28-cxx11-cu128-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
build/torch28-cxx11-cu129-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
build/torch29-cxx11-cu126-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
build/torch29-cxx11-cu128-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
build/torch29-cxx11-cu130-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- kernel
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
RWKV kernel for transformers
|
build.toml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[general]
|
| 2 |
+
name = "rwkv"
|
| 3 |
+
universal = false
|
| 4 |
+
|
| 5 |
+
[torch]
|
| 6 |
+
src = [
|
| 7 |
+
"torch-ext/torch_binding.cpp",
|
| 8 |
+
]
|
| 9 |
+
|
| 10 |
+
[kernel.rwkv]
|
| 11 |
+
depends = ["torch"]
|
| 12 |
+
backend = "cuda"
|
| 13 |
+
cuda-capabilities = [
|
| 14 |
+
"8.0",
|
| 15 |
+
"8.9",
|
| 16 |
+
"9.0",
|
| 17 |
+
"10.0",
|
| 18 |
+
"12.0",
|
| 19 |
+
]
|
| 20 |
+
include = ["."]
|
| 21 |
+
src = [
|
| 22 |
+
"rwkv/wkv_cuda.cu",
|
| 23 |
+
"rwkv/wkv_cuda_bf16.cu",
|
| 24 |
+
]
|
| 25 |
+
cuda-flags = [
|
| 26 |
+
"-res-usage",
|
| 27 |
+
"--use_fast_math",
|
| 28 |
+
"-O3",
|
| 29 |
+
"--extra-device-vectorization",
|
| 30 |
+
"-DTmax=1024",
|
| 31 |
+
]
|
build/torch27-cxx11-cu118-x86_64-linux/rwkv/__init__.py
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ._ops import ops
|
| 2 |
+
from typing import Tuple, Any
|
| 3 |
+
|
| 4 |
+
# Use a broad Tensor alias to avoid importing torch at import time.
|
| 5 |
+
from torch import Tensor
|
| 6 |
+
|
| 7 |
+
def forward(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor) -> None:
|
| 8 |
+
"""RWKV WKV forward pass (float32).
|
| 9 |
+
|
| 10 |
+
Runs the CUDA kernel and writes the result into ``y`` in-place.
|
| 11 |
+
|
| 12 |
+
Args:
|
| 13 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 14 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 15 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 16 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 17 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 18 |
+
|
| 19 |
+
Notes:
|
| 20 |
+
- All tensors must be on the same CUDA device.
|
| 21 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 22 |
+
"""
|
| 23 |
+
_validate_device_match((w, u, k, v, y))
|
| 24 |
+
ops.forward(w, u, k, v, y)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def forward_bf16(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor) -> None:
|
| 28 |
+
"""RWKV WKV forward pass (bfloat16 inputs/outputs, float32 ``w``).
|
| 29 |
+
|
| 30 |
+
Runs the CUDA kernel and writes the result into ``y`` in-place.
|
| 31 |
+
|
| 32 |
+
Args:
|
| 33 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 34 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 35 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 36 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 37 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 38 |
+
|
| 39 |
+
Notes:
|
| 40 |
+
- All tensors must be on the same CUDA device.
|
| 41 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 42 |
+
"""
|
| 43 |
+
_validate_device_match((w, u, k, v, y))
|
| 44 |
+
ops.forward_bf16(w, u, k, v, y)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def forward_with_state(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor, s: Tensor) -> None:
|
| 48 |
+
"""RWKV WKV forward pass with persistent state (float32).
|
| 49 |
+
|
| 50 |
+
Runs the CUDA kernel using and updating state ``s`` and writes the result into ``y``.
|
| 51 |
+
|
| 52 |
+
Args:
|
| 53 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 54 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 55 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 56 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 57 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 58 |
+
s: Stateful tensor, shape ``[B, C]``, dtype ``torch.float32`` (updated in-place).
|
| 59 |
+
|
| 60 |
+
Notes:
|
| 61 |
+
- All tensors must be on the same CUDA device.
|
| 62 |
+
- Shapes must agree on ``B`` and ``C``; ``y`` shares ``[B, T, C]`` with inputs.
|
| 63 |
+
"""
|
| 64 |
+
_validate_device_match((w, u, k, v, y, s))
|
| 65 |
+
ops.forward_with_state(w, u, k, v, y, s)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def forward_with_state_bf16(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor, s: Tensor) -> None:
|
| 69 |
+
"""RWKV WKV forward pass with persistent state (bfloat16 inputs/outputs, float32 ``w`` and ``s``).
|
| 70 |
+
|
| 71 |
+
Runs the CUDA kernel using and updating state ``s`` and writes the result into ``y``.
|
| 72 |
+
|
| 73 |
+
Args:
|
| 74 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 75 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 76 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 77 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 78 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 79 |
+
s: Stateful tensor, shape ``[B, C]``, dtype ``torch.float32`` (updated in-place).
|
| 80 |
+
|
| 81 |
+
Notes:
|
| 82 |
+
- All tensors must be on the same CUDA device.
|
| 83 |
+
- Shapes must agree on ``B`` and ``C``; ``y`` shares ``[B, T, C]`` with inputs.
|
| 84 |
+
"""
|
| 85 |
+
_validate_device_match((w, u, k, v, y, s))
|
| 86 |
+
ops.forward_with_state_bf16(w, u, k, v, y, s)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def backward(
|
| 90 |
+
w: Tensor,
|
| 91 |
+
u: Tensor,
|
| 92 |
+
k: Tensor,
|
| 93 |
+
v: Tensor,
|
| 94 |
+
y: Tensor,
|
| 95 |
+
gy: Tensor,
|
| 96 |
+
gw: Tensor,
|
| 97 |
+
gu: Tensor,
|
| 98 |
+
gk: Tensor,
|
| 99 |
+
gv: Tensor,
|
| 100 |
+
) -> None:
|
| 101 |
+
"""RWKV WKV backward pass (float32).
|
| 102 |
+
|
| 103 |
+
Writes gradients into the provided tensors in-place.
|
| 104 |
+
|
| 105 |
+
Args:
|
| 106 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 107 |
+
u, k, v, y: Forward-pass tensors, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 108 |
+
gy: Gradient of ``y``, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 109 |
+
gw: Gradient for ``w``, shape ``[C]``, dtype ``torch.float32`` (written in-place).
|
| 110 |
+
gu, gk, gv: Gradients for ``u``, ``k``, ``v`` respectively, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 111 |
+
|
| 112 |
+
Notes:
|
| 113 |
+
- All tensors must be on the same CUDA device.
|
| 114 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 115 |
+
"""
|
| 116 |
+
_validate_device_match((w, u, k, v, y, gy, gw, gu, gk, gv))
|
| 117 |
+
ops.backward(w, u, k, v, y, gy, gw, gu, gk, gv)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def backward_bf16(
|
| 121 |
+
w: Tensor,
|
| 122 |
+
u: Tensor,
|
| 123 |
+
k: Tensor,
|
| 124 |
+
v: Tensor,
|
| 125 |
+
y: Tensor,
|
| 126 |
+
gy: Tensor,
|
| 127 |
+
gw: Tensor,
|
| 128 |
+
gu: Tensor,
|
| 129 |
+
gk: Tensor,
|
| 130 |
+
gv: Tensor,
|
| 131 |
+
) -> None:
|
| 132 |
+
"""RWKV WKV backward pass (bfloat16 inputs/outputs/gradients, float32 ``w``).
|
| 133 |
+
|
| 134 |
+
Writes gradients into the provided tensors in-place.
|
| 135 |
+
|
| 136 |
+
Args:
|
| 137 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 138 |
+
u, k, v, y: Forward-pass tensors, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 139 |
+
gy: Gradient of ``y``, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 140 |
+
gw: Gradient for ``w``, shape ``[C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 141 |
+
gu, gk, gv: Gradients for ``u``, ``k``, ``v`` respectively, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 142 |
+
|
| 143 |
+
Notes:
|
| 144 |
+
- All tensors must be on the same CUDA device.
|
| 145 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 146 |
+
"""
|
| 147 |
+
_validate_device_match((w, u, k, v, y, gy, gw, gu, gk, gv))
|
| 148 |
+
ops.backward_bf16(w, u, k, v, y, gy, gw, gu, gk, gv)
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def _validate_device_match(tensors: Tuple[Tensor, ...]) -> None:
|
| 152 |
+
"""Minimal runtime validation that all tensors live on the same CUDA device."""
|
| 153 |
+
if not tensors:
|
| 154 |
+
return
|
| 155 |
+
device = tensors[0].device
|
| 156 |
+
if not device.type == "cuda":
|
| 157 |
+
raise RuntimeError("RWKV CUDA ops require CUDA tensors")
|
| 158 |
+
for t in tensors[1:]:
|
| 159 |
+
if t.device != device:
|
| 160 |
+
raise RuntimeError("All tensors must be on the same CUDA device")
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
__all__ = [
|
| 164 |
+
"forward",
|
| 165 |
+
"forward_bf16",
|
| 166 |
+
"forward_with_state",
|
| 167 |
+
"forward_with_state_bf16",
|
| 168 |
+
"backward",
|
| 169 |
+
"backward_bf16",
|
| 170 |
+
]
|
build/torch27-cxx11-cu118-x86_64-linux/rwkv/__pycache__/__init__.cpython-313.pyc
ADDED
|
Binary file (7.21 kB). View file
|
|
|
build/torch27-cxx11-cu118-x86_64-linux/rwkv/__pycache__/_ops.cpython-313.pyc
ADDED
|
Binary file (520 Bytes). View file
|
|
|
build/torch27-cxx11-cu118-x86_64-linux/rwkv/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _rwkv_eb0e3e5_dirty
|
| 3 |
+
ops = torch.ops._rwkv_eb0e3e5_dirty
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_rwkv_eb0e3e5_dirty::{op_name}"
|
build/torch27-cxx11-cu118-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:25632a613591ab66c83b18aeda5bd01f4ba117e34345efdb6191fe501be170cf
|
| 3 |
+
size 2065424
|
build/torch27-cxx11-cu126-x86_64-linux/rwkv/__init__.py
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ._ops import ops
|
| 2 |
+
from typing import Tuple, Any
|
| 3 |
+
|
| 4 |
+
# Use a broad Tensor alias to avoid importing torch at import time.
|
| 5 |
+
from torch import Tensor
|
| 6 |
+
|
| 7 |
+
def forward(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor) -> None:
|
| 8 |
+
"""RWKV WKV forward pass (float32).
|
| 9 |
+
|
| 10 |
+
Runs the CUDA kernel and writes the result into ``y`` in-place.
|
| 11 |
+
|
| 12 |
+
Args:
|
| 13 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 14 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 15 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 16 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 17 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 18 |
+
|
| 19 |
+
Notes:
|
| 20 |
+
- All tensors must be on the same CUDA device.
|
| 21 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 22 |
+
"""
|
| 23 |
+
_validate_device_match((w, u, k, v, y))
|
| 24 |
+
ops.forward(w, u, k, v, y)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def forward_bf16(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor) -> None:
|
| 28 |
+
"""RWKV WKV forward pass (bfloat16 inputs/outputs, float32 ``w``).
|
| 29 |
+
|
| 30 |
+
Runs the CUDA kernel and writes the result into ``y`` in-place.
|
| 31 |
+
|
| 32 |
+
Args:
|
| 33 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 34 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 35 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 36 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 37 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 38 |
+
|
| 39 |
+
Notes:
|
| 40 |
+
- All tensors must be on the same CUDA device.
|
| 41 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 42 |
+
"""
|
| 43 |
+
_validate_device_match((w, u, k, v, y))
|
| 44 |
+
ops.forward_bf16(w, u, k, v, y)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def forward_with_state(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor, s: Tensor) -> None:
|
| 48 |
+
"""RWKV WKV forward pass with persistent state (float32).
|
| 49 |
+
|
| 50 |
+
Runs the CUDA kernel using and updating state ``s`` and writes the result into ``y``.
|
| 51 |
+
|
| 52 |
+
Args:
|
| 53 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 54 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 55 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 56 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 57 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 58 |
+
s: Stateful tensor, shape ``[B, C]``, dtype ``torch.float32`` (updated in-place).
|
| 59 |
+
|
| 60 |
+
Notes:
|
| 61 |
+
- All tensors must be on the same CUDA device.
|
| 62 |
+
- Shapes must agree on ``B`` and ``C``; ``y`` shares ``[B, T, C]`` with inputs.
|
| 63 |
+
"""
|
| 64 |
+
_validate_device_match((w, u, k, v, y, s))
|
| 65 |
+
ops.forward_with_state(w, u, k, v, y, s)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def forward_with_state_bf16(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor, s: Tensor) -> None:
|
| 69 |
+
"""RWKV WKV forward pass with persistent state (bfloat16 inputs/outputs, float32 ``w`` and ``s``).
|
| 70 |
+
|
| 71 |
+
Runs the CUDA kernel using and updating state ``s`` and writes the result into ``y``.
|
| 72 |
+
|
| 73 |
+
Args:
|
| 74 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 75 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 76 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 77 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 78 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 79 |
+
s: Stateful tensor, shape ``[B, C]``, dtype ``torch.float32`` (updated in-place).
|
| 80 |
+
|
| 81 |
+
Notes:
|
| 82 |
+
- All tensors must be on the same CUDA device.
|
| 83 |
+
- Shapes must agree on ``B`` and ``C``; ``y`` shares ``[B, T, C]`` with inputs.
|
| 84 |
+
"""
|
| 85 |
+
_validate_device_match((w, u, k, v, y, s))
|
| 86 |
+
ops.forward_with_state_bf16(w, u, k, v, y, s)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def backward(
|
| 90 |
+
w: Tensor,
|
| 91 |
+
u: Tensor,
|
| 92 |
+
k: Tensor,
|
| 93 |
+
v: Tensor,
|
| 94 |
+
y: Tensor,
|
| 95 |
+
gy: Tensor,
|
| 96 |
+
gw: Tensor,
|
| 97 |
+
gu: Tensor,
|
| 98 |
+
gk: Tensor,
|
| 99 |
+
gv: Tensor,
|
| 100 |
+
) -> None:
|
| 101 |
+
"""RWKV WKV backward pass (float32).
|
| 102 |
+
|
| 103 |
+
Writes gradients into the provided tensors in-place.
|
| 104 |
+
|
| 105 |
+
Args:
|
| 106 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 107 |
+
u, k, v, y: Forward-pass tensors, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 108 |
+
gy: Gradient of ``y``, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 109 |
+
gw: Gradient for ``w``, shape ``[C]``, dtype ``torch.float32`` (written in-place).
|
| 110 |
+
gu, gk, gv: Gradients for ``u``, ``k``, ``v`` respectively, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 111 |
+
|
| 112 |
+
Notes:
|
| 113 |
+
- All tensors must be on the same CUDA device.
|
| 114 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 115 |
+
"""
|
| 116 |
+
_validate_device_match((w, u, k, v, y, gy, gw, gu, gk, gv))
|
| 117 |
+
ops.backward(w, u, k, v, y, gy, gw, gu, gk, gv)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def backward_bf16(
|
| 121 |
+
w: Tensor,
|
| 122 |
+
u: Tensor,
|
| 123 |
+
k: Tensor,
|
| 124 |
+
v: Tensor,
|
| 125 |
+
y: Tensor,
|
| 126 |
+
gy: Tensor,
|
| 127 |
+
gw: Tensor,
|
| 128 |
+
gu: Tensor,
|
| 129 |
+
gk: Tensor,
|
| 130 |
+
gv: Tensor,
|
| 131 |
+
) -> None:
|
| 132 |
+
"""RWKV WKV backward pass (bfloat16 inputs/outputs/gradients, float32 ``w``).
|
| 133 |
+
|
| 134 |
+
Writes gradients into the provided tensors in-place.
|
| 135 |
+
|
| 136 |
+
Args:
|
| 137 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 138 |
+
u, k, v, y: Forward-pass tensors, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 139 |
+
gy: Gradient of ``y``, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 140 |
+
gw: Gradient for ``w``, shape ``[C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 141 |
+
gu, gk, gv: Gradients for ``u``, ``k``, ``v`` respectively, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 142 |
+
|
| 143 |
+
Notes:
|
| 144 |
+
- All tensors must be on the same CUDA device.
|
| 145 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 146 |
+
"""
|
| 147 |
+
_validate_device_match((w, u, k, v, y, gy, gw, gu, gk, gv))
|
| 148 |
+
ops.backward_bf16(w, u, k, v, y, gy, gw, gu, gk, gv)
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def _validate_device_match(tensors: Tuple[Tensor, ...]) -> None:
|
| 152 |
+
"""Minimal runtime validation that all tensors live on the same CUDA device."""
|
| 153 |
+
if not tensors:
|
| 154 |
+
return
|
| 155 |
+
device = tensors[0].device
|
| 156 |
+
if not device.type == "cuda":
|
| 157 |
+
raise RuntimeError("RWKV CUDA ops require CUDA tensors")
|
| 158 |
+
for t in tensors[1:]:
|
| 159 |
+
if t.device != device:
|
| 160 |
+
raise RuntimeError("All tensors must be on the same CUDA device")
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
__all__ = [
|
| 164 |
+
"forward",
|
| 165 |
+
"forward_bf16",
|
| 166 |
+
"forward_with_state",
|
| 167 |
+
"forward_with_state_bf16",
|
| 168 |
+
"backward",
|
| 169 |
+
"backward_bf16",
|
| 170 |
+
]
|
build/torch27-cxx11-cu126-x86_64-linux/rwkv/__pycache__/__init__.cpython-313.pyc
ADDED
|
Binary file (7.21 kB). View file
|
|
|
build/torch27-cxx11-cu126-x86_64-linux/rwkv/__pycache__/_ops.cpython-313.pyc
ADDED
|
Binary file (520 Bytes). View file
|
|
|
build/torch27-cxx11-cu126-x86_64-linux/rwkv/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _rwkv_eb0e3e5_dirty
|
| 3 |
+
ops = torch.ops._rwkv_eb0e3e5_dirty
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_rwkv_eb0e3e5_dirty::{op_name}"
|
build/torch27-cxx11-cu126-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c96331e3a863df3e5fc2eee8fe0916f036a51e5c73a03bba2169556a945db2d7
|
| 3 |
+
size 2106440
|
build/torch27-cxx11-cu128-x86_64-linux/rwkv/__init__.py
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ._ops import ops
|
| 2 |
+
from typing import Tuple, Any
|
| 3 |
+
|
| 4 |
+
# Use a broad Tensor alias to avoid importing torch at import time.
|
| 5 |
+
from torch import Tensor
|
| 6 |
+
|
| 7 |
+
def forward(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor) -> None:
|
| 8 |
+
"""RWKV WKV forward pass (float32).
|
| 9 |
+
|
| 10 |
+
Runs the CUDA kernel and writes the result into ``y`` in-place.
|
| 11 |
+
|
| 12 |
+
Args:
|
| 13 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 14 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 15 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 16 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 17 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 18 |
+
|
| 19 |
+
Notes:
|
| 20 |
+
- All tensors must be on the same CUDA device.
|
| 21 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 22 |
+
"""
|
| 23 |
+
_validate_device_match((w, u, k, v, y))
|
| 24 |
+
ops.forward(w, u, k, v, y)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def forward_bf16(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor) -> None:
|
| 28 |
+
"""RWKV WKV forward pass (bfloat16 inputs/outputs, float32 ``w``).
|
| 29 |
+
|
| 30 |
+
Runs the CUDA kernel and writes the result into ``y`` in-place.
|
| 31 |
+
|
| 32 |
+
Args:
|
| 33 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 34 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 35 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 36 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 37 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 38 |
+
|
| 39 |
+
Notes:
|
| 40 |
+
- All tensors must be on the same CUDA device.
|
| 41 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 42 |
+
"""
|
| 43 |
+
_validate_device_match((w, u, k, v, y))
|
| 44 |
+
ops.forward_bf16(w, u, k, v, y)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def forward_with_state(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor, s: Tensor) -> None:
|
| 48 |
+
"""RWKV WKV forward pass with persistent state (float32).
|
| 49 |
+
|
| 50 |
+
Runs the CUDA kernel using and updating state ``s`` and writes the result into ``y``.
|
| 51 |
+
|
| 52 |
+
Args:
|
| 53 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 54 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 55 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 56 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 57 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 58 |
+
s: Stateful tensor, shape ``[B, C]``, dtype ``torch.float32`` (updated in-place).
|
| 59 |
+
|
| 60 |
+
Notes:
|
| 61 |
+
- All tensors must be on the same CUDA device.
|
| 62 |
+
- Shapes must agree on ``B`` and ``C``; ``y`` shares ``[B, T, C]`` with inputs.
|
| 63 |
+
"""
|
| 64 |
+
_validate_device_match((w, u, k, v, y, s))
|
| 65 |
+
ops.forward_with_state(w, u, k, v, y, s)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def forward_with_state_bf16(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor, s: Tensor) -> None:
|
| 69 |
+
"""RWKV WKV forward pass with persistent state (bfloat16 inputs/outputs, float32 ``w`` and ``s``).
|
| 70 |
+
|
| 71 |
+
Runs the CUDA kernel using and updating state ``s`` and writes the result into ``y``.
|
| 72 |
+
|
| 73 |
+
Args:
|
| 74 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 75 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 76 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 77 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 78 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 79 |
+
s: Stateful tensor, shape ``[B, C]``, dtype ``torch.float32`` (updated in-place).
|
| 80 |
+
|
| 81 |
+
Notes:
|
| 82 |
+
- All tensors must be on the same CUDA device.
|
| 83 |
+
- Shapes must agree on ``B`` and ``C``; ``y`` shares ``[B, T, C]`` with inputs.
|
| 84 |
+
"""
|
| 85 |
+
_validate_device_match((w, u, k, v, y, s))
|
| 86 |
+
ops.forward_with_state_bf16(w, u, k, v, y, s)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def backward(
|
| 90 |
+
w: Tensor,
|
| 91 |
+
u: Tensor,
|
| 92 |
+
k: Tensor,
|
| 93 |
+
v: Tensor,
|
| 94 |
+
y: Tensor,
|
| 95 |
+
gy: Tensor,
|
| 96 |
+
gw: Tensor,
|
| 97 |
+
gu: Tensor,
|
| 98 |
+
gk: Tensor,
|
| 99 |
+
gv: Tensor,
|
| 100 |
+
) -> None:
|
| 101 |
+
"""RWKV WKV backward pass (float32).
|
| 102 |
+
|
| 103 |
+
Writes gradients into the provided tensors in-place.
|
| 104 |
+
|
| 105 |
+
Args:
|
| 106 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 107 |
+
u, k, v, y: Forward-pass tensors, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 108 |
+
gy: Gradient of ``y``, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 109 |
+
gw: Gradient for ``w``, shape ``[C]``, dtype ``torch.float32`` (written in-place).
|
| 110 |
+
gu, gk, gv: Gradients for ``u``, ``k``, ``v`` respectively, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 111 |
+
|
| 112 |
+
Notes:
|
| 113 |
+
- All tensors must be on the same CUDA device.
|
| 114 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 115 |
+
"""
|
| 116 |
+
_validate_device_match((w, u, k, v, y, gy, gw, gu, gk, gv))
|
| 117 |
+
ops.backward(w, u, k, v, y, gy, gw, gu, gk, gv)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def backward_bf16(
|
| 121 |
+
w: Tensor,
|
| 122 |
+
u: Tensor,
|
| 123 |
+
k: Tensor,
|
| 124 |
+
v: Tensor,
|
| 125 |
+
y: Tensor,
|
| 126 |
+
gy: Tensor,
|
| 127 |
+
gw: Tensor,
|
| 128 |
+
gu: Tensor,
|
| 129 |
+
gk: Tensor,
|
| 130 |
+
gv: Tensor,
|
| 131 |
+
) -> None:
|
| 132 |
+
"""RWKV WKV backward pass (bfloat16 inputs/outputs/gradients, float32 ``w``).
|
| 133 |
+
|
| 134 |
+
Writes gradients into the provided tensors in-place.
|
| 135 |
+
|
| 136 |
+
Args:
|
| 137 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 138 |
+
u, k, v, y: Forward-pass tensors, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 139 |
+
gy: Gradient of ``y``, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 140 |
+
gw: Gradient for ``w``, shape ``[C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 141 |
+
gu, gk, gv: Gradients for ``u``, ``k``, ``v`` respectively, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 142 |
+
|
| 143 |
+
Notes:
|
| 144 |
+
- All tensors must be on the same CUDA device.
|
| 145 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 146 |
+
"""
|
| 147 |
+
_validate_device_match((w, u, k, v, y, gy, gw, gu, gk, gv))
|
| 148 |
+
ops.backward_bf16(w, u, k, v, y, gy, gw, gu, gk, gv)
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def _validate_device_match(tensors: Tuple[Tensor, ...]) -> None:
|
| 152 |
+
"""Minimal runtime validation that all tensors live on the same CUDA device."""
|
| 153 |
+
if not tensors:
|
| 154 |
+
return
|
| 155 |
+
device = tensors[0].device
|
| 156 |
+
if not device.type == "cuda":
|
| 157 |
+
raise RuntimeError("RWKV CUDA ops require CUDA tensors")
|
| 158 |
+
for t in tensors[1:]:
|
| 159 |
+
if t.device != device:
|
| 160 |
+
raise RuntimeError("All tensors must be on the same CUDA device")
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
__all__ = [
|
| 164 |
+
"forward",
|
| 165 |
+
"forward_bf16",
|
| 166 |
+
"forward_with_state",
|
| 167 |
+
"forward_with_state_bf16",
|
| 168 |
+
"backward",
|
| 169 |
+
"backward_bf16",
|
| 170 |
+
]
|
build/torch27-cxx11-cu128-x86_64-linux/rwkv/__pycache__/__init__.cpython-313.pyc
ADDED
|
Binary file (7.21 kB). View file
|
|
|
build/torch27-cxx11-cu128-x86_64-linux/rwkv/__pycache__/_ops.cpython-313.pyc
ADDED
|
Binary file (520 Bytes). View file
|
|
|
build/torch27-cxx11-cu128-x86_64-linux/rwkv/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _rwkv_eb0e3e5_dirty
|
| 3 |
+
ops = torch.ops._rwkv_eb0e3e5_dirty
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_rwkv_eb0e3e5_dirty::{op_name}"
|
build/torch27-cxx11-cu128-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9b1ec16445438d1b9ec59f7efab20880b58d774f59c06abab5ae964d164d5fa0
|
| 3 |
+
size 2308880
|
build/torch28-cxx11-cu126-x86_64-linux/rwkv/__init__.py
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ._ops import ops
|
| 2 |
+
from typing import Tuple, Any
|
| 3 |
+
|
| 4 |
+
# Use a broad Tensor alias to avoid importing torch at import time.
|
| 5 |
+
from torch import Tensor
|
| 6 |
+
|
| 7 |
+
def forward(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor) -> None:
|
| 8 |
+
"""RWKV WKV forward pass (float32).
|
| 9 |
+
|
| 10 |
+
Runs the CUDA kernel and writes the result into ``y`` in-place.
|
| 11 |
+
|
| 12 |
+
Args:
|
| 13 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 14 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 15 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 16 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 17 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 18 |
+
|
| 19 |
+
Notes:
|
| 20 |
+
- All tensors must be on the same CUDA device.
|
| 21 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 22 |
+
"""
|
| 23 |
+
_validate_device_match((w, u, k, v, y))
|
| 24 |
+
ops.forward(w, u, k, v, y)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def forward_bf16(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor) -> None:
|
| 28 |
+
"""RWKV WKV forward pass (bfloat16 inputs/outputs, float32 ``w``).
|
| 29 |
+
|
| 30 |
+
Runs the CUDA kernel and writes the result into ``y`` in-place.
|
| 31 |
+
|
| 32 |
+
Args:
|
| 33 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 34 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 35 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 36 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 37 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 38 |
+
|
| 39 |
+
Notes:
|
| 40 |
+
- All tensors must be on the same CUDA device.
|
| 41 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 42 |
+
"""
|
| 43 |
+
_validate_device_match((w, u, k, v, y))
|
| 44 |
+
ops.forward_bf16(w, u, k, v, y)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def forward_with_state(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor, s: Tensor) -> None:
|
| 48 |
+
"""RWKV WKV forward pass with persistent state (float32).
|
| 49 |
+
|
| 50 |
+
Runs the CUDA kernel using and updating state ``s`` and writes the result into ``y``.
|
| 51 |
+
|
| 52 |
+
Args:
|
| 53 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 54 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 55 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 56 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 57 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 58 |
+
s: Stateful tensor, shape ``[B, C]``, dtype ``torch.float32`` (updated in-place).
|
| 59 |
+
|
| 60 |
+
Notes:
|
| 61 |
+
- All tensors must be on the same CUDA device.
|
| 62 |
+
- Shapes must agree on ``B`` and ``C``; ``y`` shares ``[B, T, C]`` with inputs.
|
| 63 |
+
"""
|
| 64 |
+
_validate_device_match((w, u, k, v, y, s))
|
| 65 |
+
ops.forward_with_state(w, u, k, v, y, s)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def forward_with_state_bf16(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor, s: Tensor) -> None:
|
| 69 |
+
"""RWKV WKV forward pass with persistent state (bfloat16 inputs/outputs, float32 ``w`` and ``s``).
|
| 70 |
+
|
| 71 |
+
Runs the CUDA kernel using and updating state ``s`` and writes the result into ``y``.
|
| 72 |
+
|
| 73 |
+
Args:
|
| 74 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 75 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 76 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 77 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 78 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 79 |
+
s: Stateful tensor, shape ``[B, C]``, dtype ``torch.float32`` (updated in-place).
|
| 80 |
+
|
| 81 |
+
Notes:
|
| 82 |
+
- All tensors must be on the same CUDA device.
|
| 83 |
+
- Shapes must agree on ``B`` and ``C``; ``y`` shares ``[B, T, C]`` with inputs.
|
| 84 |
+
"""
|
| 85 |
+
_validate_device_match((w, u, k, v, y, s))
|
| 86 |
+
ops.forward_with_state_bf16(w, u, k, v, y, s)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def backward(
|
| 90 |
+
w: Tensor,
|
| 91 |
+
u: Tensor,
|
| 92 |
+
k: Tensor,
|
| 93 |
+
v: Tensor,
|
| 94 |
+
y: Tensor,
|
| 95 |
+
gy: Tensor,
|
| 96 |
+
gw: Tensor,
|
| 97 |
+
gu: Tensor,
|
| 98 |
+
gk: Tensor,
|
| 99 |
+
gv: Tensor,
|
| 100 |
+
) -> None:
|
| 101 |
+
"""RWKV WKV backward pass (float32).
|
| 102 |
+
|
| 103 |
+
Writes gradients into the provided tensors in-place.
|
| 104 |
+
|
| 105 |
+
Args:
|
| 106 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 107 |
+
u, k, v, y: Forward-pass tensors, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 108 |
+
gy: Gradient of ``y``, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 109 |
+
gw: Gradient for ``w``, shape ``[C]``, dtype ``torch.float32`` (written in-place).
|
| 110 |
+
gu, gk, gv: Gradients for ``u``, ``k``, ``v`` respectively, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 111 |
+
|
| 112 |
+
Notes:
|
| 113 |
+
- All tensors must be on the same CUDA device.
|
| 114 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 115 |
+
"""
|
| 116 |
+
_validate_device_match((w, u, k, v, y, gy, gw, gu, gk, gv))
|
| 117 |
+
ops.backward(w, u, k, v, y, gy, gw, gu, gk, gv)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def backward_bf16(
|
| 121 |
+
w: Tensor,
|
| 122 |
+
u: Tensor,
|
| 123 |
+
k: Tensor,
|
| 124 |
+
v: Tensor,
|
| 125 |
+
y: Tensor,
|
| 126 |
+
gy: Tensor,
|
| 127 |
+
gw: Tensor,
|
| 128 |
+
gu: Tensor,
|
| 129 |
+
gk: Tensor,
|
| 130 |
+
gv: Tensor,
|
| 131 |
+
) -> None:
|
| 132 |
+
"""RWKV WKV backward pass (bfloat16 inputs/outputs/gradients, float32 ``w``).
|
| 133 |
+
|
| 134 |
+
Writes gradients into the provided tensors in-place.
|
| 135 |
+
|
| 136 |
+
Args:
|
| 137 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 138 |
+
u, k, v, y: Forward-pass tensors, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 139 |
+
gy: Gradient of ``y``, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 140 |
+
gw: Gradient for ``w``, shape ``[C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 141 |
+
gu, gk, gv: Gradients for ``u``, ``k``, ``v`` respectively, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 142 |
+
|
| 143 |
+
Notes:
|
| 144 |
+
- All tensors must be on the same CUDA device.
|
| 145 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 146 |
+
"""
|
| 147 |
+
_validate_device_match((w, u, k, v, y, gy, gw, gu, gk, gv))
|
| 148 |
+
ops.backward_bf16(w, u, k, v, y, gy, gw, gu, gk, gv)
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def _validate_device_match(tensors: Tuple[Tensor, ...]) -> None:
|
| 152 |
+
"""Minimal runtime validation that all tensors live on the same CUDA device."""
|
| 153 |
+
if not tensors:
|
| 154 |
+
return
|
| 155 |
+
device = tensors[0].device
|
| 156 |
+
if not device.type == "cuda":
|
| 157 |
+
raise RuntimeError("RWKV CUDA ops require CUDA tensors")
|
| 158 |
+
for t in tensors[1:]:
|
| 159 |
+
if t.device != device:
|
| 160 |
+
raise RuntimeError("All tensors must be on the same CUDA device")
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
__all__ = [
|
| 164 |
+
"forward",
|
| 165 |
+
"forward_bf16",
|
| 166 |
+
"forward_with_state",
|
| 167 |
+
"forward_with_state_bf16",
|
| 168 |
+
"backward",
|
| 169 |
+
"backward_bf16",
|
| 170 |
+
]
|
build/torch28-cxx11-cu126-x86_64-linux/rwkv/__pycache__/__init__.cpython-313.pyc
ADDED
|
Binary file (7.21 kB). View file
|
|
|
build/torch28-cxx11-cu126-x86_64-linux/rwkv/__pycache__/_ops.cpython-313.pyc
ADDED
|
Binary file (520 Bytes). View file
|
|
|
build/torch28-cxx11-cu126-x86_64-linux/rwkv/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _rwkv_eb0e3e5_dirty
|
| 3 |
+
ops = torch.ops._rwkv_eb0e3e5_dirty
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_rwkv_eb0e3e5_dirty::{op_name}"
|
build/torch28-cxx11-cu126-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:00476bbd1c8b08d8ad3fef06cb12e0a86900830ad4f72dd4ea400131f432d510
|
| 3 |
+
size 2106464
|
build/torch28-cxx11-cu128-x86_64-linux/rwkv/__init__.py
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ._ops import ops
|
| 2 |
+
from typing import Tuple, Any
|
| 3 |
+
|
| 4 |
+
# Use a broad Tensor alias to avoid importing torch at import time.
|
| 5 |
+
from torch import Tensor
|
| 6 |
+
|
| 7 |
+
def forward(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor) -> None:
|
| 8 |
+
"""RWKV WKV forward pass (float32).
|
| 9 |
+
|
| 10 |
+
Runs the CUDA kernel and writes the result into ``y`` in-place.
|
| 11 |
+
|
| 12 |
+
Args:
|
| 13 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 14 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 15 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 16 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 17 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 18 |
+
|
| 19 |
+
Notes:
|
| 20 |
+
- All tensors must be on the same CUDA device.
|
| 21 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 22 |
+
"""
|
| 23 |
+
_validate_device_match((w, u, k, v, y))
|
| 24 |
+
ops.forward(w, u, k, v, y)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def forward_bf16(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor) -> None:
|
| 28 |
+
"""RWKV WKV forward pass (bfloat16 inputs/outputs, float32 ``w``).
|
| 29 |
+
|
| 30 |
+
Runs the CUDA kernel and writes the result into ``y`` in-place.
|
| 31 |
+
|
| 32 |
+
Args:
|
| 33 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 34 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 35 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 36 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 37 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 38 |
+
|
| 39 |
+
Notes:
|
| 40 |
+
- All tensors must be on the same CUDA device.
|
| 41 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 42 |
+
"""
|
| 43 |
+
_validate_device_match((w, u, k, v, y))
|
| 44 |
+
ops.forward_bf16(w, u, k, v, y)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def forward_with_state(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor, s: Tensor) -> None:
|
| 48 |
+
"""RWKV WKV forward pass with persistent state (float32).
|
| 49 |
+
|
| 50 |
+
Runs the CUDA kernel using and updating state ``s`` and writes the result into ``y``.
|
| 51 |
+
|
| 52 |
+
Args:
|
| 53 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 54 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 55 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 56 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 57 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 58 |
+
s: Stateful tensor, shape ``[B, C]``, dtype ``torch.float32`` (updated in-place).
|
| 59 |
+
|
| 60 |
+
Notes:
|
| 61 |
+
- All tensors must be on the same CUDA device.
|
| 62 |
+
- Shapes must agree on ``B`` and ``C``; ``y`` shares ``[B, T, C]`` with inputs.
|
| 63 |
+
"""
|
| 64 |
+
_validate_device_match((w, u, k, v, y, s))
|
| 65 |
+
ops.forward_with_state(w, u, k, v, y, s)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def forward_with_state_bf16(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor, s: Tensor) -> None:
|
| 69 |
+
"""RWKV WKV forward pass with persistent state (bfloat16 inputs/outputs, float32 ``w`` and ``s``).
|
| 70 |
+
|
| 71 |
+
Runs the CUDA kernel using and updating state ``s`` and writes the result into ``y``.
|
| 72 |
+
|
| 73 |
+
Args:
|
| 74 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 75 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 76 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 77 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 78 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 79 |
+
s: Stateful tensor, shape ``[B, C]``, dtype ``torch.float32`` (updated in-place).
|
| 80 |
+
|
| 81 |
+
Notes:
|
| 82 |
+
- All tensors must be on the same CUDA device.
|
| 83 |
+
- Shapes must agree on ``B`` and ``C``; ``y`` shares ``[B, T, C]`` with inputs.
|
| 84 |
+
"""
|
| 85 |
+
_validate_device_match((w, u, k, v, y, s))
|
| 86 |
+
ops.forward_with_state_bf16(w, u, k, v, y, s)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def backward(
|
| 90 |
+
w: Tensor,
|
| 91 |
+
u: Tensor,
|
| 92 |
+
k: Tensor,
|
| 93 |
+
v: Tensor,
|
| 94 |
+
y: Tensor,
|
| 95 |
+
gy: Tensor,
|
| 96 |
+
gw: Tensor,
|
| 97 |
+
gu: Tensor,
|
| 98 |
+
gk: Tensor,
|
| 99 |
+
gv: Tensor,
|
| 100 |
+
) -> None:
|
| 101 |
+
"""RWKV WKV backward pass (float32).
|
| 102 |
+
|
| 103 |
+
Writes gradients into the provided tensors in-place.
|
| 104 |
+
|
| 105 |
+
Args:
|
| 106 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 107 |
+
u, k, v, y: Forward-pass tensors, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 108 |
+
gy: Gradient of ``y``, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 109 |
+
gw: Gradient for ``w``, shape ``[C]``, dtype ``torch.float32`` (written in-place).
|
| 110 |
+
gu, gk, gv: Gradients for ``u``, ``k``, ``v`` respectively, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 111 |
+
|
| 112 |
+
Notes:
|
| 113 |
+
- All tensors must be on the same CUDA device.
|
| 114 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 115 |
+
"""
|
| 116 |
+
_validate_device_match((w, u, k, v, y, gy, gw, gu, gk, gv))
|
| 117 |
+
ops.backward(w, u, k, v, y, gy, gw, gu, gk, gv)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def backward_bf16(
|
| 121 |
+
w: Tensor,
|
| 122 |
+
u: Tensor,
|
| 123 |
+
k: Tensor,
|
| 124 |
+
v: Tensor,
|
| 125 |
+
y: Tensor,
|
| 126 |
+
gy: Tensor,
|
| 127 |
+
gw: Tensor,
|
| 128 |
+
gu: Tensor,
|
| 129 |
+
gk: Tensor,
|
| 130 |
+
gv: Tensor,
|
| 131 |
+
) -> None:
|
| 132 |
+
"""RWKV WKV backward pass (bfloat16 inputs/outputs/gradients, float32 ``w``).
|
| 133 |
+
|
| 134 |
+
Writes gradients into the provided tensors in-place.
|
| 135 |
+
|
| 136 |
+
Args:
|
| 137 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 138 |
+
u, k, v, y: Forward-pass tensors, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 139 |
+
gy: Gradient of ``y``, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 140 |
+
gw: Gradient for ``w``, shape ``[C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 141 |
+
gu, gk, gv: Gradients for ``u``, ``k``, ``v`` respectively, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 142 |
+
|
| 143 |
+
Notes:
|
| 144 |
+
- All tensors must be on the same CUDA device.
|
| 145 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 146 |
+
"""
|
| 147 |
+
_validate_device_match((w, u, k, v, y, gy, gw, gu, gk, gv))
|
| 148 |
+
ops.backward_bf16(w, u, k, v, y, gy, gw, gu, gk, gv)
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def _validate_device_match(tensors: Tuple[Tensor, ...]) -> None:
|
| 152 |
+
"""Minimal runtime validation that all tensors live on the same CUDA device."""
|
| 153 |
+
if not tensors:
|
| 154 |
+
return
|
| 155 |
+
device = tensors[0].device
|
| 156 |
+
if not device.type == "cuda":
|
| 157 |
+
raise RuntimeError("RWKV CUDA ops require CUDA tensors")
|
| 158 |
+
for t in tensors[1:]:
|
| 159 |
+
if t.device != device:
|
| 160 |
+
raise RuntimeError("All tensors must be on the same CUDA device")
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
__all__ = [
|
| 164 |
+
"forward",
|
| 165 |
+
"forward_bf16",
|
| 166 |
+
"forward_with_state",
|
| 167 |
+
"forward_with_state_bf16",
|
| 168 |
+
"backward",
|
| 169 |
+
"backward_bf16",
|
| 170 |
+
]
|
build/torch28-cxx11-cu128-x86_64-linux/rwkv/__pycache__/__init__.cpython-313.pyc
ADDED
|
Binary file (7.21 kB). View file
|
|
|
build/torch28-cxx11-cu128-x86_64-linux/rwkv/__pycache__/_ops.cpython-313.pyc
ADDED
|
Binary file (520 Bytes). View file
|
|
|
build/torch28-cxx11-cu128-x86_64-linux/rwkv/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _rwkv_eb0e3e5_dirty
|
| 3 |
+
ops = torch.ops._rwkv_eb0e3e5_dirty
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_rwkv_eb0e3e5_dirty::{op_name}"
|
build/torch28-cxx11-cu128-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:301bf08ad13b2e382ccd49bd7de6ed8931fd1c9a70eb699728999fa454a52723
|
| 3 |
+
size 2308880
|
build/torch28-cxx11-cu129-x86_64-linux/rwkv/__init__.py
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ._ops import ops
|
| 2 |
+
from typing import Tuple, Any
|
| 3 |
+
|
| 4 |
+
# Use a broad Tensor alias to avoid importing torch at import time.
|
| 5 |
+
from torch import Tensor
|
| 6 |
+
|
| 7 |
+
def forward(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor) -> None:
|
| 8 |
+
"""RWKV WKV forward pass (float32).
|
| 9 |
+
|
| 10 |
+
Runs the CUDA kernel and writes the result into ``y`` in-place.
|
| 11 |
+
|
| 12 |
+
Args:
|
| 13 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 14 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 15 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 16 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 17 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 18 |
+
|
| 19 |
+
Notes:
|
| 20 |
+
- All tensors must be on the same CUDA device.
|
| 21 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 22 |
+
"""
|
| 23 |
+
_validate_device_match((w, u, k, v, y))
|
| 24 |
+
ops.forward(w, u, k, v, y)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def forward_bf16(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor) -> None:
|
| 28 |
+
"""RWKV WKV forward pass (bfloat16 inputs/outputs, float32 ``w``).
|
| 29 |
+
|
| 30 |
+
Runs the CUDA kernel and writes the result into ``y`` in-place.
|
| 31 |
+
|
| 32 |
+
Args:
|
| 33 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 34 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 35 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 36 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 37 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 38 |
+
|
| 39 |
+
Notes:
|
| 40 |
+
- All tensors must be on the same CUDA device.
|
| 41 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 42 |
+
"""
|
| 43 |
+
_validate_device_match((w, u, k, v, y))
|
| 44 |
+
ops.forward_bf16(w, u, k, v, y)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def forward_with_state(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor, s: Tensor) -> None:
|
| 48 |
+
"""RWKV WKV forward pass with persistent state (float32).
|
| 49 |
+
|
| 50 |
+
Runs the CUDA kernel using and updating state ``s`` and writes the result into ``y``.
|
| 51 |
+
|
| 52 |
+
Args:
|
| 53 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 54 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 55 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 56 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 57 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 58 |
+
s: Stateful tensor, shape ``[B, C]``, dtype ``torch.float32`` (updated in-place).
|
| 59 |
+
|
| 60 |
+
Notes:
|
| 61 |
+
- All tensors must be on the same CUDA device.
|
| 62 |
+
- Shapes must agree on ``B`` and ``C``; ``y`` shares ``[B, T, C]`` with inputs.
|
| 63 |
+
"""
|
| 64 |
+
_validate_device_match((w, u, k, v, y, s))
|
| 65 |
+
ops.forward_with_state(w, u, k, v, y, s)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def forward_with_state_bf16(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor, s: Tensor) -> None:
|
| 69 |
+
"""RWKV WKV forward pass with persistent state (bfloat16 inputs/outputs, float32 ``w`` and ``s``).
|
| 70 |
+
|
| 71 |
+
Runs the CUDA kernel using and updating state ``s`` and writes the result into ``y``.
|
| 72 |
+
|
| 73 |
+
Args:
|
| 74 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 75 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 76 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 77 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 78 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 79 |
+
s: Stateful tensor, shape ``[B, C]``, dtype ``torch.float32`` (updated in-place).
|
| 80 |
+
|
| 81 |
+
Notes:
|
| 82 |
+
- All tensors must be on the same CUDA device.
|
| 83 |
+
- Shapes must agree on ``B`` and ``C``; ``y`` shares ``[B, T, C]`` with inputs.
|
| 84 |
+
"""
|
| 85 |
+
_validate_device_match((w, u, k, v, y, s))
|
| 86 |
+
ops.forward_with_state_bf16(w, u, k, v, y, s)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def backward(
|
| 90 |
+
w: Tensor,
|
| 91 |
+
u: Tensor,
|
| 92 |
+
k: Tensor,
|
| 93 |
+
v: Tensor,
|
| 94 |
+
y: Tensor,
|
| 95 |
+
gy: Tensor,
|
| 96 |
+
gw: Tensor,
|
| 97 |
+
gu: Tensor,
|
| 98 |
+
gk: Tensor,
|
| 99 |
+
gv: Tensor,
|
| 100 |
+
) -> None:
|
| 101 |
+
"""RWKV WKV backward pass (float32).
|
| 102 |
+
|
| 103 |
+
Writes gradients into the provided tensors in-place.
|
| 104 |
+
|
| 105 |
+
Args:
|
| 106 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 107 |
+
u, k, v, y: Forward-pass tensors, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 108 |
+
gy: Gradient of ``y``, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 109 |
+
gw: Gradient for ``w``, shape ``[C]``, dtype ``torch.float32`` (written in-place).
|
| 110 |
+
gu, gk, gv: Gradients for ``u``, ``k``, ``v`` respectively, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 111 |
+
|
| 112 |
+
Notes:
|
| 113 |
+
- All tensors must be on the same CUDA device.
|
| 114 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 115 |
+
"""
|
| 116 |
+
_validate_device_match((w, u, k, v, y, gy, gw, gu, gk, gv))
|
| 117 |
+
ops.backward(w, u, k, v, y, gy, gw, gu, gk, gv)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def backward_bf16(
|
| 121 |
+
w: Tensor,
|
| 122 |
+
u: Tensor,
|
| 123 |
+
k: Tensor,
|
| 124 |
+
v: Tensor,
|
| 125 |
+
y: Tensor,
|
| 126 |
+
gy: Tensor,
|
| 127 |
+
gw: Tensor,
|
| 128 |
+
gu: Tensor,
|
| 129 |
+
gk: Tensor,
|
| 130 |
+
gv: Tensor,
|
| 131 |
+
) -> None:
|
| 132 |
+
"""RWKV WKV backward pass (bfloat16 inputs/outputs/gradients, float32 ``w``).
|
| 133 |
+
|
| 134 |
+
Writes gradients into the provided tensors in-place.
|
| 135 |
+
|
| 136 |
+
Args:
|
| 137 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 138 |
+
u, k, v, y: Forward-pass tensors, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 139 |
+
gy: Gradient of ``y``, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 140 |
+
gw: Gradient for ``w``, shape ``[C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 141 |
+
gu, gk, gv: Gradients for ``u``, ``k``, ``v`` respectively, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 142 |
+
|
| 143 |
+
Notes:
|
| 144 |
+
- All tensors must be on the same CUDA device.
|
| 145 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 146 |
+
"""
|
| 147 |
+
_validate_device_match((w, u, k, v, y, gy, gw, gu, gk, gv))
|
| 148 |
+
ops.backward_bf16(w, u, k, v, y, gy, gw, gu, gk, gv)
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def _validate_device_match(tensors: Tuple[Tensor, ...]) -> None:
|
| 152 |
+
"""Minimal runtime validation that all tensors live on the same CUDA device."""
|
| 153 |
+
if not tensors:
|
| 154 |
+
return
|
| 155 |
+
device = tensors[0].device
|
| 156 |
+
if not device.type == "cuda":
|
| 157 |
+
raise RuntimeError("RWKV CUDA ops require CUDA tensors")
|
| 158 |
+
for t in tensors[1:]:
|
| 159 |
+
if t.device != device:
|
| 160 |
+
raise RuntimeError("All tensors must be on the same CUDA device")
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
__all__ = [
|
| 164 |
+
"forward",
|
| 165 |
+
"forward_bf16",
|
| 166 |
+
"forward_with_state",
|
| 167 |
+
"forward_with_state_bf16",
|
| 168 |
+
"backward",
|
| 169 |
+
"backward_bf16",
|
| 170 |
+
]
|
build/torch28-cxx11-cu129-x86_64-linux/rwkv/__pycache__/__init__.cpython-313.pyc
ADDED
|
Binary file (7.21 kB). View file
|
|
|
build/torch28-cxx11-cu129-x86_64-linux/rwkv/__pycache__/_ops.cpython-313.pyc
ADDED
|
Binary file (520 Bytes). View file
|
|
|
build/torch28-cxx11-cu129-x86_64-linux/rwkv/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _rwkv_eb0e3e5_dirty
|
| 3 |
+
ops = torch.ops._rwkv_eb0e3e5_dirty
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_rwkv_eb0e3e5_dirty::{op_name}"
|
build/torch28-cxx11-cu129-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c6f42c1d67d68e35de1f1140e85011870e61bf78a6c77499e2fc4c8926d3ebe3
|
| 3 |
+
size 2330376
|
build/torch29-cxx11-cu126-x86_64-linux/rwkv/__init__.py
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ._ops import ops
|
| 2 |
+
from typing import Tuple, Any
|
| 3 |
+
|
| 4 |
+
# Use a broad Tensor alias to avoid importing torch at import time.
|
| 5 |
+
from torch import Tensor
|
| 6 |
+
|
| 7 |
+
def forward(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor) -> None:
|
| 8 |
+
"""RWKV WKV forward pass (float32).
|
| 9 |
+
|
| 10 |
+
Runs the CUDA kernel and writes the result into ``y`` in-place.
|
| 11 |
+
|
| 12 |
+
Args:
|
| 13 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 14 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 15 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 16 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 17 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 18 |
+
|
| 19 |
+
Notes:
|
| 20 |
+
- All tensors must be on the same CUDA device.
|
| 21 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 22 |
+
"""
|
| 23 |
+
_validate_device_match((w, u, k, v, y))
|
| 24 |
+
ops.forward(w, u, k, v, y)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def forward_bf16(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor) -> None:
|
| 28 |
+
"""RWKV WKV forward pass (bfloat16 inputs/outputs, float32 ``w``).
|
| 29 |
+
|
| 30 |
+
Runs the CUDA kernel and writes the result into ``y`` in-place.
|
| 31 |
+
|
| 32 |
+
Args:
|
| 33 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 34 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 35 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 36 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 37 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 38 |
+
|
| 39 |
+
Notes:
|
| 40 |
+
- All tensors must be on the same CUDA device.
|
| 41 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 42 |
+
"""
|
| 43 |
+
_validate_device_match((w, u, k, v, y))
|
| 44 |
+
ops.forward_bf16(w, u, k, v, y)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def forward_with_state(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor, s: Tensor) -> None:
|
| 48 |
+
"""RWKV WKV forward pass with persistent state (float32).
|
| 49 |
+
|
| 50 |
+
Runs the CUDA kernel using and updating state ``s`` and writes the result into ``y``.
|
| 51 |
+
|
| 52 |
+
Args:
|
| 53 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 54 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 55 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 56 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 57 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 58 |
+
s: Stateful tensor, shape ``[B, C]``, dtype ``torch.float32`` (updated in-place).
|
| 59 |
+
|
| 60 |
+
Notes:
|
| 61 |
+
- All tensors must be on the same CUDA device.
|
| 62 |
+
- Shapes must agree on ``B`` and ``C``; ``y`` shares ``[B, T, C]`` with inputs.
|
| 63 |
+
"""
|
| 64 |
+
_validate_device_match((w, u, k, v, y, s))
|
| 65 |
+
ops.forward_with_state(w, u, k, v, y, s)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def forward_with_state_bf16(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor, s: Tensor) -> None:
|
| 69 |
+
"""RWKV WKV forward pass with persistent state (bfloat16 inputs/outputs, float32 ``w`` and ``s``).
|
| 70 |
+
|
| 71 |
+
Runs the CUDA kernel using and updating state ``s`` and writes the result into ``y``.
|
| 72 |
+
|
| 73 |
+
Args:
|
| 74 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 75 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 76 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 77 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 78 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 79 |
+
s: Stateful tensor, shape ``[B, C]``, dtype ``torch.float32`` (updated in-place).
|
| 80 |
+
|
| 81 |
+
Notes:
|
| 82 |
+
- All tensors must be on the same CUDA device.
|
| 83 |
+
- Shapes must agree on ``B`` and ``C``; ``y`` shares ``[B, T, C]`` with inputs.
|
| 84 |
+
"""
|
| 85 |
+
_validate_device_match((w, u, k, v, y, s))
|
| 86 |
+
ops.forward_with_state_bf16(w, u, k, v, y, s)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def backward(
|
| 90 |
+
w: Tensor,
|
| 91 |
+
u: Tensor,
|
| 92 |
+
k: Tensor,
|
| 93 |
+
v: Tensor,
|
| 94 |
+
y: Tensor,
|
| 95 |
+
gy: Tensor,
|
| 96 |
+
gw: Tensor,
|
| 97 |
+
gu: Tensor,
|
| 98 |
+
gk: Tensor,
|
| 99 |
+
gv: Tensor,
|
| 100 |
+
) -> None:
|
| 101 |
+
"""RWKV WKV backward pass (float32).
|
| 102 |
+
|
| 103 |
+
Writes gradients into the provided tensors in-place.
|
| 104 |
+
|
| 105 |
+
Args:
|
| 106 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 107 |
+
u, k, v, y: Forward-pass tensors, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 108 |
+
gy: Gradient of ``y``, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 109 |
+
gw: Gradient for ``w``, shape ``[C]``, dtype ``torch.float32`` (written in-place).
|
| 110 |
+
gu, gk, gv: Gradients for ``u``, ``k``, ``v`` respectively, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 111 |
+
|
| 112 |
+
Notes:
|
| 113 |
+
- All tensors must be on the same CUDA device.
|
| 114 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 115 |
+
"""
|
| 116 |
+
_validate_device_match((w, u, k, v, y, gy, gw, gu, gk, gv))
|
| 117 |
+
ops.backward(w, u, k, v, y, gy, gw, gu, gk, gv)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def backward_bf16(
|
| 121 |
+
w: Tensor,
|
| 122 |
+
u: Tensor,
|
| 123 |
+
k: Tensor,
|
| 124 |
+
v: Tensor,
|
| 125 |
+
y: Tensor,
|
| 126 |
+
gy: Tensor,
|
| 127 |
+
gw: Tensor,
|
| 128 |
+
gu: Tensor,
|
| 129 |
+
gk: Tensor,
|
| 130 |
+
gv: Tensor,
|
| 131 |
+
) -> None:
|
| 132 |
+
"""RWKV WKV backward pass (bfloat16 inputs/outputs/gradients, float32 ``w``).
|
| 133 |
+
|
| 134 |
+
Writes gradients into the provided tensors in-place.
|
| 135 |
+
|
| 136 |
+
Args:
|
| 137 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 138 |
+
u, k, v, y: Forward-pass tensors, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 139 |
+
gy: Gradient of ``y``, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 140 |
+
gw: Gradient for ``w``, shape ``[C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 141 |
+
gu, gk, gv: Gradients for ``u``, ``k``, ``v`` respectively, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 142 |
+
|
| 143 |
+
Notes:
|
| 144 |
+
- All tensors must be on the same CUDA device.
|
| 145 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 146 |
+
"""
|
| 147 |
+
_validate_device_match((w, u, k, v, y, gy, gw, gu, gk, gv))
|
| 148 |
+
ops.backward_bf16(w, u, k, v, y, gy, gw, gu, gk, gv)
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def _validate_device_match(tensors: Tuple[Tensor, ...]) -> None:
|
| 152 |
+
"""Minimal runtime validation that all tensors live on the same CUDA device."""
|
| 153 |
+
if not tensors:
|
| 154 |
+
return
|
| 155 |
+
device = tensors[0].device
|
| 156 |
+
if not device.type == "cuda":
|
| 157 |
+
raise RuntimeError("RWKV CUDA ops require CUDA tensors")
|
| 158 |
+
for t in tensors[1:]:
|
| 159 |
+
if t.device != device:
|
| 160 |
+
raise RuntimeError("All tensors must be on the same CUDA device")
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
__all__ = [
|
| 164 |
+
"forward",
|
| 165 |
+
"forward_bf16",
|
| 166 |
+
"forward_with_state",
|
| 167 |
+
"forward_with_state_bf16",
|
| 168 |
+
"backward",
|
| 169 |
+
"backward_bf16",
|
| 170 |
+
]
|
build/torch29-cxx11-cu126-x86_64-linux/rwkv/__pycache__/__init__.cpython-313.pyc
ADDED
|
Binary file (7.21 kB). View file
|
|
|
build/torch29-cxx11-cu126-x86_64-linux/rwkv/__pycache__/_ops.cpython-313.pyc
ADDED
|
Binary file (520 Bytes). View file
|
|
|
build/torch29-cxx11-cu126-x86_64-linux/rwkv/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _rwkv_eb0e3e5_dirty
|
| 3 |
+
ops = torch.ops._rwkv_eb0e3e5_dirty
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_rwkv_eb0e3e5_dirty::{op_name}"
|
build/torch29-cxx11-cu126-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:40d078873830f1833a85082fd6d907fd75c7eb3c94605ee77618981fe8cdee4e
|
| 3 |
+
size 2106440
|
build/torch29-cxx11-cu128-x86_64-linux/rwkv/__init__.py
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ._ops import ops
|
| 2 |
+
from typing import Tuple, Any
|
| 3 |
+
|
| 4 |
+
# Use a broad Tensor alias to avoid importing torch at import time.
|
| 5 |
+
from torch import Tensor
|
| 6 |
+
|
| 7 |
+
def forward(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor) -> None:
|
| 8 |
+
"""RWKV WKV forward pass (float32).
|
| 9 |
+
|
| 10 |
+
Runs the CUDA kernel and writes the result into ``y`` in-place.
|
| 11 |
+
|
| 12 |
+
Args:
|
| 13 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 14 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 15 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 16 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 17 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 18 |
+
|
| 19 |
+
Notes:
|
| 20 |
+
- All tensors must be on the same CUDA device.
|
| 21 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 22 |
+
"""
|
| 23 |
+
_validate_device_match((w, u, k, v, y))
|
| 24 |
+
ops.forward(w, u, k, v, y)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def forward_bf16(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor) -> None:
|
| 28 |
+
"""RWKV WKV forward pass (bfloat16 inputs/outputs, float32 ``w``).
|
| 29 |
+
|
| 30 |
+
Runs the CUDA kernel and writes the result into ``y`` in-place.
|
| 31 |
+
|
| 32 |
+
Args:
|
| 33 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 34 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 35 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 36 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 37 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 38 |
+
|
| 39 |
+
Notes:
|
| 40 |
+
- All tensors must be on the same CUDA device.
|
| 41 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 42 |
+
"""
|
| 43 |
+
_validate_device_match((w, u, k, v, y))
|
| 44 |
+
ops.forward_bf16(w, u, k, v, y)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def forward_with_state(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor, s: Tensor) -> None:
|
| 48 |
+
"""RWKV WKV forward pass with persistent state (float32).
|
| 49 |
+
|
| 50 |
+
Runs the CUDA kernel using and updating state ``s`` and writes the result into ``y``.
|
| 51 |
+
|
| 52 |
+
Args:
|
| 53 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 54 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 55 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 56 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 57 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 58 |
+
s: Stateful tensor, shape ``[B, C]``, dtype ``torch.float32`` (updated in-place).
|
| 59 |
+
|
| 60 |
+
Notes:
|
| 61 |
+
- All tensors must be on the same CUDA device.
|
| 62 |
+
- Shapes must agree on ``B`` and ``C``; ``y`` shares ``[B, T, C]`` with inputs.
|
| 63 |
+
"""
|
| 64 |
+
_validate_device_match((w, u, k, v, y, s))
|
| 65 |
+
ops.forward_with_state(w, u, k, v, y, s)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def forward_with_state_bf16(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor, s: Tensor) -> None:
|
| 69 |
+
"""RWKV WKV forward pass with persistent state (bfloat16 inputs/outputs, float32 ``w`` and ``s``).
|
| 70 |
+
|
| 71 |
+
Runs the CUDA kernel using and updating state ``s`` and writes the result into ``y``.
|
| 72 |
+
|
| 73 |
+
Args:
|
| 74 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 75 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 76 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 77 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 78 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 79 |
+
s: Stateful tensor, shape ``[B, C]``, dtype ``torch.float32`` (updated in-place).
|
| 80 |
+
|
| 81 |
+
Notes:
|
| 82 |
+
- All tensors must be on the same CUDA device.
|
| 83 |
+
- Shapes must agree on ``B`` and ``C``; ``y`` shares ``[B, T, C]`` with inputs.
|
| 84 |
+
"""
|
| 85 |
+
_validate_device_match((w, u, k, v, y, s))
|
| 86 |
+
ops.forward_with_state_bf16(w, u, k, v, y, s)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def backward(
|
| 90 |
+
w: Tensor,
|
| 91 |
+
u: Tensor,
|
| 92 |
+
k: Tensor,
|
| 93 |
+
v: Tensor,
|
| 94 |
+
y: Tensor,
|
| 95 |
+
gy: Tensor,
|
| 96 |
+
gw: Tensor,
|
| 97 |
+
gu: Tensor,
|
| 98 |
+
gk: Tensor,
|
| 99 |
+
gv: Tensor,
|
| 100 |
+
) -> None:
|
| 101 |
+
"""RWKV WKV backward pass (float32).
|
| 102 |
+
|
| 103 |
+
Writes gradients into the provided tensors in-place.
|
| 104 |
+
|
| 105 |
+
Args:
|
| 106 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 107 |
+
u, k, v, y: Forward-pass tensors, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 108 |
+
gy: Gradient of ``y``, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 109 |
+
gw: Gradient for ``w``, shape ``[C]``, dtype ``torch.float32`` (written in-place).
|
| 110 |
+
gu, gk, gv: Gradients for ``u``, ``k``, ``v`` respectively, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 111 |
+
|
| 112 |
+
Notes:
|
| 113 |
+
- All tensors must be on the same CUDA device.
|
| 114 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 115 |
+
"""
|
| 116 |
+
_validate_device_match((w, u, k, v, y, gy, gw, gu, gk, gv))
|
| 117 |
+
ops.backward(w, u, k, v, y, gy, gw, gu, gk, gv)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def backward_bf16(
|
| 121 |
+
w: Tensor,
|
| 122 |
+
u: Tensor,
|
| 123 |
+
k: Tensor,
|
| 124 |
+
v: Tensor,
|
| 125 |
+
y: Tensor,
|
| 126 |
+
gy: Tensor,
|
| 127 |
+
gw: Tensor,
|
| 128 |
+
gu: Tensor,
|
| 129 |
+
gk: Tensor,
|
| 130 |
+
gv: Tensor,
|
| 131 |
+
) -> None:
|
| 132 |
+
"""RWKV WKV backward pass (bfloat16 inputs/outputs/gradients, float32 ``w``).
|
| 133 |
+
|
| 134 |
+
Writes gradients into the provided tensors in-place.
|
| 135 |
+
|
| 136 |
+
Args:
|
| 137 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 138 |
+
u, k, v, y: Forward-pass tensors, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 139 |
+
gy: Gradient of ``y``, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 140 |
+
gw: Gradient for ``w``, shape ``[C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 141 |
+
gu, gk, gv: Gradients for ``u``, ``k``, ``v`` respectively, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 142 |
+
|
| 143 |
+
Notes:
|
| 144 |
+
- All tensors must be on the same CUDA device.
|
| 145 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 146 |
+
"""
|
| 147 |
+
_validate_device_match((w, u, k, v, y, gy, gw, gu, gk, gv))
|
| 148 |
+
ops.backward_bf16(w, u, k, v, y, gy, gw, gu, gk, gv)
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def _validate_device_match(tensors: Tuple[Tensor, ...]) -> None:
|
| 152 |
+
"""Minimal runtime validation that all tensors live on the same CUDA device."""
|
| 153 |
+
if not tensors:
|
| 154 |
+
return
|
| 155 |
+
device = tensors[0].device
|
| 156 |
+
if not device.type == "cuda":
|
| 157 |
+
raise RuntimeError("RWKV CUDA ops require CUDA tensors")
|
| 158 |
+
for t in tensors[1:]:
|
| 159 |
+
if t.device != device:
|
| 160 |
+
raise RuntimeError("All tensors must be on the same CUDA device")
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
__all__ = [
|
| 164 |
+
"forward",
|
| 165 |
+
"forward_bf16",
|
| 166 |
+
"forward_with_state",
|
| 167 |
+
"forward_with_state_bf16",
|
| 168 |
+
"backward",
|
| 169 |
+
"backward_bf16",
|
| 170 |
+
]
|
build/torch29-cxx11-cu128-x86_64-linux/rwkv/__pycache__/__init__.cpython-313.pyc
ADDED
|
Binary file (7.21 kB). View file
|
|
|
build/torch29-cxx11-cu128-x86_64-linux/rwkv/__pycache__/_ops.cpython-313.pyc
ADDED
|
Binary file (520 Bytes). View file
|
|
|
build/torch29-cxx11-cu128-x86_64-linux/rwkv/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _rwkv_eb0e3e5_dirty
|
| 3 |
+
ops = torch.ops._rwkv_eb0e3e5_dirty
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_rwkv_eb0e3e5_dirty::{op_name}"
|
build/torch29-cxx11-cu128-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ad6856c6dd2c9ed38dc4077f21c09cec11d0de47b870ae348d6576637f9816a2
|
| 3 |
+
size 2308848
|
build/torch29-cxx11-cu130-x86_64-linux/rwkv/__init__.py
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ._ops import ops
|
| 2 |
+
from typing import Tuple, Any
|
| 3 |
+
|
| 4 |
+
# Use a broad Tensor alias to avoid importing torch at import time.
|
| 5 |
+
from torch import Tensor
|
| 6 |
+
|
| 7 |
+
def forward(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor) -> None:
|
| 8 |
+
"""RWKV WKV forward pass (float32).
|
| 9 |
+
|
| 10 |
+
Runs the CUDA kernel and writes the result into ``y`` in-place.
|
| 11 |
+
|
| 12 |
+
Args:
|
| 13 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 14 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 15 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 16 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 17 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 18 |
+
|
| 19 |
+
Notes:
|
| 20 |
+
- All tensors must be on the same CUDA device.
|
| 21 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 22 |
+
"""
|
| 23 |
+
_validate_device_match((w, u, k, v, y))
|
| 24 |
+
ops.forward(w, u, k, v, y)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def forward_bf16(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor) -> None:
|
| 28 |
+
"""RWKV WKV forward pass (bfloat16 inputs/outputs, float32 ``w``).
|
| 29 |
+
|
| 30 |
+
Runs the CUDA kernel and writes the result into ``y`` in-place.
|
| 31 |
+
|
| 32 |
+
Args:
|
| 33 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 34 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 35 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 36 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 37 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 38 |
+
|
| 39 |
+
Notes:
|
| 40 |
+
- All tensors must be on the same CUDA device.
|
| 41 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 42 |
+
"""
|
| 43 |
+
_validate_device_match((w, u, k, v, y))
|
| 44 |
+
ops.forward_bf16(w, u, k, v, y)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def forward_with_state(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor, s: Tensor) -> None:
|
| 48 |
+
"""RWKV WKV forward pass with persistent state (float32).
|
| 49 |
+
|
| 50 |
+
Runs the CUDA kernel using and updating state ``s`` and writes the result into ``y``.
|
| 51 |
+
|
| 52 |
+
Args:
|
| 53 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 54 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 55 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 56 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 57 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 58 |
+
s: Stateful tensor, shape ``[B, C]``, dtype ``torch.float32`` (updated in-place).
|
| 59 |
+
|
| 60 |
+
Notes:
|
| 61 |
+
- All tensors must be on the same CUDA device.
|
| 62 |
+
- Shapes must agree on ``B`` and ``C``; ``y`` shares ``[B, T, C]`` with inputs.
|
| 63 |
+
"""
|
| 64 |
+
_validate_device_match((w, u, k, v, y, s))
|
| 65 |
+
ops.forward_with_state(w, u, k, v, y, s)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def forward_with_state_bf16(w: Tensor, u: Tensor, k: Tensor, v: Tensor, y: Tensor, s: Tensor) -> None:
|
| 69 |
+
"""RWKV WKV forward pass with persistent state (bfloat16 inputs/outputs, float32 ``w`` and ``s``).
|
| 70 |
+
|
| 71 |
+
Runs the CUDA kernel using and updating state ``s`` and writes the result into ``y``.
|
| 72 |
+
|
| 73 |
+
Args:
|
| 74 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 75 |
+
u: Input tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 76 |
+
k: Key tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 77 |
+
v: Value tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 78 |
+
y: Output tensor, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 79 |
+
s: Stateful tensor, shape ``[B, C]``, dtype ``torch.float32`` (updated in-place).
|
| 80 |
+
|
| 81 |
+
Notes:
|
| 82 |
+
- All tensors must be on the same CUDA device.
|
| 83 |
+
- Shapes must agree on ``B`` and ``C``; ``y`` shares ``[B, T, C]`` with inputs.
|
| 84 |
+
"""
|
| 85 |
+
_validate_device_match((w, u, k, v, y, s))
|
| 86 |
+
ops.forward_with_state_bf16(w, u, k, v, y, s)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def backward(
|
| 90 |
+
w: Tensor,
|
| 91 |
+
u: Tensor,
|
| 92 |
+
k: Tensor,
|
| 93 |
+
v: Tensor,
|
| 94 |
+
y: Tensor,
|
| 95 |
+
gy: Tensor,
|
| 96 |
+
gw: Tensor,
|
| 97 |
+
gu: Tensor,
|
| 98 |
+
gk: Tensor,
|
| 99 |
+
gv: Tensor,
|
| 100 |
+
) -> None:
|
| 101 |
+
"""RWKV WKV backward pass (float32).
|
| 102 |
+
|
| 103 |
+
Writes gradients into the provided tensors in-place.
|
| 104 |
+
|
| 105 |
+
Args:
|
| 106 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 107 |
+
u, k, v, y: Forward-pass tensors, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 108 |
+
gy: Gradient of ``y``, shape ``[B, T, C]``, dtype ``torch.float32``.
|
| 109 |
+
gw: Gradient for ``w``, shape ``[C]``, dtype ``torch.float32`` (written in-place).
|
| 110 |
+
gu, gk, gv: Gradients for ``u``, ``k``, ``v`` respectively, shape ``[B, T, C]``, dtype ``torch.float32`` (written in-place).
|
| 111 |
+
|
| 112 |
+
Notes:
|
| 113 |
+
- All tensors must be on the same CUDA device.
|
| 114 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 115 |
+
"""
|
| 116 |
+
_validate_device_match((w, u, k, v, y, gy, gw, gu, gk, gv))
|
| 117 |
+
ops.backward(w, u, k, v, y, gy, gw, gu, gk, gv)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def backward_bf16(
|
| 121 |
+
w: Tensor,
|
| 122 |
+
u: Tensor,
|
| 123 |
+
k: Tensor,
|
| 124 |
+
v: Tensor,
|
| 125 |
+
y: Tensor,
|
| 126 |
+
gy: Tensor,
|
| 127 |
+
gw: Tensor,
|
| 128 |
+
gu: Tensor,
|
| 129 |
+
gk: Tensor,
|
| 130 |
+
gv: Tensor,
|
| 131 |
+
) -> None:
|
| 132 |
+
"""RWKV WKV backward pass (bfloat16 inputs/outputs/gradients, float32 ``w``).
|
| 133 |
+
|
| 134 |
+
Writes gradients into the provided tensors in-place.
|
| 135 |
+
|
| 136 |
+
Args:
|
| 137 |
+
w: Decay weights, shape ``[C]``, dtype ``torch.float32``.
|
| 138 |
+
u, k, v, y: Forward-pass tensors, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 139 |
+
gy: Gradient of ``y``, shape ``[B, T, C]``, dtype ``torch.bfloat16``.
|
| 140 |
+
gw: Gradient for ``w``, shape ``[C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 141 |
+
gu, gk, gv: Gradients for ``u``, ``k``, ``v`` respectively, shape ``[B, T, C]``, dtype ``torch.bfloat16`` (written in-place).
|
| 142 |
+
|
| 143 |
+
Notes:
|
| 144 |
+
- All tensors must be on the same CUDA device.
|
| 145 |
+
- Shapes must agree on ``B``, ``T`` and ``C``.
|
| 146 |
+
"""
|
| 147 |
+
_validate_device_match((w, u, k, v, y, gy, gw, gu, gk, gv))
|
| 148 |
+
ops.backward_bf16(w, u, k, v, y, gy, gw, gu, gk, gv)
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def _validate_device_match(tensors: Tuple[Tensor, ...]) -> None:
|
| 152 |
+
"""Minimal runtime validation that all tensors live on the same CUDA device."""
|
| 153 |
+
if not tensors:
|
| 154 |
+
return
|
| 155 |
+
device = tensors[0].device
|
| 156 |
+
if not device.type == "cuda":
|
| 157 |
+
raise RuntimeError("RWKV CUDA ops require CUDA tensors")
|
| 158 |
+
for t in tensors[1:]:
|
| 159 |
+
if t.device != device:
|
| 160 |
+
raise RuntimeError("All tensors must be on the same CUDA device")
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
__all__ = [
|
| 164 |
+
"forward",
|
| 165 |
+
"forward_bf16",
|
| 166 |
+
"forward_with_state",
|
| 167 |
+
"forward_with_state_bf16",
|
| 168 |
+
"backward",
|
| 169 |
+
"backward_bf16",
|
| 170 |
+
]
|
build/torch29-cxx11-cu130-x86_64-linux/rwkv/__pycache__/__init__.cpython-313.pyc
ADDED
|
Binary file (7.21 kB). View file
|
|
|
build/torch29-cxx11-cu130-x86_64-linux/rwkv/__pycache__/_ops.cpython-313.pyc
ADDED
|
Binary file (520 Bytes). View file
|
|
|
build/torch29-cxx11-cu130-x86_64-linux/rwkv/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _rwkv_eb0e3e5_dirty
|
| 3 |
+
ops = torch.ops._rwkv_eb0e3e5_dirty
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_rwkv_eb0e3e5_dirty::{op_name}"
|
build/torch29-cxx11-cu130-x86_64-linux/rwkv/_rwkv_eb0e3e5_dirty.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dbe5a4e59abcaf208a0b7e0c952821d9585431aec58ca2364881d5239ac5819e
|
| 3 |
+
size 2334744
|
flake.lock
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"nodes": {
|
| 3 |
+
"flake-compat": {
|
| 4 |
+
"locked": {
|
| 5 |
+
"lastModified": 1747046372,
|
| 6 |
+
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
|
| 7 |
+
"owner": "edolstra",
|
| 8 |
+
"repo": "flake-compat",
|
| 9 |
+
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
|
| 10 |
+
"type": "github"
|
| 11 |
+
},
|
| 12 |
+
"original": {
|
| 13 |
+
"owner": "edolstra",
|
| 14 |
+
"repo": "flake-compat",
|
| 15 |
+
"type": "github"
|
| 16 |
+
}
|
| 17 |
+
},
|
| 18 |
+
"flake-compat_2": {
|
| 19 |
+
"locked": {
|
| 20 |
+
"lastModified": 1747046372,
|
| 21 |
+
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
|
| 22 |
+
"owner": "edolstra",
|
| 23 |
+
"repo": "flake-compat",
|
| 24 |
+
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
|
| 25 |
+
"type": "github"
|
| 26 |
+
},
|
| 27 |
+
"original": {
|
| 28 |
+
"owner": "edolstra",
|
| 29 |
+
"repo": "flake-compat",
|
| 30 |
+
"type": "github"
|
| 31 |
+
}
|
| 32 |
+
},
|
| 33 |
+
"flake-utils": {
|
| 34 |
+
"inputs": {
|
| 35 |
+
"systems": "systems"
|
| 36 |
+
},
|
| 37 |
+
"locked": {
|
| 38 |
+
"lastModified": 1731533236,
|
| 39 |
+
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
| 40 |
+
"owner": "numtide",
|
| 41 |
+
"repo": "flake-utils",
|
| 42 |
+
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
| 43 |
+
"type": "github"
|
| 44 |
+
},
|
| 45 |
+
"original": {
|
| 46 |
+
"owner": "numtide",
|
| 47 |
+
"repo": "flake-utils",
|
| 48 |
+
"type": "github"
|
| 49 |
+
}
|
| 50 |
+
},
|
| 51 |
+
"flake-utils_2": {
|
| 52 |
+
"inputs": {
|
| 53 |
+
"systems": "systems_2"
|
| 54 |
+
},
|
| 55 |
+
"locked": {
|
| 56 |
+
"lastModified": 1731533236,
|
| 57 |
+
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
| 58 |
+
"owner": "numtide",
|
| 59 |
+
"repo": "flake-utils",
|
| 60 |
+
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
| 61 |
+
"type": "github"
|
| 62 |
+
},
|
| 63 |
+
"original": {
|
| 64 |
+
"owner": "numtide",
|
| 65 |
+
"repo": "flake-utils",
|
| 66 |
+
"type": "github"
|
| 67 |
+
}
|
| 68 |
+
},
|
| 69 |
+
"hf-nix": {
|
| 70 |
+
"inputs": {
|
| 71 |
+
"flake-compat": "flake-compat_2",
|
| 72 |
+
"flake-utils": "flake-utils_2",
|
| 73 |
+
"nixpkgs": "nixpkgs"
|
| 74 |
+
},
|
| 75 |
+
"locked": {
|
| 76 |
+
"lastModified": 1759851564,
|
| 77 |
+
"narHash": "sha256-Xybkhm0FM/VzlZ5WndTYq/X/9MAeddd4EQ2Vz8GdkOA=",
|
| 78 |
+
"owner": "huggingface",
|
| 79 |
+
"repo": "hf-nix",
|
| 80 |
+
"rev": "351655d9f124805ed7c1193aa61550ce245f4570",
|
| 81 |
+
"type": "github"
|
| 82 |
+
},
|
| 83 |
+
"original": {
|
| 84 |
+
"owner": "huggingface",
|
| 85 |
+
"repo": "hf-nix",
|
| 86 |
+
"type": "github"
|
| 87 |
+
}
|
| 88 |
+
},
|
| 89 |
+
"kernel-builder": {
|
| 90 |
+
"inputs": {
|
| 91 |
+
"flake-compat": "flake-compat",
|
| 92 |
+
"flake-utils": "flake-utils",
|
| 93 |
+
"hf-nix": "hf-nix",
|
| 94 |
+
"nixpkgs": [
|
| 95 |
+
"kernel-builder",
|
| 96 |
+
"hf-nix",
|
| 97 |
+
"nixpkgs"
|
| 98 |
+
]
|
| 99 |
+
},
|
| 100 |
+
"locked": {
|
| 101 |
+
"lastModified": 1760035358,
|
| 102 |
+
"narHash": "sha256-N5vmCrgwcIluPclf/hmnofLK77EJJYh5PR8SRvw++es=",
|
| 103 |
+
"owner": "huggingface",
|
| 104 |
+
"repo": "kernel-builder",
|
| 105 |
+
"rev": "a48cbd19ae7e425dfc1865188ef06dac43ab9244",
|
| 106 |
+
"type": "github"
|
| 107 |
+
},
|
| 108 |
+
"original": {
|
| 109 |
+
"owner": "huggingface",
|
| 110 |
+
"repo": "kernel-builder",
|
| 111 |
+
"type": "github"
|
| 112 |
+
}
|
| 113 |
+
},
|
| 114 |
+
"nixpkgs": {
|
| 115 |
+
"locked": {
|
| 116 |
+
"lastModified": 1755963616,
|
| 117 |
+
"narHash": "sha256-6yD0ww/S8n+U2uPYcJZ3DRURP8Kx036GRpR2uPNZroE=",
|
| 118 |
+
"owner": "nixos",
|
| 119 |
+
"repo": "nixpkgs",
|
| 120 |
+
"rev": "73e96df7cff5783f45e21342a75a1540c4eddce4",
|
| 121 |
+
"type": "github"
|
| 122 |
+
},
|
| 123 |
+
"original": {
|
| 124 |
+
"owner": "nixos",
|
| 125 |
+
"ref": "nixos-unstable-small",
|
| 126 |
+
"repo": "nixpkgs",
|
| 127 |
+
"type": "github"
|
| 128 |
+
}
|
| 129 |
+
},
|
| 130 |
+
"root": {
|
| 131 |
+
"inputs": {
|
| 132 |
+
"kernel-builder": "kernel-builder"
|
| 133 |
+
}
|
| 134 |
+
},
|
| 135 |
+
"systems": {
|
| 136 |
+
"locked": {
|
| 137 |
+
"lastModified": 1681028828,
|
| 138 |
+
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
| 139 |
+
"owner": "nix-systems",
|
| 140 |
+
"repo": "default",
|
| 141 |
+
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
| 142 |
+
"type": "github"
|
| 143 |
+
},
|
| 144 |
+
"original": {
|
| 145 |
+
"owner": "nix-systems",
|
| 146 |
+
"repo": "default",
|
| 147 |
+
"type": "github"
|
| 148 |
+
}
|
| 149 |
+
},
|
| 150 |
+
"systems_2": {
|
| 151 |
+
"locked": {
|
| 152 |
+
"lastModified": 1681028828,
|
| 153 |
+
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
| 154 |
+
"owner": "nix-systems",
|
| 155 |
+
"repo": "default",
|
| 156 |
+
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
| 157 |
+
"type": "github"
|
| 158 |
+
},
|
| 159 |
+
"original": {
|
| 160 |
+
"owner": "nix-systems",
|
| 161 |
+
"repo": "default",
|
| 162 |
+
"type": "github"
|
| 163 |
+
}
|
| 164 |
+
}
|
| 165 |
+
},
|
| 166 |
+
"root": "root",
|
| 167 |
+
"version": 7
|
| 168 |
+
}
|
flake.nix
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
description = "Flake for rwkv kernels";
|
| 3 |
+
|
| 4 |
+
inputs = {
|
| 5 |
+
kernel-builder.url = "github:huggingface/kernel-builder";
|
| 6 |
+
};
|
| 7 |
+
|
| 8 |
+
outputs =
|
| 9 |
+
{
|
| 10 |
+
self,
|
| 11 |
+
kernel-builder,
|
| 12 |
+
}:
|
| 13 |
+
kernel-builder.lib.genFlakeOutputs {
|
| 14 |
+
path = ./.;
|
| 15 |
+
rev = self.shortRev or self.dirtyShortRev or self.lastModifiedDate;
|
| 16 |
+
};
|
| 17 |
+
}
|