Uploaded using `kernel-builder`.
Browse files- build/torch212-cxx11-cu130-x86_64-linux/{_causal_conv1d_state_cuda_22d776b.abi3.so → _causal_conv1d_state_cuda_8589753.abi3.so} +1 -1
- build/torch212-cxx11-cu130-x86_64-linux/_ops.py +3 -3
- build/torch212-cxx11-cu130-x86_64-linux/causal_conv1d_state/__init__.py +0 -26
- build/torch212-cxx11-cu130-x86_64-linux/metadata.json +21 -2
- build/torch212-cxx11-cu132-x86_64-linux/{_causal_conv1d_state_cuda_22d776b.abi3.so → _causal_conv1d_state_cuda_8589753.abi3.so} +1 -1
- build/torch212-cxx11-cu132-x86_64-linux/_ops.py +3 -3
- build/torch212-cxx11-cu132-x86_64-linux/causal_conv1d_state/__init__.py +0 -26
- build/torch212-cxx11-cu132-x86_64-linux/metadata.json +21 -2
- build/torch213-cxx11-cu130-x86_64-linux/__init__.py +305 -0
- build/torch213-cxx11-cu130-x86_64-linux/_causal_conv1d_state_cuda_8589753.abi3.so +3 -0
- build/torch213-cxx11-cu130-x86_64-linux/_ops.py +9 -0
- build/torch213-cxx11-cu130-x86_64-linux/metadata.json +41 -0
- build/torch213-cxx11-cu132-x86_64-linux/__init__.py +305 -0
- build/torch213-cxx11-cu132-x86_64-linux/_causal_conv1d_state_cuda_8589753.abi3.so +3 -0
- build/torch213-cxx11-cu132-x86_64-linux/_ops.py +9 -0
- build/torch213-cxx11-cu132-x86_64-linux/metadata.json +41 -0
build/torch212-cxx11-cu130-x86_64-linux/{_causal_conv1d_state_cuda_22d776b.abi3.so → _causal_conv1d_state_cuda_8589753.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 1256392
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3b22d80b41c587dbf1b30addb26be2c65c37168871b823b26548d8c8109053b1
|
| 3 |
size 1256392
|
build/torch212-cxx11-cu130-x86_64-linux/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _causal_conv1d_state_cuda_8589753
|
| 3 |
+
ops = torch.ops._causal_conv1d_state_cuda_8589753
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_causal_conv1d_state_cuda_8589753::{op_name}"
|
build/torch212-cxx11-cu130-x86_64-linux/causal_conv1d_state/__init__.py
DELETED
|
@@ -1,26 +0,0 @@
|
|
| 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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "causal-conv1d-state",
|
| 3 |
-
"id": "
|
| 4 |
"version": 2,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
@@ -18,5 +18,24 @@
|
|
| 18 |
"8.9",
|
| 19 |
"9.0"
|
| 20 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
}
|
| 22 |
-
}
|
|
|
|
| 1 |
{
|
| 2 |
"name": "causal-conv1d-state",
|
| 3 |
+
"id": "_causal_conv1d_state_cuda_8589753",
|
| 4 |
"version": 2,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
|
|
| 18 |
"8.9",
|
| 19 |
"9.0"
|
| 20 |
]
|
| 21 |
+
},
|
| 22 |
+
"digest": {
|
| 23 |
+
"algorithm": "sha256",
|
| 24 |
+
"files": {
|
| 25 |
+
"__init__.py": "jC3cFEzRQxoloALJMANJU4Px3BpryCaxyVp+MdmTj6Q=",
|
| 26 |
+
"_causal_conv1d_state_cuda_8589753.abi3.so": "OyLYC0HFh9vxswrdsmvixlw3FohxuCOyZUjYyBCQU7E=",
|
| 27 |
+
"_ops.py": "XOwQje24M0e2Is75hhdYmSaw60wjwb/z4WY2Fza5UIc="
|
| 28 |
+
}
|
| 29 |
+
},
|
| 30 |
+
"provenance": {
|
| 31 |
+
"kernel-builder": {
|
| 32 |
+
"version": "0.17.0-dev0",
|
| 33 |
+
"sha": "81f55ea30fd8f819dcf93a3c934dd584c895bd2f",
|
| 34 |
+
"dirty": false
|
| 35 |
+
},
|
| 36 |
+
"kernel": {
|
| 37 |
+
"sha": "85897539ddf848f1cbd4bb17d24c89030d2c33e2",
|
| 38 |
+
"dirty": false
|
| 39 |
+
}
|
| 40 |
}
|
| 41 |
+
}
|
build/torch212-cxx11-cu132-x86_64-linux/{_causal_conv1d_state_cuda_22d776b.abi3.so → _causal_conv1d_state_cuda_8589753.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 1264584
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9a19590b37857c264d674fd768c1a98fdc74cd4def6234f7d7883575bcac9b13
|
| 3 |
size 1264584
|
build/torch212-cxx11-cu132-x86_64-linux/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _causal_conv1d_state_cuda_8589753
|
| 3 |
+
ops = torch.ops._causal_conv1d_state_cuda_8589753
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_causal_conv1d_state_cuda_8589753::{op_name}"
|
build/torch212-cxx11-cu132-x86_64-linux/causal_conv1d_state/__init__.py
DELETED
|
@@ -1,26 +0,0 @@
|
|
| 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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "causal-conv1d-state",
|
| 3 |
-
"id": "
|
| 4 |
"version": 2,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
@@ -18,5 +18,24 @@
|
|
| 18 |
"8.9",
|
| 19 |
"9.0"
|
| 20 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
}
|
| 22 |
-
}
|
|
|
|
| 1 |
{
|
| 2 |
"name": "causal-conv1d-state",
|
| 3 |
+
"id": "_causal_conv1d_state_cuda_8589753",
|
| 4 |
"version": 2,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
|
|
| 18 |
"8.9",
|
| 19 |
"9.0"
|
| 20 |
]
|
| 21 |
+
},
|
| 22 |
+
"digest": {
|
| 23 |
+
"algorithm": "sha256",
|
| 24 |
+
"files": {
|
| 25 |
+
"__init__.py": "jC3cFEzRQxoloALJMANJU4Px3BpryCaxyVp+MdmTj6Q=",
|
| 26 |
+
"_causal_conv1d_state_cuda_8589753.abi3.so": "mhlZCzeFfCZNZ0/XaMGpj9x0zU3vYjT314g1dbysmxM=",
|
| 27 |
+
"_ops.py": "XOwQje24M0e2Is75hhdYmSaw60wjwb/z4WY2Fza5UIc="
|
| 28 |
+
}
|
| 29 |
+
},
|
| 30 |
+
"provenance": {
|
| 31 |
+
"kernel-builder": {
|
| 32 |
+
"version": "0.17.0-dev0",
|
| 33 |
+
"sha": "81f55ea30fd8f819dcf93a3c934dd584c895bd2f",
|
| 34 |
+
"dirty": false
|
| 35 |
+
},
|
| 36 |
+
"kernel": {
|
| 37 |
+
"sha": "85897539ddf848f1cbd4bb17d24c89030d2c33e2",
|
| 38 |
+
"dirty": false
|
| 39 |
+
}
|
| 40 |
}
|
| 41 |
+
}
|
build/torch213-cxx11-cu130-x86_64-linux/__init__.py
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FlashRT causal Conv1D state kernels."""
|
| 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 |
+
def _empty_bias_like(x: torch.Tensor) -> torch.Tensor:
|
| 13 |
+
return torch.empty((0,), device=x.device, dtype=torch.bfloat16)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def _check_conv_shapes(x: torch.Tensor, w: torch.Tensor, bias: torch.Tensor, has_bias: bool, out: torch.Tensor) -> None:
|
| 17 |
+
if x.dim() != 3:
|
| 18 |
+
raise RuntimeError("x must have shape (B,S,C)")
|
| 19 |
+
if w.dim() != 2 or w.shape[0] != x.shape[2] or w.shape[1] < 2 or w.shape[1] > 8:
|
| 20 |
+
raise RuntimeError("w must have shape (C,K), 2 <= K <= 8")
|
| 21 |
+
if has_bias and bias.shape != (x.shape[2],):
|
| 22 |
+
raise RuntimeError("bias must have shape (C,)")
|
| 23 |
+
if out.shape != x.shape:
|
| 24 |
+
raise RuntimeError("out must match x shape")
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
@torch.library.register_fake(add_op_namespace_prefix("causal_conv1d_bf16"))
|
| 28 |
+
def _causal_conv1d_bf16_fake(
|
| 29 |
+
x: torch.Tensor,
|
| 30 |
+
w: torch.Tensor,
|
| 31 |
+
bias: torch.Tensor,
|
| 32 |
+
out: torch.Tensor,
|
| 33 |
+
has_bias: bool = True,
|
| 34 |
+
apply_silu: bool = True,
|
| 35 |
+
) -> None:
|
| 36 |
+
_check_conv_shapes(x, w, bias, has_bias, out)
|
| 37 |
+
return None
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
@torch.library.register_fake(add_op_namespace_prefix("causal_conv1d_update_bf16"))
|
| 41 |
+
def _causal_conv1d_update_bf16_fake(
|
| 42 |
+
x_new: torch.Tensor,
|
| 43 |
+
w: torch.Tensor,
|
| 44 |
+
bias: torch.Tensor,
|
| 45 |
+
state: torch.Tensor,
|
| 46 |
+
out: torch.Tensor,
|
| 47 |
+
has_bias: bool = True,
|
| 48 |
+
apply_silu: bool = True,
|
| 49 |
+
) -> None:
|
| 50 |
+
if x_new.dim() != 2:
|
| 51 |
+
raise RuntimeError("x_new must have shape (B,C)")
|
| 52 |
+
b, c = x_new.shape
|
| 53 |
+
if w.dim() != 2 or w.shape[0] != c or w.shape[1] < 2 or w.shape[1] > 8:
|
| 54 |
+
raise RuntimeError("w must have shape (C,K), 2 <= K <= 8")
|
| 55 |
+
if has_bias and bias.shape != (c,):
|
| 56 |
+
raise RuntimeError("bias must have shape (C,)")
|
| 57 |
+
if state.shape != (b, c, w.shape[1] - 1):
|
| 58 |
+
raise RuntimeError("state must have shape (B,C,K-1)")
|
| 59 |
+
if out.shape != x_new.shape:
|
| 60 |
+
raise RuntimeError("out must match x_new shape")
|
| 61 |
+
return None
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
@torch.library.register_fake(add_op_namespace_prefix("causal_conv1d_update_inout_bf16"))
|
| 65 |
+
def _causal_conv1d_update_inout_bf16_fake(
|
| 66 |
+
x_new: torch.Tensor,
|
| 67 |
+
w: torch.Tensor,
|
| 68 |
+
bias: torch.Tensor,
|
| 69 |
+
state_in: torch.Tensor,
|
| 70 |
+
state_out: torch.Tensor,
|
| 71 |
+
out: torch.Tensor,
|
| 72 |
+
has_bias: bool = True,
|
| 73 |
+
apply_silu: bool = True,
|
| 74 |
+
) -> None:
|
| 75 |
+
_causal_conv1d_update_bf16_fake(x_new, w, bias, state_in, out, has_bias, apply_silu)
|
| 76 |
+
if state_out.shape != state_in.shape:
|
| 77 |
+
raise RuntimeError("state_out shape mismatch")
|
| 78 |
+
return None
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
@torch.library.register_fake(add_op_namespace_prefix("causal_conv1d_update_chunk_bf16"))
|
| 82 |
+
def _causal_conv1d_update_chunk_bf16_fake(
|
| 83 |
+
x: torch.Tensor,
|
| 84 |
+
w: torch.Tensor,
|
| 85 |
+
bias: torch.Tensor,
|
| 86 |
+
state: torch.Tensor,
|
| 87 |
+
out: torch.Tensor,
|
| 88 |
+
has_bias: bool = True,
|
| 89 |
+
apply_silu: bool = True,
|
| 90 |
+
) -> None:
|
| 91 |
+
_check_conv_shapes(x, w, bias, has_bias, out)
|
| 92 |
+
if state.shape != (x.shape[0], x.shape[2], w.shape[1] - 1):
|
| 93 |
+
raise RuntimeError("state must have shape (B,C,K-1)")
|
| 94 |
+
return None
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
@torch.library.register_fake(add_op_namespace_prefix("causal_conv1d_update_chunk_parallel_bf16"))
|
| 98 |
+
def _causal_conv1d_update_chunk_parallel_bf16_fake(
|
| 99 |
+
x: torch.Tensor,
|
| 100 |
+
w: torch.Tensor,
|
| 101 |
+
bias: torch.Tensor,
|
| 102 |
+
state: torch.Tensor,
|
| 103 |
+
out: torch.Tensor,
|
| 104 |
+
has_bias: bool = True,
|
| 105 |
+
apply_silu: bool = True,
|
| 106 |
+
) -> None:
|
| 107 |
+
_causal_conv1d_update_chunk_bf16_fake(x, w, bias, state, out, has_bias, apply_silu)
|
| 108 |
+
return None
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
@torch.library.register_fake(add_op_namespace_prefix("causal_conv1d_update_chunk_parallel_gqa_bf16"))
|
| 112 |
+
def _causal_conv1d_update_chunk_parallel_gqa_bf16_fake(
|
| 113 |
+
x: torch.Tensor,
|
| 114 |
+
w: torch.Tensor,
|
| 115 |
+
bias: torch.Tensor,
|
| 116 |
+
state: torch.Tensor,
|
| 117 |
+
q16: torch.Tensor,
|
| 118 |
+
k16: torch.Tensor,
|
| 119 |
+
v48: torch.Tensor,
|
| 120 |
+
has_bias: bool = True,
|
| 121 |
+
apply_silu: bool = True,
|
| 122 |
+
) -> None:
|
| 123 |
+
if x.dim() != 3 or x.shape[2] != 10240:
|
| 124 |
+
raise RuntimeError("GQA split variant expects x shape (B,S,10240)")
|
| 125 |
+
if w.shape != (10240, w.shape[1]) or w.shape[1] < 2 or w.shape[1] > 8:
|
| 126 |
+
raise RuntimeError("w must have shape (10240,K), 2 <= K <= 8")
|
| 127 |
+
b, s, _ = x.shape
|
| 128 |
+
if state.shape != (b, 10240, w.shape[1] - 1):
|
| 129 |
+
raise RuntimeError("state must have shape (B,10240,K-1)")
|
| 130 |
+
if q16.shape != (b, s, 16, 128) or k16.shape != q16.shape or v48.shape != (b, s, 48, 128):
|
| 131 |
+
raise RuntimeError("q16/k16/v48 output shape mismatch")
|
| 132 |
+
if has_bias and bias.shape != (10240,):
|
| 133 |
+
raise RuntimeError("bias must have shape (10240,)")
|
| 134 |
+
return None
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
@torch.library.register_fake(add_op_namespace_prefix("causal_conv1d_update_steps_gqa_bf16"))
|
| 138 |
+
def _causal_conv1d_update_steps_gqa_bf16_fake(
|
| 139 |
+
x, w, bias, state, q16, k16, v48, apply_silu: bool = True
|
| 140 |
+
) -> None:
|
| 141 |
+
del apply_silu
|
| 142 |
+
if x.dim() != 2 or x.shape[1] != 10240:
|
| 143 |
+
raise RuntimeError("x must have shape (S,10240)")
|
| 144 |
+
s = x.shape[0]
|
| 145 |
+
if w.shape != (10240, 4) or bias.shape != (10240,) or state.shape != (10240, 3):
|
| 146 |
+
raise RuntimeError("w/bias/state shape contract failed")
|
| 147 |
+
if q16.shape != (s, 2048) or k16.shape != q16.shape or v48.shape != (s, 6144):
|
| 148 |
+
raise RuntimeError("q16/k16/v48 output shape mismatch")
|
| 149 |
+
return None
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
def causal_conv1d_bf16(
|
| 153 |
+
x: torch.Tensor,
|
| 154 |
+
w: torch.Tensor,
|
| 155 |
+
bias: Optional[torch.Tensor] = None,
|
| 156 |
+
*,
|
| 157 |
+
apply_silu: bool = True,
|
| 158 |
+
out: Optional[torch.Tensor] = None,
|
| 159 |
+
) -> torch.Tensor:
|
| 160 |
+
if out is None:
|
| 161 |
+
out = torch.empty_like(x)
|
| 162 |
+
has_bias = bias is not None
|
| 163 |
+
if bias is None:
|
| 164 |
+
bias = _empty_bias_like(x)
|
| 165 |
+
ops.causal_conv1d_bf16(x, w, bias, out, bool(has_bias), bool(apply_silu))
|
| 166 |
+
return out
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def causal_conv1d_update_bf16(
|
| 170 |
+
x_new: torch.Tensor,
|
| 171 |
+
w: torch.Tensor,
|
| 172 |
+
state: torch.Tensor,
|
| 173 |
+
bias: Optional[torch.Tensor] = None,
|
| 174 |
+
*,
|
| 175 |
+
apply_silu: bool = True,
|
| 176 |
+
out: Optional[torch.Tensor] = None,
|
| 177 |
+
) -> torch.Tensor:
|
| 178 |
+
if out is None:
|
| 179 |
+
out = torch.empty_like(x_new)
|
| 180 |
+
has_bias = bias is not None
|
| 181 |
+
if bias is None:
|
| 182 |
+
bias = _empty_bias_like(x_new)
|
| 183 |
+
ops.causal_conv1d_update_bf16(x_new, w, bias, state, out, bool(has_bias), bool(apply_silu))
|
| 184 |
+
return out
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def causal_conv1d_update_inout_bf16(
|
| 188 |
+
x_new: torch.Tensor,
|
| 189 |
+
w: torch.Tensor,
|
| 190 |
+
state_in: torch.Tensor,
|
| 191 |
+
bias: Optional[torch.Tensor] = None,
|
| 192 |
+
*,
|
| 193 |
+
apply_silu: bool = True,
|
| 194 |
+
out: Optional[torch.Tensor] = None,
|
| 195 |
+
state_out: Optional[torch.Tensor] = None,
|
| 196 |
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
| 197 |
+
if out is None:
|
| 198 |
+
out = torch.empty_like(x_new)
|
| 199 |
+
if state_out is None:
|
| 200 |
+
state_out = torch.empty_like(state_in)
|
| 201 |
+
has_bias = bias is not None
|
| 202 |
+
if bias is None:
|
| 203 |
+
bias = _empty_bias_like(x_new)
|
| 204 |
+
ops.causal_conv1d_update_inout_bf16(
|
| 205 |
+
x_new, w, bias, state_in, state_out, out, bool(has_bias), bool(apply_silu)
|
| 206 |
+
)
|
| 207 |
+
return out, state_out
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
def causal_conv1d_update_chunk_bf16(
|
| 211 |
+
x: torch.Tensor,
|
| 212 |
+
w: torch.Tensor,
|
| 213 |
+
state: torch.Tensor,
|
| 214 |
+
bias: Optional[torch.Tensor] = None,
|
| 215 |
+
*,
|
| 216 |
+
apply_silu: bool = True,
|
| 217 |
+
out: Optional[torch.Tensor] = None,
|
| 218 |
+
) -> torch.Tensor:
|
| 219 |
+
if out is None:
|
| 220 |
+
out = torch.empty_like(x)
|
| 221 |
+
has_bias = bias is not None
|
| 222 |
+
if bias is None:
|
| 223 |
+
bias = _empty_bias_like(x)
|
| 224 |
+
ops.causal_conv1d_update_chunk_bf16(x, w, bias, state, out, bool(has_bias), bool(apply_silu))
|
| 225 |
+
return out
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
def causal_conv1d_update_chunk_parallel_bf16(
|
| 229 |
+
x: torch.Tensor,
|
| 230 |
+
w: torch.Tensor,
|
| 231 |
+
state: torch.Tensor,
|
| 232 |
+
bias: Optional[torch.Tensor] = None,
|
| 233 |
+
*,
|
| 234 |
+
apply_silu: bool = True,
|
| 235 |
+
out: Optional[torch.Tensor] = None,
|
| 236 |
+
) -> torch.Tensor:
|
| 237 |
+
if out is None:
|
| 238 |
+
out = torch.empty_like(x)
|
| 239 |
+
has_bias = bias is not None
|
| 240 |
+
if bias is None:
|
| 241 |
+
bias = _empty_bias_like(x)
|
| 242 |
+
ops.causal_conv1d_update_chunk_parallel_bf16(x, w, bias, state, out, bool(has_bias), bool(apply_silu))
|
| 243 |
+
return out
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
def causal_conv1d_update_chunk_parallel_gqa_bf16(
|
| 247 |
+
x: torch.Tensor,
|
| 248 |
+
w: torch.Tensor,
|
| 249 |
+
state: torch.Tensor,
|
| 250 |
+
bias: Optional[torch.Tensor] = None,
|
| 251 |
+
*,
|
| 252 |
+
apply_silu: bool = True,
|
| 253 |
+
q16: Optional[torch.Tensor] = None,
|
| 254 |
+
k16: Optional[torch.Tensor] = None,
|
| 255 |
+
v48: Optional[torch.Tensor] = None,
|
| 256 |
+
) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
| 257 |
+
b, s, _ = x.shape
|
| 258 |
+
if q16 is None:
|
| 259 |
+
q16 = torch.empty((b, s, 16, 128), device=x.device, dtype=torch.bfloat16)
|
| 260 |
+
if k16 is None:
|
| 261 |
+
k16 = torch.empty_like(q16)
|
| 262 |
+
if v48 is None:
|
| 263 |
+
v48 = torch.empty((b, s, 48, 128), device=x.device, dtype=torch.bfloat16)
|
| 264 |
+
has_bias = bias is not None
|
| 265 |
+
if bias is None:
|
| 266 |
+
bias = _empty_bias_like(x)
|
| 267 |
+
ops.causal_conv1d_update_chunk_parallel_gqa_bf16(
|
| 268 |
+
x, w, bias, state, q16, k16, v48, bool(has_bias), bool(apply_silu)
|
| 269 |
+
)
|
| 270 |
+
return q16, k16, v48
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
def causal_conv1d_update_steps_gqa_bf16(
|
| 274 |
+
x: torch.Tensor,
|
| 275 |
+
w: torch.Tensor,
|
| 276 |
+
state: torch.Tensor,
|
| 277 |
+
bias: torch.Tensor,
|
| 278 |
+
*,
|
| 279 |
+
apply_silu: bool = True,
|
| 280 |
+
q16: Optional[torch.Tensor] = None,
|
| 281 |
+
k16: Optional[torch.Tensor] = None,
|
| 282 |
+
v48: Optional[torch.Tensor] = None,
|
| 283 |
+
) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
| 284 |
+
s = x.shape[0]
|
| 285 |
+
if q16 is None:
|
| 286 |
+
q16 = torch.empty((s, 2048), device=x.device, dtype=torch.bfloat16)
|
| 287 |
+
if k16 is None:
|
| 288 |
+
k16 = torch.empty_like(q16)
|
| 289 |
+
if v48 is None:
|
| 290 |
+
v48 = torch.empty((s, 6144), device=x.device, dtype=torch.bfloat16)
|
| 291 |
+
ops.causal_conv1d_update_steps_gqa_bf16(
|
| 292 |
+
x, w, bias, state, q16, k16, v48, bool(apply_silu)
|
| 293 |
+
)
|
| 294 |
+
return q16, k16, v48
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
__all__ = [
|
| 298 |
+
"causal_conv1d_bf16",
|
| 299 |
+
"causal_conv1d_update_bf16",
|
| 300 |
+
"causal_conv1d_update_inout_bf16",
|
| 301 |
+
"causal_conv1d_update_chunk_bf16",
|
| 302 |
+
"causal_conv1d_update_chunk_parallel_bf16",
|
| 303 |
+
"causal_conv1d_update_chunk_parallel_gqa_bf16",
|
| 304 |
+
"causal_conv1d_update_steps_gqa_bf16",
|
| 305 |
+
]
|
build/torch213-cxx11-cu130-x86_64-linux/_causal_conv1d_state_cuda_8589753.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:449890100502e5de595e747fafb3c9b2816255b8780754cf9aa362b244a67d25
|
| 3 |
+
size 1256232
|
build/torch213-cxx11-cu130-x86_64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _causal_conv1d_state_cuda_8589753
|
| 3 |
+
ops = torch.ops._causal_conv1d_state_cuda_8589753
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_causal_conv1d_state_cuda_8589753::{op_name}"
|
build/torch213-cxx11-cu130-x86_64-linux/metadata.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "causal-conv1d-state",
|
| 3 |
+
"id": "_causal_conv1d_state_cuda_8589753",
|
| 4 |
+
"version": 2,
|
| 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 |
+
"digest": {
|
| 23 |
+
"algorithm": "sha256",
|
| 24 |
+
"files": {
|
| 25 |
+
"__init__.py": "jC3cFEzRQxoloALJMANJU4Px3BpryCaxyVp+MdmTj6Q=",
|
| 26 |
+
"_causal_conv1d_state_cuda_8589753.abi3.so": "RJiQEAUC5d5ZXnR/r7PJsoFiVbh4B1TPmqNiskSmfSU=",
|
| 27 |
+
"_ops.py": "XOwQje24M0e2Is75hhdYmSaw60wjwb/z4WY2Fza5UIc="
|
| 28 |
+
}
|
| 29 |
+
},
|
| 30 |
+
"provenance": {
|
| 31 |
+
"kernel-builder": {
|
| 32 |
+
"version": "0.17.0-dev0",
|
| 33 |
+
"sha": "81f55ea30fd8f819dcf93a3c934dd584c895bd2f",
|
| 34 |
+
"dirty": false
|
| 35 |
+
},
|
| 36 |
+
"kernel": {
|
| 37 |
+
"sha": "85897539ddf848f1cbd4bb17d24c89030d2c33e2",
|
| 38 |
+
"dirty": false
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
}
|
build/torch213-cxx11-cu132-x86_64-linux/__init__.py
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FlashRT causal Conv1D state kernels."""
|
| 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 |
+
def _empty_bias_like(x: torch.Tensor) -> torch.Tensor:
|
| 13 |
+
return torch.empty((0,), device=x.device, dtype=torch.bfloat16)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def _check_conv_shapes(x: torch.Tensor, w: torch.Tensor, bias: torch.Tensor, has_bias: bool, out: torch.Tensor) -> None:
|
| 17 |
+
if x.dim() != 3:
|
| 18 |
+
raise RuntimeError("x must have shape (B,S,C)")
|
| 19 |
+
if w.dim() != 2 or w.shape[0] != x.shape[2] or w.shape[1] < 2 or w.shape[1] > 8:
|
| 20 |
+
raise RuntimeError("w must have shape (C,K), 2 <= K <= 8")
|
| 21 |
+
if has_bias and bias.shape != (x.shape[2],):
|
| 22 |
+
raise RuntimeError("bias must have shape (C,)")
|
| 23 |
+
if out.shape != x.shape:
|
| 24 |
+
raise RuntimeError("out must match x shape")
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
@torch.library.register_fake(add_op_namespace_prefix("causal_conv1d_bf16"))
|
| 28 |
+
def _causal_conv1d_bf16_fake(
|
| 29 |
+
x: torch.Tensor,
|
| 30 |
+
w: torch.Tensor,
|
| 31 |
+
bias: torch.Tensor,
|
| 32 |
+
out: torch.Tensor,
|
| 33 |
+
has_bias: bool = True,
|
| 34 |
+
apply_silu: bool = True,
|
| 35 |
+
) -> None:
|
| 36 |
+
_check_conv_shapes(x, w, bias, has_bias, out)
|
| 37 |
+
return None
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
@torch.library.register_fake(add_op_namespace_prefix("causal_conv1d_update_bf16"))
|
| 41 |
+
def _causal_conv1d_update_bf16_fake(
|
| 42 |
+
x_new: torch.Tensor,
|
| 43 |
+
w: torch.Tensor,
|
| 44 |
+
bias: torch.Tensor,
|
| 45 |
+
state: torch.Tensor,
|
| 46 |
+
out: torch.Tensor,
|
| 47 |
+
has_bias: bool = True,
|
| 48 |
+
apply_silu: bool = True,
|
| 49 |
+
) -> None:
|
| 50 |
+
if x_new.dim() != 2:
|
| 51 |
+
raise RuntimeError("x_new must have shape (B,C)")
|
| 52 |
+
b, c = x_new.shape
|
| 53 |
+
if w.dim() != 2 or w.shape[0] != c or w.shape[1] < 2 or w.shape[1] > 8:
|
| 54 |
+
raise RuntimeError("w must have shape (C,K), 2 <= K <= 8")
|
| 55 |
+
if has_bias and bias.shape != (c,):
|
| 56 |
+
raise RuntimeError("bias must have shape (C,)")
|
| 57 |
+
if state.shape != (b, c, w.shape[1] - 1):
|
| 58 |
+
raise RuntimeError("state must have shape (B,C,K-1)")
|
| 59 |
+
if out.shape != x_new.shape:
|
| 60 |
+
raise RuntimeError("out must match x_new shape")
|
| 61 |
+
return None
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
@torch.library.register_fake(add_op_namespace_prefix("causal_conv1d_update_inout_bf16"))
|
| 65 |
+
def _causal_conv1d_update_inout_bf16_fake(
|
| 66 |
+
x_new: torch.Tensor,
|
| 67 |
+
w: torch.Tensor,
|
| 68 |
+
bias: torch.Tensor,
|
| 69 |
+
state_in: torch.Tensor,
|
| 70 |
+
state_out: torch.Tensor,
|
| 71 |
+
out: torch.Tensor,
|
| 72 |
+
has_bias: bool = True,
|
| 73 |
+
apply_silu: bool = True,
|
| 74 |
+
) -> None:
|
| 75 |
+
_causal_conv1d_update_bf16_fake(x_new, w, bias, state_in, out, has_bias, apply_silu)
|
| 76 |
+
if state_out.shape != state_in.shape:
|
| 77 |
+
raise RuntimeError("state_out shape mismatch")
|
| 78 |
+
return None
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
@torch.library.register_fake(add_op_namespace_prefix("causal_conv1d_update_chunk_bf16"))
|
| 82 |
+
def _causal_conv1d_update_chunk_bf16_fake(
|
| 83 |
+
x: torch.Tensor,
|
| 84 |
+
w: torch.Tensor,
|
| 85 |
+
bias: torch.Tensor,
|
| 86 |
+
state: torch.Tensor,
|
| 87 |
+
out: torch.Tensor,
|
| 88 |
+
has_bias: bool = True,
|
| 89 |
+
apply_silu: bool = True,
|
| 90 |
+
) -> None:
|
| 91 |
+
_check_conv_shapes(x, w, bias, has_bias, out)
|
| 92 |
+
if state.shape != (x.shape[0], x.shape[2], w.shape[1] - 1):
|
| 93 |
+
raise RuntimeError("state must have shape (B,C,K-1)")
|
| 94 |
+
return None
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
@torch.library.register_fake(add_op_namespace_prefix("causal_conv1d_update_chunk_parallel_bf16"))
|
| 98 |
+
def _causal_conv1d_update_chunk_parallel_bf16_fake(
|
| 99 |
+
x: torch.Tensor,
|
| 100 |
+
w: torch.Tensor,
|
| 101 |
+
bias: torch.Tensor,
|
| 102 |
+
state: torch.Tensor,
|
| 103 |
+
out: torch.Tensor,
|
| 104 |
+
has_bias: bool = True,
|
| 105 |
+
apply_silu: bool = True,
|
| 106 |
+
) -> None:
|
| 107 |
+
_causal_conv1d_update_chunk_bf16_fake(x, w, bias, state, out, has_bias, apply_silu)
|
| 108 |
+
return None
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
@torch.library.register_fake(add_op_namespace_prefix("causal_conv1d_update_chunk_parallel_gqa_bf16"))
|
| 112 |
+
def _causal_conv1d_update_chunk_parallel_gqa_bf16_fake(
|
| 113 |
+
x: torch.Tensor,
|
| 114 |
+
w: torch.Tensor,
|
| 115 |
+
bias: torch.Tensor,
|
| 116 |
+
state: torch.Tensor,
|
| 117 |
+
q16: torch.Tensor,
|
| 118 |
+
k16: torch.Tensor,
|
| 119 |
+
v48: torch.Tensor,
|
| 120 |
+
has_bias: bool = True,
|
| 121 |
+
apply_silu: bool = True,
|
| 122 |
+
) -> None:
|
| 123 |
+
if x.dim() != 3 or x.shape[2] != 10240:
|
| 124 |
+
raise RuntimeError("GQA split variant expects x shape (B,S,10240)")
|
| 125 |
+
if w.shape != (10240, w.shape[1]) or w.shape[1] < 2 or w.shape[1] > 8:
|
| 126 |
+
raise RuntimeError("w must have shape (10240,K), 2 <= K <= 8")
|
| 127 |
+
b, s, _ = x.shape
|
| 128 |
+
if state.shape != (b, 10240, w.shape[1] - 1):
|
| 129 |
+
raise RuntimeError("state must have shape (B,10240,K-1)")
|
| 130 |
+
if q16.shape != (b, s, 16, 128) or k16.shape != q16.shape or v48.shape != (b, s, 48, 128):
|
| 131 |
+
raise RuntimeError("q16/k16/v48 output shape mismatch")
|
| 132 |
+
if has_bias and bias.shape != (10240,):
|
| 133 |
+
raise RuntimeError("bias must have shape (10240,)")
|
| 134 |
+
return None
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
@torch.library.register_fake(add_op_namespace_prefix("causal_conv1d_update_steps_gqa_bf16"))
|
| 138 |
+
def _causal_conv1d_update_steps_gqa_bf16_fake(
|
| 139 |
+
x, w, bias, state, q16, k16, v48, apply_silu: bool = True
|
| 140 |
+
) -> None:
|
| 141 |
+
del apply_silu
|
| 142 |
+
if x.dim() != 2 or x.shape[1] != 10240:
|
| 143 |
+
raise RuntimeError("x must have shape (S,10240)")
|
| 144 |
+
s = x.shape[0]
|
| 145 |
+
if w.shape != (10240, 4) or bias.shape != (10240,) or state.shape != (10240, 3):
|
| 146 |
+
raise RuntimeError("w/bias/state shape contract failed")
|
| 147 |
+
if q16.shape != (s, 2048) or k16.shape != q16.shape or v48.shape != (s, 6144):
|
| 148 |
+
raise RuntimeError("q16/k16/v48 output shape mismatch")
|
| 149 |
+
return None
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
def causal_conv1d_bf16(
|
| 153 |
+
x: torch.Tensor,
|
| 154 |
+
w: torch.Tensor,
|
| 155 |
+
bias: Optional[torch.Tensor] = None,
|
| 156 |
+
*,
|
| 157 |
+
apply_silu: bool = True,
|
| 158 |
+
out: Optional[torch.Tensor] = None,
|
| 159 |
+
) -> torch.Tensor:
|
| 160 |
+
if out is None:
|
| 161 |
+
out = torch.empty_like(x)
|
| 162 |
+
has_bias = bias is not None
|
| 163 |
+
if bias is None:
|
| 164 |
+
bias = _empty_bias_like(x)
|
| 165 |
+
ops.causal_conv1d_bf16(x, w, bias, out, bool(has_bias), bool(apply_silu))
|
| 166 |
+
return out
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def causal_conv1d_update_bf16(
|
| 170 |
+
x_new: torch.Tensor,
|
| 171 |
+
w: torch.Tensor,
|
| 172 |
+
state: torch.Tensor,
|
| 173 |
+
bias: Optional[torch.Tensor] = None,
|
| 174 |
+
*,
|
| 175 |
+
apply_silu: bool = True,
|
| 176 |
+
out: Optional[torch.Tensor] = None,
|
| 177 |
+
) -> torch.Tensor:
|
| 178 |
+
if out is None:
|
| 179 |
+
out = torch.empty_like(x_new)
|
| 180 |
+
has_bias = bias is not None
|
| 181 |
+
if bias is None:
|
| 182 |
+
bias = _empty_bias_like(x_new)
|
| 183 |
+
ops.causal_conv1d_update_bf16(x_new, w, bias, state, out, bool(has_bias), bool(apply_silu))
|
| 184 |
+
return out
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def causal_conv1d_update_inout_bf16(
|
| 188 |
+
x_new: torch.Tensor,
|
| 189 |
+
w: torch.Tensor,
|
| 190 |
+
state_in: torch.Tensor,
|
| 191 |
+
bias: Optional[torch.Tensor] = None,
|
| 192 |
+
*,
|
| 193 |
+
apply_silu: bool = True,
|
| 194 |
+
out: Optional[torch.Tensor] = None,
|
| 195 |
+
state_out: Optional[torch.Tensor] = None,
|
| 196 |
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
| 197 |
+
if out is None:
|
| 198 |
+
out = torch.empty_like(x_new)
|
| 199 |
+
if state_out is None:
|
| 200 |
+
state_out = torch.empty_like(state_in)
|
| 201 |
+
has_bias = bias is not None
|
| 202 |
+
if bias is None:
|
| 203 |
+
bias = _empty_bias_like(x_new)
|
| 204 |
+
ops.causal_conv1d_update_inout_bf16(
|
| 205 |
+
x_new, w, bias, state_in, state_out, out, bool(has_bias), bool(apply_silu)
|
| 206 |
+
)
|
| 207 |
+
return out, state_out
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
def causal_conv1d_update_chunk_bf16(
|
| 211 |
+
x: torch.Tensor,
|
| 212 |
+
w: torch.Tensor,
|
| 213 |
+
state: torch.Tensor,
|
| 214 |
+
bias: Optional[torch.Tensor] = None,
|
| 215 |
+
*,
|
| 216 |
+
apply_silu: bool = True,
|
| 217 |
+
out: Optional[torch.Tensor] = None,
|
| 218 |
+
) -> torch.Tensor:
|
| 219 |
+
if out is None:
|
| 220 |
+
out = torch.empty_like(x)
|
| 221 |
+
has_bias = bias is not None
|
| 222 |
+
if bias is None:
|
| 223 |
+
bias = _empty_bias_like(x)
|
| 224 |
+
ops.causal_conv1d_update_chunk_bf16(x, w, bias, state, out, bool(has_bias), bool(apply_silu))
|
| 225 |
+
return out
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
def causal_conv1d_update_chunk_parallel_bf16(
|
| 229 |
+
x: torch.Tensor,
|
| 230 |
+
w: torch.Tensor,
|
| 231 |
+
state: torch.Tensor,
|
| 232 |
+
bias: Optional[torch.Tensor] = None,
|
| 233 |
+
*,
|
| 234 |
+
apply_silu: bool = True,
|
| 235 |
+
out: Optional[torch.Tensor] = None,
|
| 236 |
+
) -> torch.Tensor:
|
| 237 |
+
if out is None:
|
| 238 |
+
out = torch.empty_like(x)
|
| 239 |
+
has_bias = bias is not None
|
| 240 |
+
if bias is None:
|
| 241 |
+
bias = _empty_bias_like(x)
|
| 242 |
+
ops.causal_conv1d_update_chunk_parallel_bf16(x, w, bias, state, out, bool(has_bias), bool(apply_silu))
|
| 243 |
+
return out
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
def causal_conv1d_update_chunk_parallel_gqa_bf16(
|
| 247 |
+
x: torch.Tensor,
|
| 248 |
+
w: torch.Tensor,
|
| 249 |
+
state: torch.Tensor,
|
| 250 |
+
bias: Optional[torch.Tensor] = None,
|
| 251 |
+
*,
|
| 252 |
+
apply_silu: bool = True,
|
| 253 |
+
q16: Optional[torch.Tensor] = None,
|
| 254 |
+
k16: Optional[torch.Tensor] = None,
|
| 255 |
+
v48: Optional[torch.Tensor] = None,
|
| 256 |
+
) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
| 257 |
+
b, s, _ = x.shape
|
| 258 |
+
if q16 is None:
|
| 259 |
+
q16 = torch.empty((b, s, 16, 128), device=x.device, dtype=torch.bfloat16)
|
| 260 |
+
if k16 is None:
|
| 261 |
+
k16 = torch.empty_like(q16)
|
| 262 |
+
if v48 is None:
|
| 263 |
+
v48 = torch.empty((b, s, 48, 128), device=x.device, dtype=torch.bfloat16)
|
| 264 |
+
has_bias = bias is not None
|
| 265 |
+
if bias is None:
|
| 266 |
+
bias = _empty_bias_like(x)
|
| 267 |
+
ops.causal_conv1d_update_chunk_parallel_gqa_bf16(
|
| 268 |
+
x, w, bias, state, q16, k16, v48, bool(has_bias), bool(apply_silu)
|
| 269 |
+
)
|
| 270 |
+
return q16, k16, v48
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
def causal_conv1d_update_steps_gqa_bf16(
|
| 274 |
+
x: torch.Tensor,
|
| 275 |
+
w: torch.Tensor,
|
| 276 |
+
state: torch.Tensor,
|
| 277 |
+
bias: torch.Tensor,
|
| 278 |
+
*,
|
| 279 |
+
apply_silu: bool = True,
|
| 280 |
+
q16: Optional[torch.Tensor] = None,
|
| 281 |
+
k16: Optional[torch.Tensor] = None,
|
| 282 |
+
v48: Optional[torch.Tensor] = None,
|
| 283 |
+
) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
| 284 |
+
s = x.shape[0]
|
| 285 |
+
if q16 is None:
|
| 286 |
+
q16 = torch.empty((s, 2048), device=x.device, dtype=torch.bfloat16)
|
| 287 |
+
if k16 is None:
|
| 288 |
+
k16 = torch.empty_like(q16)
|
| 289 |
+
if v48 is None:
|
| 290 |
+
v48 = torch.empty((s, 6144), device=x.device, dtype=torch.bfloat16)
|
| 291 |
+
ops.causal_conv1d_update_steps_gqa_bf16(
|
| 292 |
+
x, w, bias, state, q16, k16, v48, bool(apply_silu)
|
| 293 |
+
)
|
| 294 |
+
return q16, k16, v48
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
__all__ = [
|
| 298 |
+
"causal_conv1d_bf16",
|
| 299 |
+
"causal_conv1d_update_bf16",
|
| 300 |
+
"causal_conv1d_update_inout_bf16",
|
| 301 |
+
"causal_conv1d_update_chunk_bf16",
|
| 302 |
+
"causal_conv1d_update_chunk_parallel_bf16",
|
| 303 |
+
"causal_conv1d_update_chunk_parallel_gqa_bf16",
|
| 304 |
+
"causal_conv1d_update_steps_gqa_bf16",
|
| 305 |
+
]
|
build/torch213-cxx11-cu132-x86_64-linux/_causal_conv1d_state_cuda_8589753.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fefab8142cd9d244dd948c26905edc8d689fceeb70b0ff9a2423c3fea23b5c2e
|
| 3 |
+
size 1264424
|
build/torch213-cxx11-cu132-x86_64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _causal_conv1d_state_cuda_8589753
|
| 3 |
+
ops = torch.ops._causal_conv1d_state_cuda_8589753
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_causal_conv1d_state_cuda_8589753::{op_name}"
|
build/torch213-cxx11-cu132-x86_64-linux/metadata.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "causal-conv1d-state",
|
| 3 |
+
"id": "_causal_conv1d_state_cuda_8589753",
|
| 4 |
+
"version": 2,
|
| 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 |
+
"digest": {
|
| 23 |
+
"algorithm": "sha256",
|
| 24 |
+
"files": {
|
| 25 |
+
"__init__.py": "jC3cFEzRQxoloALJMANJU4Px3BpryCaxyVp+MdmTj6Q=",
|
| 26 |
+
"_causal_conv1d_state_cuda_8589753.abi3.so": "/vq4FCzZ0kTdlIwmkF7cjWifzutwsP+aJCPD/qI7XC4=",
|
| 27 |
+
"_ops.py": "XOwQje24M0e2Is75hhdYmSaw60wjwb/z4WY2Fza5UIc="
|
| 28 |
+
}
|
| 29 |
+
},
|
| 30 |
+
"provenance": {
|
| 31 |
+
"kernel-builder": {
|
| 32 |
+
"version": "0.17.0-dev0",
|
| 33 |
+
"sha": "81f55ea30fd8f819dcf93a3c934dd584c895bd2f",
|
| 34 |
+
"dirty": false
|
| 35 |
+
},
|
| 36 |
+
"kernel": {
|
| 37 |
+
"sha": "85897539ddf848f1cbd4bb17d24c89030d2c33e2",
|
| 38 |
+
"dirty": false
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
}
|