Promote latest kernel artifacts to main
Browse files- .gitattributes +3 -35
- README.md +0 -9
- build/torch211-cxx11-cu128-x86_64-linux/__init__.py +54 -0
- build/torch211-cxx11-cu128-x86_64-linux/_linear_attention_seq_state_cuda_dc145d0.abi3.so +3 -0
- build/torch211-cxx11-cu128-x86_64-linux/_ops.py +9 -0
- build/torch211-cxx11-cu128-x86_64-linux/linear_attention_seq_state/__init__.py +26 -0
- build/torch211-cxx11-cu128-x86_64-linux/metadata.json +23 -0
- build/torch211-cxx11-cu130-x86_64-linux/__init__.py +54 -0
- build/torch211-cxx11-cu130-x86_64-linux/_linear_attention_seq_state_cuda_dc145d0.abi3.so +3 -0
- build/torch211-cxx11-cu130-x86_64-linux/_ops.py +9 -0
- build/torch211-cxx11-cu130-x86_64-linux/linear_attention_seq_state/__init__.py +26 -0
- build/torch211-cxx11-cu130-x86_64-linux/metadata.json +22 -0
- build/torch212-cxx11-cu130-x86_64-linux/__init__.py +54 -0
- build/torch212-cxx11-cu130-x86_64-linux/_linear_attention_seq_state_cuda_dc145d0.abi3.so +3 -0
- build/torch212-cxx11-cu130-x86_64-linux/_ops.py +9 -0
- build/torch212-cxx11-cu130-x86_64-linux/linear_attention_seq_state/__init__.py +26 -0
- build/torch212-cxx11-cu130-x86_64-linux/metadata.json +22 -0
- build/torch212-cxx11-cu132-x86_64-linux/__init__.py +54 -0
- build/torch212-cxx11-cu132-x86_64-linux/_linear_attention_seq_state_cuda_dc145d0.abi3.so +3 -0
- build/torch212-cxx11-cu132-x86_64-linux/_ops.py +9 -0
- build/torch212-cxx11-cu132-x86_64-linux/linear_attention_seq_state/__init__.py +26 -0
- build/torch212-cxx11-cu132-x86_64-linux/metadata.json +22 -0
.gitattributes
CHANGED
|
@@ -1,35 +1,3 @@
|
|
| 1 |
-
*.
|
| 2 |
-
*.
|
| 3 |
-
*.
|
| 4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
-
*.xz 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
|
|
|
|
| 1 |
+
*.so filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.pyd filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.dylib filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
# flashrt/linear-attention-seq-state
|
| 2 |
-
|
| 3 |
-
This repository is a compatibility mirror for older `kernels` clients
|
| 4 |
-
that resolve repositories through the default Hugging Face model repo API.
|
| 5 |
-
|
| 6 |
-
Canonical Kernel Hub repo: https://huggingface.co/kernels/flashrt/linear-attention-seq-state
|
| 7 |
-
|
| 8 |
-
Do not edit this mirror by hand. It is generated from the Kernel Hub
|
| 9 |
-
`vN` branches and contains the same `build/**` artifacts.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch211-cxx11-cu128-x86_64-linux/__init__.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FlashRT sequential state-scan kernels for linear attention."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from typing import Optional
|
| 6 |
+
|
| 7 |
+
import torch
|
| 8 |
+
|
| 9 |
+
from ._ops import add_op_namespace_prefix, ops
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@torch.library.register_fake(add_op_namespace_prefix("gated_delta_recurrent_seq_bf16"))
|
| 13 |
+
def _gated_delta_recurrent_seq_fake(
|
| 14 |
+
q: torch.Tensor,
|
| 15 |
+
k: torch.Tensor,
|
| 16 |
+
v: torch.Tensor,
|
| 17 |
+
g: torch.Tensor,
|
| 18 |
+
beta: torch.Tensor,
|
| 19 |
+
state: torch.Tensor,
|
| 20 |
+
out: torch.Tensor,
|
| 21 |
+
use_qk_l2norm: bool = False,
|
| 22 |
+
) -> None:
|
| 23 |
+
if q.dim() != 3 or k.shape != q.shape or v.shape != q.shape:
|
| 24 |
+
raise RuntimeError("q/k/v must have shape (S,H,D)")
|
| 25 |
+
if g.shape != (q.shape[0], q.shape[1]) or beta.shape != g.shape:
|
| 26 |
+
raise RuntimeError("g/beta must have shape (S,H)")
|
| 27 |
+
if state.shape != (q.shape[1], q.shape[2], q.shape[2]) or out.shape != q.shape:
|
| 28 |
+
raise RuntimeError("state/out shape mismatch")
|
| 29 |
+
return None
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def gated_delta_recurrent_seq_bf16(
|
| 33 |
+
q: torch.Tensor,
|
| 34 |
+
k: torch.Tensor,
|
| 35 |
+
v: torch.Tensor,
|
| 36 |
+
g: torch.Tensor,
|
| 37 |
+
beta: torch.Tensor,
|
| 38 |
+
state: torch.Tensor,
|
| 39 |
+
*,
|
| 40 |
+
out: Optional[torch.Tensor] = None,
|
| 41 |
+
use_qk_l2norm: bool = False,
|
| 42 |
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
| 43 |
+
"""Scan a full `(S,H,128)` Gated DeltaNet sequence in one launch.
|
| 44 |
+
|
| 45 |
+
`state` is updated in place with the final `(H,128,128)` state.
|
| 46 |
+
"""
|
| 47 |
+
|
| 48 |
+
if out is None:
|
| 49 |
+
out = torch.empty_like(q)
|
| 50 |
+
ops.gated_delta_recurrent_seq_bf16(q, k, v, g, beta, state, out, bool(use_qk_l2norm))
|
| 51 |
+
return out, state
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
__all__ = ["gated_delta_recurrent_seq_bf16"]
|
build/torch211-cxx11-cu128-x86_64-linux/_linear_attention_seq_state_cuda_dc145d0.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fe0391f1ed2474da4990a40bbfb4bf9c2437135ea9c178f80316b5aefbc79dde
|
| 3 |
+
size 246792
|
build/torch211-cxx11-cu128-x86_64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _linear_attention_seq_state_cuda_dc145d0
|
| 3 |
+
ops = torch.ops._linear_attention_seq_state_cuda_dc145d0
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_linear_attention_seq_state_cuda_dc145d0::{op_name}"
|
build/torch211-cxx11-cu128-x86_64-linux/linear_attention_seq_state/__init__.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import ctypes
|
| 2 |
+
import importlib.util
|
| 3 |
+
import sys
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
from types import ModuleType
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def _import_from_path(file_path: Path) -> ModuleType:
|
| 9 |
+
# We cannot use the module name as-is, after adding it to `sys.modules`,
|
| 10 |
+
# it would also be used for other imports. So, we make a module name that
|
| 11 |
+
# depends on the path for it to be unique using the hex-encoded hash of
|
| 12 |
+
# the path.
|
| 13 |
+
path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
|
| 14 |
+
module_name = path_hash
|
| 15 |
+
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
| 16 |
+
if spec is None:
|
| 17 |
+
raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
|
| 18 |
+
module = importlib.util.module_from_spec(spec)
|
| 19 |
+
if module is None:
|
| 20 |
+
raise ImportError(f"Cannot load module {module_name} from spec")
|
| 21 |
+
sys.modules[module_name] = module
|
| 22 |
+
spec.loader.exec_module(module) # type: ignore
|
| 23 |
+
return module
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
|
build/torch211-cxx11-cu128-x86_64-linux/metadata.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "linear-attention-seq-state",
|
| 3 |
+
"id": "_linear_attention_seq_state_cuda_dc145d0",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "Apache-2.0",
|
| 6 |
+
"python-depends": [],
|
| 7 |
+
"backend": {
|
| 8 |
+
"type": "cuda",
|
| 9 |
+
"archs": [
|
| 10 |
+
"10.0",
|
| 11 |
+
"10.1",
|
| 12 |
+
"12.0+PTX",
|
| 13 |
+
"7.0",
|
| 14 |
+
"7.2",
|
| 15 |
+
"7.5",
|
| 16 |
+
"8.0",
|
| 17 |
+
"8.6",
|
| 18 |
+
"8.7",
|
| 19 |
+
"8.9",
|
| 20 |
+
"9.0"
|
| 21 |
+
]
|
| 22 |
+
}
|
| 23 |
+
}
|
build/torch211-cxx11-cu130-x86_64-linux/__init__.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FlashRT sequential state-scan kernels for linear attention."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from typing import Optional
|
| 6 |
+
|
| 7 |
+
import torch
|
| 8 |
+
|
| 9 |
+
from ._ops import add_op_namespace_prefix, ops
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@torch.library.register_fake(add_op_namespace_prefix("gated_delta_recurrent_seq_bf16"))
|
| 13 |
+
def _gated_delta_recurrent_seq_fake(
|
| 14 |
+
q: torch.Tensor,
|
| 15 |
+
k: torch.Tensor,
|
| 16 |
+
v: torch.Tensor,
|
| 17 |
+
g: torch.Tensor,
|
| 18 |
+
beta: torch.Tensor,
|
| 19 |
+
state: torch.Tensor,
|
| 20 |
+
out: torch.Tensor,
|
| 21 |
+
use_qk_l2norm: bool = False,
|
| 22 |
+
) -> None:
|
| 23 |
+
if q.dim() != 3 or k.shape != q.shape or v.shape != q.shape:
|
| 24 |
+
raise RuntimeError("q/k/v must have shape (S,H,D)")
|
| 25 |
+
if g.shape != (q.shape[0], q.shape[1]) or beta.shape != g.shape:
|
| 26 |
+
raise RuntimeError("g/beta must have shape (S,H)")
|
| 27 |
+
if state.shape != (q.shape[1], q.shape[2], q.shape[2]) or out.shape != q.shape:
|
| 28 |
+
raise RuntimeError("state/out shape mismatch")
|
| 29 |
+
return None
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def gated_delta_recurrent_seq_bf16(
|
| 33 |
+
q: torch.Tensor,
|
| 34 |
+
k: torch.Tensor,
|
| 35 |
+
v: torch.Tensor,
|
| 36 |
+
g: torch.Tensor,
|
| 37 |
+
beta: torch.Tensor,
|
| 38 |
+
state: torch.Tensor,
|
| 39 |
+
*,
|
| 40 |
+
out: Optional[torch.Tensor] = None,
|
| 41 |
+
use_qk_l2norm: bool = False,
|
| 42 |
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
| 43 |
+
"""Scan a full `(S,H,128)` Gated DeltaNet sequence in one launch.
|
| 44 |
+
|
| 45 |
+
`state` is updated in place with the final `(H,128,128)` state.
|
| 46 |
+
"""
|
| 47 |
+
|
| 48 |
+
if out is None:
|
| 49 |
+
out = torch.empty_like(q)
|
| 50 |
+
ops.gated_delta_recurrent_seq_bf16(q, k, v, g, beta, state, out, bool(use_qk_l2norm))
|
| 51 |
+
return out, state
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
__all__ = ["gated_delta_recurrent_seq_bf16"]
|
build/torch211-cxx11-cu130-x86_64-linux/_linear_attention_seq_state_cuda_dc145d0.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:307c8f19b1b276ffbd5816f4a13752496316825999ef1e4575deda9daf301312
|
| 3 |
+
size 239784
|
build/torch211-cxx11-cu130-x86_64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _linear_attention_seq_state_cuda_dc145d0
|
| 3 |
+
ops = torch.ops._linear_attention_seq_state_cuda_dc145d0
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_linear_attention_seq_state_cuda_dc145d0::{op_name}"
|
build/torch211-cxx11-cu130-x86_64-linux/linear_attention_seq_state/__init__.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import ctypes
|
| 2 |
+
import importlib.util
|
| 3 |
+
import sys
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
from types import ModuleType
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def _import_from_path(file_path: Path) -> ModuleType:
|
| 9 |
+
# We cannot use the module name as-is, after adding it to `sys.modules`,
|
| 10 |
+
# it would also be used for other imports. So, we make a module name that
|
| 11 |
+
# depends on the path for it to be unique using the hex-encoded hash of
|
| 12 |
+
# the path.
|
| 13 |
+
path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
|
| 14 |
+
module_name = path_hash
|
| 15 |
+
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
| 16 |
+
if spec is None:
|
| 17 |
+
raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
|
| 18 |
+
module = importlib.util.module_from_spec(spec)
|
| 19 |
+
if module is None:
|
| 20 |
+
raise ImportError(f"Cannot load module {module_name} from spec")
|
| 21 |
+
sys.modules[module_name] = module
|
| 22 |
+
spec.loader.exec_module(module) # type: ignore
|
| 23 |
+
return module
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
|
build/torch211-cxx11-cu130-x86_64-linux/metadata.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "linear-attention-seq-state",
|
| 3 |
+
"id": "_linear_attention_seq_state_cuda_dc145d0",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "Apache-2.0",
|
| 6 |
+
"python-depends": [],
|
| 7 |
+
"backend": {
|
| 8 |
+
"type": "cuda",
|
| 9 |
+
"archs": [
|
| 10 |
+
"10.0",
|
| 11 |
+
"11.0",
|
| 12 |
+
"12.0",
|
| 13 |
+
"12.1+PTX",
|
| 14 |
+
"7.5",
|
| 15 |
+
"8.0",
|
| 16 |
+
"8.6",
|
| 17 |
+
"8.7",
|
| 18 |
+
"8.9",
|
| 19 |
+
"9.0"
|
| 20 |
+
]
|
| 21 |
+
}
|
| 22 |
+
}
|
build/torch212-cxx11-cu130-x86_64-linux/__init__.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FlashRT sequential state-scan kernels for linear attention."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from typing import Optional
|
| 6 |
+
|
| 7 |
+
import torch
|
| 8 |
+
|
| 9 |
+
from ._ops import add_op_namespace_prefix, ops
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@torch.library.register_fake(add_op_namespace_prefix("gated_delta_recurrent_seq_bf16"))
|
| 13 |
+
def _gated_delta_recurrent_seq_fake(
|
| 14 |
+
q: torch.Tensor,
|
| 15 |
+
k: torch.Tensor,
|
| 16 |
+
v: torch.Tensor,
|
| 17 |
+
g: torch.Tensor,
|
| 18 |
+
beta: torch.Tensor,
|
| 19 |
+
state: torch.Tensor,
|
| 20 |
+
out: torch.Tensor,
|
| 21 |
+
use_qk_l2norm: bool = False,
|
| 22 |
+
) -> None:
|
| 23 |
+
if q.dim() != 3 or k.shape != q.shape or v.shape != q.shape:
|
| 24 |
+
raise RuntimeError("q/k/v must have shape (S,H,D)")
|
| 25 |
+
if g.shape != (q.shape[0], q.shape[1]) or beta.shape != g.shape:
|
| 26 |
+
raise RuntimeError("g/beta must have shape (S,H)")
|
| 27 |
+
if state.shape != (q.shape[1], q.shape[2], q.shape[2]) or out.shape != q.shape:
|
| 28 |
+
raise RuntimeError("state/out shape mismatch")
|
| 29 |
+
return None
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def gated_delta_recurrent_seq_bf16(
|
| 33 |
+
q: torch.Tensor,
|
| 34 |
+
k: torch.Tensor,
|
| 35 |
+
v: torch.Tensor,
|
| 36 |
+
g: torch.Tensor,
|
| 37 |
+
beta: torch.Tensor,
|
| 38 |
+
state: torch.Tensor,
|
| 39 |
+
*,
|
| 40 |
+
out: Optional[torch.Tensor] = None,
|
| 41 |
+
use_qk_l2norm: bool = False,
|
| 42 |
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
| 43 |
+
"""Scan a full `(S,H,128)` Gated DeltaNet sequence in one launch.
|
| 44 |
+
|
| 45 |
+
`state` is updated in place with the final `(H,128,128)` state.
|
| 46 |
+
"""
|
| 47 |
+
|
| 48 |
+
if out is None:
|
| 49 |
+
out = torch.empty_like(q)
|
| 50 |
+
ops.gated_delta_recurrent_seq_bf16(q, k, v, g, beta, state, out, bool(use_qk_l2norm))
|
| 51 |
+
return out, state
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
__all__ = ["gated_delta_recurrent_seq_bf16"]
|
build/torch212-cxx11-cu130-x86_64-linux/_linear_attention_seq_state_cuda_dc145d0.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:35325c9c634607ddf35e0cdb9da57ba374aab7990261c190106145fcf42e494a
|
| 3 |
+
size 250696
|
build/torch212-cxx11-cu130-x86_64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _linear_attention_seq_state_cuda_dc145d0
|
| 3 |
+
ops = torch.ops._linear_attention_seq_state_cuda_dc145d0
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_linear_attention_seq_state_cuda_dc145d0::{op_name}"
|
build/torch212-cxx11-cu130-x86_64-linux/linear_attention_seq_state/__init__.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import ctypes
|
| 2 |
+
import importlib.util
|
| 3 |
+
import sys
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
from types import ModuleType
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def _import_from_path(file_path: Path) -> ModuleType:
|
| 9 |
+
# We cannot use the module name as-is, after adding it to `sys.modules`,
|
| 10 |
+
# it would also be used for other imports. So, we make a module name that
|
| 11 |
+
# depends on the path for it to be unique using the hex-encoded hash of
|
| 12 |
+
# the path.
|
| 13 |
+
path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
|
| 14 |
+
module_name = path_hash
|
| 15 |
+
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
| 16 |
+
if spec is None:
|
| 17 |
+
raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
|
| 18 |
+
module = importlib.util.module_from_spec(spec)
|
| 19 |
+
if module is None:
|
| 20 |
+
raise ImportError(f"Cannot load module {module_name} from spec")
|
| 21 |
+
sys.modules[module_name] = module
|
| 22 |
+
spec.loader.exec_module(module) # type: ignore
|
| 23 |
+
return module
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
|
build/torch212-cxx11-cu130-x86_64-linux/metadata.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "linear-attention-seq-state",
|
| 3 |
+
"id": "_linear_attention_seq_state_cuda_dc145d0",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "Apache-2.0",
|
| 6 |
+
"python-depends": [],
|
| 7 |
+
"backend": {
|
| 8 |
+
"type": "cuda",
|
| 9 |
+
"archs": [
|
| 10 |
+
"10.0",
|
| 11 |
+
"11.0",
|
| 12 |
+
"12.0",
|
| 13 |
+
"12.1+PTX",
|
| 14 |
+
"7.5",
|
| 15 |
+
"8.0",
|
| 16 |
+
"8.6",
|
| 17 |
+
"8.7",
|
| 18 |
+
"8.9",
|
| 19 |
+
"9.0"
|
| 20 |
+
]
|
| 21 |
+
}
|
| 22 |
+
}
|
build/torch212-cxx11-cu132-x86_64-linux/__init__.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FlashRT sequential state-scan kernels for linear attention."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from typing import Optional
|
| 6 |
+
|
| 7 |
+
import torch
|
| 8 |
+
|
| 9 |
+
from ._ops import add_op_namespace_prefix, ops
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@torch.library.register_fake(add_op_namespace_prefix("gated_delta_recurrent_seq_bf16"))
|
| 13 |
+
def _gated_delta_recurrent_seq_fake(
|
| 14 |
+
q: torch.Tensor,
|
| 15 |
+
k: torch.Tensor,
|
| 16 |
+
v: torch.Tensor,
|
| 17 |
+
g: torch.Tensor,
|
| 18 |
+
beta: torch.Tensor,
|
| 19 |
+
state: torch.Tensor,
|
| 20 |
+
out: torch.Tensor,
|
| 21 |
+
use_qk_l2norm: bool = False,
|
| 22 |
+
) -> None:
|
| 23 |
+
if q.dim() != 3 or k.shape != q.shape or v.shape != q.shape:
|
| 24 |
+
raise RuntimeError("q/k/v must have shape (S,H,D)")
|
| 25 |
+
if g.shape != (q.shape[0], q.shape[1]) or beta.shape != g.shape:
|
| 26 |
+
raise RuntimeError("g/beta must have shape (S,H)")
|
| 27 |
+
if state.shape != (q.shape[1], q.shape[2], q.shape[2]) or out.shape != q.shape:
|
| 28 |
+
raise RuntimeError("state/out shape mismatch")
|
| 29 |
+
return None
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def gated_delta_recurrent_seq_bf16(
|
| 33 |
+
q: torch.Tensor,
|
| 34 |
+
k: torch.Tensor,
|
| 35 |
+
v: torch.Tensor,
|
| 36 |
+
g: torch.Tensor,
|
| 37 |
+
beta: torch.Tensor,
|
| 38 |
+
state: torch.Tensor,
|
| 39 |
+
*,
|
| 40 |
+
out: Optional[torch.Tensor] = None,
|
| 41 |
+
use_qk_l2norm: bool = False,
|
| 42 |
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
| 43 |
+
"""Scan a full `(S,H,128)` Gated DeltaNet sequence in one launch.
|
| 44 |
+
|
| 45 |
+
`state` is updated in place with the final `(H,128,128)` state.
|
| 46 |
+
"""
|
| 47 |
+
|
| 48 |
+
if out is None:
|
| 49 |
+
out = torch.empty_like(q)
|
| 50 |
+
ops.gated_delta_recurrent_seq_bf16(q, k, v, g, beta, state, out, bool(use_qk_l2norm))
|
| 51 |
+
return out, state
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
__all__ = ["gated_delta_recurrent_seq_bf16"]
|
build/torch212-cxx11-cu132-x86_64-linux/_linear_attention_seq_state_cuda_dc145d0.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b15ccae32f404cded7121d50917afb3697c717d5ca9b1a9335ebbd991dd7dcca
|
| 3 |
+
size 250696
|
build/torch212-cxx11-cu132-x86_64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _linear_attention_seq_state_cuda_dc145d0
|
| 3 |
+
ops = torch.ops._linear_attention_seq_state_cuda_dc145d0
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_linear_attention_seq_state_cuda_dc145d0::{op_name}"
|
build/torch212-cxx11-cu132-x86_64-linux/linear_attention_seq_state/__init__.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import ctypes
|
| 2 |
+
import importlib.util
|
| 3 |
+
import sys
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
from types import ModuleType
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def _import_from_path(file_path: Path) -> ModuleType:
|
| 9 |
+
# We cannot use the module name as-is, after adding it to `sys.modules`,
|
| 10 |
+
# it would also be used for other imports. So, we make a module name that
|
| 11 |
+
# depends on the path for it to be unique using the hex-encoded hash of
|
| 12 |
+
# the path.
|
| 13 |
+
path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
|
| 14 |
+
module_name = path_hash
|
| 15 |
+
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
| 16 |
+
if spec is None:
|
| 17 |
+
raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
|
| 18 |
+
module = importlib.util.module_from_spec(spec)
|
| 19 |
+
if module is None:
|
| 20 |
+
raise ImportError(f"Cannot load module {module_name} from spec")
|
| 21 |
+
sys.modules[module_name] = module
|
| 22 |
+
spec.loader.exec_module(module) # type: ignore
|
| 23 |
+
return module
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
|
build/torch212-cxx11-cu132-x86_64-linux/metadata.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "linear-attention-seq-state",
|
| 3 |
+
"id": "_linear_attention_seq_state_cuda_dc145d0",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "Apache-2.0",
|
| 6 |
+
"python-depends": [],
|
| 7 |
+
"backend": {
|
| 8 |
+
"type": "cuda",
|
| 9 |
+
"archs": [
|
| 10 |
+
"10.0",
|
| 11 |
+
"11.0",
|
| 12 |
+
"12.0",
|
| 13 |
+
"12.1+PTX",
|
| 14 |
+
"7.5",
|
| 15 |
+
"8.0",
|
| 16 |
+
"8.6",
|
| 17 |
+
"8.7",
|
| 18 |
+
"8.9",
|
| 19 |
+
"9.0"
|
| 20 |
+
]
|
| 21 |
+
}
|
| 22 |
+
}
|