Kernels:
Trusted publisher
Uploaded using `kernel-builder`.
Browse files- .gitattributes +9 -0
- build/torch210-cxx11-cu126-aarch64-linux/_ops.py +3 -3
- build/torch210-cxx11-cu126-aarch64-linux/{_tinygrad_rms_cuda_86f75d9.abi3.so → _tinygrad_rms_cuda_1917536.abi3.so} +1 -1
- build/torch210-cxx11-cu126-aarch64-linux/metadata.json +1 -1
- build/torch210-cxx11-cu128-aarch64-linux/_ops.py +3 -3
- build/torch210-cxx11-cu128-aarch64-linux/{_tinygrad_rms_cuda_86f75d9.abi3.so → _tinygrad_rms_cuda_1917536.abi3.so} +1 -1
- build/torch210-cxx11-cu128-aarch64-linux/metadata.json +1 -1
- build/torch210-cxx11-cu130-aarch64-linux/_ops.py +3 -3
- build/torch210-cxx11-cu130-aarch64-linux/{_tinygrad_rms_cuda_86f75d9.abi3.so → _tinygrad_rms_cuda_1917536.abi3.so} +1 -1
- build/torch210-cxx11-cu130-aarch64-linux/metadata.json +1 -1
- build/torch211-cxx11-cu126-aarch64-linux/_ops.py +3 -3
- build/torch211-cxx11-cu126-aarch64-linux/{_tinygrad_rms_cuda_86f75d9.abi3.so → _tinygrad_rms_cuda_1917536.abi3.so} +1 -1
- build/torch211-cxx11-cu126-aarch64-linux/metadata.json +1 -1
- build/torch211-cxx11-cu128-aarch64-linux/_ops.py +3 -3
- build/torch211-cxx11-cu128-aarch64-linux/{_tinygrad_rms_cuda_86f75d9.abi3.so → _tinygrad_rms_cuda_1917536.abi3.so} +1 -1
- build/torch211-cxx11-cu128-aarch64-linux/metadata.json +1 -1
- build/torch211-cxx11-cu130-aarch64-linux/_ops.py +3 -3
- build/torch211-cxx11-cu130-aarch64-linux/{_tinygrad_rms_cuda_86f75d9.abi3.so → _tinygrad_rms_cuda_1917536.abi3.so} +1 -1
- build/torch211-cxx11-cu130-aarch64-linux/metadata.json +1 -1
- build/torch212-cxx11-cu126-aarch64-linux/__init__.py +63 -0
- build/torch212-cxx11-cu126-aarch64-linux/_ops.py +9 -0
- build/torch212-cxx11-cu126-aarch64-linux/_tinygrad_rms_cuda_1917536.abi3.so +3 -0
- build/torch212-cxx11-cu126-aarch64-linux/metadata.json +20 -0
- build/torch212-cxx11-cu126-aarch64-linux/tinygrad_rms/__init__.py +26 -0
- build/torch212-cxx11-cu130-aarch64-linux/__init__.py +63 -0
- build/torch212-cxx11-cu130-aarch64-linux/_ops.py +9 -0
- build/torch212-cxx11-cu130-aarch64-linux/_tinygrad_rms_cuda_1917536.abi3.so +3 -0
- build/torch212-cxx11-cu130-aarch64-linux/metadata.json +21 -0
- build/torch212-cxx11-cu130-aarch64-linux/tinygrad_rms/__init__.py +26 -0
- build/torch212-cxx11-cu132-aarch64-linux/__init__.py +63 -0
- build/torch212-cxx11-cu132-aarch64-linux/_ops.py +9 -0
- build/torch212-cxx11-cu132-aarch64-linux/_tinygrad_rms_cuda_1917536.abi3.so +3 -0
- build/torch212-cxx11-cu132-aarch64-linux/metadata.json +21 -0
- build/torch212-cxx11-cu132-aarch64-linux/tinygrad_rms/__init__.py +26 -0
.gitattributes
CHANGED
|
@@ -153,3 +153,12 @@ build/torch211-cxx11-cu130-x86_64-linux/_tinygrad_rms_cuda_1917536.abi3.so filte
|
|
| 153 |
build/torch212-cxx11-cu126-x86_64-linux/_tinygrad_rms_cuda_1917536.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 154 |
build/torch212-cxx11-cu130-x86_64-linux/_tinygrad_rms_cuda_1917536.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 155 |
build/torch212-cxx11-cu132-x86_64-linux/_tinygrad_rms_cuda_1917536.abi3.so filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
build/torch212-cxx11-cu126-x86_64-linux/_tinygrad_rms_cuda_1917536.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 154 |
build/torch212-cxx11-cu130-x86_64-linux/_tinygrad_rms_cuda_1917536.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 155 |
build/torch212-cxx11-cu132-x86_64-linux/_tinygrad_rms_cuda_1917536.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 156 |
+
build/torch210-cxx11-cu126-aarch64-linux/_tinygrad_rms_cuda_1917536.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 157 |
+
build/torch210-cxx11-cu128-aarch64-linux/_tinygrad_rms_cuda_1917536.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 158 |
+
build/torch210-cxx11-cu130-aarch64-linux/_tinygrad_rms_cuda_1917536.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 159 |
+
build/torch211-cxx11-cu126-aarch64-linux/_tinygrad_rms_cuda_1917536.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 160 |
+
build/torch211-cxx11-cu128-aarch64-linux/_tinygrad_rms_cuda_1917536.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 161 |
+
build/torch211-cxx11-cu130-aarch64-linux/_tinygrad_rms_cuda_1917536.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 162 |
+
build/torch212-cxx11-cu126-aarch64-linux/_tinygrad_rms_cuda_1917536.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 163 |
+
build/torch212-cxx11-cu130-aarch64-linux/_tinygrad_rms_cuda_1917536.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 164 |
+
build/torch212-cxx11-cu132-aarch64-linux/_tinygrad_rms_cuda_1917536.abi3.so filter=lfs diff=lfs merge=lfs -text
|
build/torch210-cxx11-cu126-aarch64-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 _tinygrad_rms_cuda_1917536
|
| 3 |
+
ops = torch.ops._tinygrad_rms_cuda_1917536
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_tinygrad_rms_cuda_1917536::{op_name}"
|
build/torch210-cxx11-cu126-aarch64-linux/{_tinygrad_rms_cuda_86f75d9.abi3.so → _tinygrad_rms_cuda_1917536.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2241168
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dd58eeef09d84e1f89625e9672a1e04704427c491ba0cadee0f1cf3bc7997563
|
| 3 |
size 2241168
|
build/torch210-cxx11-cu126-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "tinygrad-rms",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "tinygrad-rms",
|
| 3 |
+
"id": "_tinygrad_rms_cuda_1917536",
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
build/torch210-cxx11-cu128-aarch64-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 _tinygrad_rms_cuda_1917536
|
| 3 |
+
ops = torch.ops._tinygrad_rms_cuda_1917536
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_tinygrad_rms_cuda_1917536::{op_name}"
|
build/torch210-cxx11-cu128-aarch64-linux/{_tinygrad_rms_cuda_86f75d9.abi3.so → _tinygrad_rms_cuda_1917536.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2372360
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ba98bcb8da1711936256ddfd6faa502cc57a2850b9243fc7b3f2f79f2fc52560
|
| 3 |
size 2372360
|
build/torch210-cxx11-cu128-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "tinygrad-rms",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "tinygrad-rms",
|
| 3 |
+
"id": "_tinygrad_rms_cuda_1917536",
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
build/torch210-cxx11-cu130-aarch64-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 _tinygrad_rms_cuda_1917536
|
| 3 |
+
ops = torch.ops._tinygrad_rms_cuda_1917536
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_tinygrad_rms_cuda_1917536::{op_name}"
|
build/torch210-cxx11-cu130-aarch64-linux/{_tinygrad_rms_cuda_86f75d9.abi3.so → _tinygrad_rms_cuda_1917536.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2309232
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f777c857654ce0461994a1e278a26a8689b99312aeb992cfc3cbeb89b46a80ec
|
| 3 |
size 2309232
|
build/torch210-cxx11-cu130-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "tinygrad-rms",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "tinygrad-rms",
|
| 3 |
+
"id": "_tinygrad_rms_cuda_1917536",
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
build/torch211-cxx11-cu126-aarch64-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 _tinygrad_rms_cuda_1917536
|
| 3 |
+
ops = torch.ops._tinygrad_rms_cuda_1917536
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_tinygrad_rms_cuda_1917536::{op_name}"
|
build/torch211-cxx11-cu126-aarch64-linux/{_tinygrad_rms_cuda_86f75d9.abi3.so → _tinygrad_rms_cuda_1917536.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2237384
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b48d91db6f10cdabda9d5b13d8f6cf671a40afa0fc199fc5d9bd590483f4e5aa
|
| 3 |
size 2237384
|
build/torch211-cxx11-cu126-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "tinygrad-rms",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "tinygrad-rms",
|
| 3 |
+
"id": "_tinygrad_rms_cuda_1917536",
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
build/torch211-cxx11-cu128-aarch64-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 _tinygrad_rms_cuda_1917536
|
| 3 |
+
ops = torch.ops._tinygrad_rms_cuda_1917536
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_tinygrad_rms_cuda_1917536::{op_name}"
|
build/torch211-cxx11-cu128-aarch64-linux/{_tinygrad_rms_cuda_86f75d9.abi3.so → _tinygrad_rms_cuda_1917536.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2368568
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:daeb102f08b78565d2dba7a48dcb7f6f3954cbcd819dd27e9d35eb22794494ee
|
| 3 |
size 2368568
|
build/torch211-cxx11-cu128-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "tinygrad-rms",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "tinygrad-rms",
|
| 3 |
+
"id": "_tinygrad_rms_cuda_1917536",
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
build/torch211-cxx11-cu130-aarch64-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 _tinygrad_rms_cuda_1917536
|
| 3 |
+
ops = torch.ops._tinygrad_rms_cuda_1917536
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_tinygrad_rms_cuda_1917536::{op_name}"
|
build/torch211-cxx11-cu130-aarch64-linux/{_tinygrad_rms_cuda_86f75d9.abi3.so → _tinygrad_rms_cuda_1917536.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 2305440
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ffe2d6b8ceba031df62a81a3c49387594caf1d1e22b8fa50760fa205dc583957
|
| 3 |
size 2305440
|
build/torch211-cxx11-cu130-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "tinygrad-rms",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "tinygrad-rms",
|
| 3 |
+
"id": "_tinygrad_rms_cuda_1917536",
|
| 4 |
"version": 1,
|
| 5 |
"license": "MIT",
|
| 6 |
"python-depends": [],
|
build/torch212-cxx11-cu126-aarch64-linux/__init__.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, Tuple
|
| 2 |
+
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
from ._ops import ops
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def tinygrad_rms_norm(
|
| 9 |
+
x: torch.Tensor,
|
| 10 |
+
epsilon: float = 1e-6,
|
| 11 |
+
out: Optional[torch.Tensor] = None,
|
| 12 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 13 |
+
"""
|
| 14 |
+
Compute RMSNorm using tinygrad-style CUDA kernels.
|
| 15 |
+
|
| 16 |
+
RMSNorm(x) = x * (1 / sqrt(mean(x^2) + epsilon))
|
| 17 |
+
|
| 18 |
+
This implementation uses a two-kernel approach:
|
| 19 |
+
1. Compute 1/sqrt(mean(x^2) + epsilon) for each row
|
| 20 |
+
2. Multiply input by the computed factor
|
| 21 |
+
|
| 22 |
+
Args:
|
| 23 |
+
x: Input tensor of shape (..., hidden_size)
|
| 24 |
+
epsilon: Small constant for numerical stability
|
| 25 |
+
out: Optional pre-allocated output tensor
|
| 26 |
+
|
| 27 |
+
Returns:
|
| 28 |
+
Tuple of (output tensor, rms_inv tensor)
|
| 29 |
+
"""
|
| 30 |
+
if out is None:
|
| 31 |
+
out = torch.empty_like(x)
|
| 32 |
+
|
| 33 |
+
hidden_size = x.size(-1)
|
| 34 |
+
num_rows = x.numel() // hidden_size
|
| 35 |
+
rms_inv = torch.empty(num_rows, dtype=x.dtype, device=x.device)
|
| 36 |
+
|
| 37 |
+
ops.tinygrad_rms_norm(out, rms_inv, x, epsilon)
|
| 38 |
+
return out, rms_inv
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def tinygrad_rms_norm_simple(
|
| 42 |
+
x: torch.Tensor,
|
| 43 |
+
epsilon: float = 1e-6,
|
| 44 |
+
out: Optional[torch.Tensor] = None,
|
| 45 |
+
) -> torch.Tensor:
|
| 46 |
+
"""
|
| 47 |
+
Compute RMSNorm using tinygrad-style CUDA kernels.
|
| 48 |
+
|
| 49 |
+
This is a simpler interface that only returns the normalized output.
|
| 50 |
+
|
| 51 |
+
Args:
|
| 52 |
+
x: Input tensor of shape (..., hidden_size)
|
| 53 |
+
epsilon: Small constant for numerical stability
|
| 54 |
+
out: Optional pre-allocated output tensor
|
| 55 |
+
|
| 56 |
+
Returns:
|
| 57 |
+
Normalized output tensor
|
| 58 |
+
"""
|
| 59 |
+
if out is None:
|
| 60 |
+
out = torch.empty_like(x)
|
| 61 |
+
|
| 62 |
+
ops.tinygrad_rms_norm_inplace(out, x, epsilon)
|
| 63 |
+
return out
|
build/torch212-cxx11-cu126-aarch64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _tinygrad_rms_cuda_1917536
|
| 3 |
+
ops = torch.ops._tinygrad_rms_cuda_1917536
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_tinygrad_rms_cuda_1917536::{op_name}"
|
build/torch212-cxx11-cu126-aarch64-linux/_tinygrad_rms_cuda_1917536.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a8f59a3df54046a3fad9b1667e41944f989aaaa39924368c8787d3e3e086643e
|
| 3 |
+
size 2240464
|
build/torch212-cxx11-cu126-aarch64-linux/metadata.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "tinygrad-rms",
|
| 3 |
+
"id": "_tinygrad_rms_cuda_1917536",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "MIT",
|
| 6 |
+
"python-depends": [],
|
| 7 |
+
"backend": {
|
| 8 |
+
"type": "cuda",
|
| 9 |
+
"archs": [
|
| 10 |
+
"7.0",
|
| 11 |
+
"7.2",
|
| 12 |
+
"7.5",
|
| 13 |
+
"8.0",
|
| 14 |
+
"8.6",
|
| 15 |
+
"8.7",
|
| 16 |
+
"8.9",
|
| 17 |
+
"9.0+PTX"
|
| 18 |
+
]
|
| 19 |
+
}
|
| 20 |
+
}
|
build/torch212-cxx11-cu126-aarch64-linux/tinygrad_rms/__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-aarch64-linux/__init__.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, Tuple
|
| 2 |
+
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
from ._ops import ops
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def tinygrad_rms_norm(
|
| 9 |
+
x: torch.Tensor,
|
| 10 |
+
epsilon: float = 1e-6,
|
| 11 |
+
out: Optional[torch.Tensor] = None,
|
| 12 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 13 |
+
"""
|
| 14 |
+
Compute RMSNorm using tinygrad-style CUDA kernels.
|
| 15 |
+
|
| 16 |
+
RMSNorm(x) = x * (1 / sqrt(mean(x^2) + epsilon))
|
| 17 |
+
|
| 18 |
+
This implementation uses a two-kernel approach:
|
| 19 |
+
1. Compute 1/sqrt(mean(x^2) + epsilon) for each row
|
| 20 |
+
2. Multiply input by the computed factor
|
| 21 |
+
|
| 22 |
+
Args:
|
| 23 |
+
x: Input tensor of shape (..., hidden_size)
|
| 24 |
+
epsilon: Small constant for numerical stability
|
| 25 |
+
out: Optional pre-allocated output tensor
|
| 26 |
+
|
| 27 |
+
Returns:
|
| 28 |
+
Tuple of (output tensor, rms_inv tensor)
|
| 29 |
+
"""
|
| 30 |
+
if out is None:
|
| 31 |
+
out = torch.empty_like(x)
|
| 32 |
+
|
| 33 |
+
hidden_size = x.size(-1)
|
| 34 |
+
num_rows = x.numel() // hidden_size
|
| 35 |
+
rms_inv = torch.empty(num_rows, dtype=x.dtype, device=x.device)
|
| 36 |
+
|
| 37 |
+
ops.tinygrad_rms_norm(out, rms_inv, x, epsilon)
|
| 38 |
+
return out, rms_inv
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def tinygrad_rms_norm_simple(
|
| 42 |
+
x: torch.Tensor,
|
| 43 |
+
epsilon: float = 1e-6,
|
| 44 |
+
out: Optional[torch.Tensor] = None,
|
| 45 |
+
) -> torch.Tensor:
|
| 46 |
+
"""
|
| 47 |
+
Compute RMSNorm using tinygrad-style CUDA kernels.
|
| 48 |
+
|
| 49 |
+
This is a simpler interface that only returns the normalized output.
|
| 50 |
+
|
| 51 |
+
Args:
|
| 52 |
+
x: Input tensor of shape (..., hidden_size)
|
| 53 |
+
epsilon: Small constant for numerical stability
|
| 54 |
+
out: Optional pre-allocated output tensor
|
| 55 |
+
|
| 56 |
+
Returns:
|
| 57 |
+
Normalized output tensor
|
| 58 |
+
"""
|
| 59 |
+
if out is None:
|
| 60 |
+
out = torch.empty_like(x)
|
| 61 |
+
|
| 62 |
+
ops.tinygrad_rms_norm_inplace(out, x, epsilon)
|
| 63 |
+
return out
|
build/torch212-cxx11-cu130-aarch64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _tinygrad_rms_cuda_1917536
|
| 3 |
+
ops = torch.ops._tinygrad_rms_cuda_1917536
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_tinygrad_rms_cuda_1917536::{op_name}"
|
build/torch212-cxx11-cu130-aarch64-linux/_tinygrad_rms_cuda_1917536.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:472028577a8a503e030bda19ec467097167c8460cd6faf9e90d813da66ddee62
|
| 3 |
+
size 2308496
|
build/torch212-cxx11-cu130-aarch64-linux/metadata.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "tinygrad-rms",
|
| 3 |
+
"id": "_tinygrad_rms_cuda_1917536",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "MIT",
|
| 6 |
+
"python-depends": [],
|
| 7 |
+
"backend": {
|
| 8 |
+
"type": "cuda",
|
| 9 |
+
"archs": [
|
| 10 |
+
"10.0",
|
| 11 |
+
"11.0",
|
| 12 |
+
"12.0+PTX",
|
| 13 |
+
"7.5",
|
| 14 |
+
"8.0",
|
| 15 |
+
"8.6",
|
| 16 |
+
"8.7",
|
| 17 |
+
"8.9",
|
| 18 |
+
"9.0"
|
| 19 |
+
]
|
| 20 |
+
}
|
| 21 |
+
}
|
build/torch212-cxx11-cu130-aarch64-linux/tinygrad_rms/__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-aarch64-linux/__init__.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional, Tuple
|
| 2 |
+
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
from ._ops import ops
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def tinygrad_rms_norm(
|
| 9 |
+
x: torch.Tensor,
|
| 10 |
+
epsilon: float = 1e-6,
|
| 11 |
+
out: Optional[torch.Tensor] = None,
|
| 12 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 13 |
+
"""
|
| 14 |
+
Compute RMSNorm using tinygrad-style CUDA kernels.
|
| 15 |
+
|
| 16 |
+
RMSNorm(x) = x * (1 / sqrt(mean(x^2) + epsilon))
|
| 17 |
+
|
| 18 |
+
This implementation uses a two-kernel approach:
|
| 19 |
+
1. Compute 1/sqrt(mean(x^2) + epsilon) for each row
|
| 20 |
+
2. Multiply input by the computed factor
|
| 21 |
+
|
| 22 |
+
Args:
|
| 23 |
+
x: Input tensor of shape (..., hidden_size)
|
| 24 |
+
epsilon: Small constant for numerical stability
|
| 25 |
+
out: Optional pre-allocated output tensor
|
| 26 |
+
|
| 27 |
+
Returns:
|
| 28 |
+
Tuple of (output tensor, rms_inv tensor)
|
| 29 |
+
"""
|
| 30 |
+
if out is None:
|
| 31 |
+
out = torch.empty_like(x)
|
| 32 |
+
|
| 33 |
+
hidden_size = x.size(-1)
|
| 34 |
+
num_rows = x.numel() // hidden_size
|
| 35 |
+
rms_inv = torch.empty(num_rows, dtype=x.dtype, device=x.device)
|
| 36 |
+
|
| 37 |
+
ops.tinygrad_rms_norm(out, rms_inv, x, epsilon)
|
| 38 |
+
return out, rms_inv
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def tinygrad_rms_norm_simple(
|
| 42 |
+
x: torch.Tensor,
|
| 43 |
+
epsilon: float = 1e-6,
|
| 44 |
+
out: Optional[torch.Tensor] = None,
|
| 45 |
+
) -> torch.Tensor:
|
| 46 |
+
"""
|
| 47 |
+
Compute RMSNorm using tinygrad-style CUDA kernels.
|
| 48 |
+
|
| 49 |
+
This is a simpler interface that only returns the normalized output.
|
| 50 |
+
|
| 51 |
+
Args:
|
| 52 |
+
x: Input tensor of shape (..., hidden_size)
|
| 53 |
+
epsilon: Small constant for numerical stability
|
| 54 |
+
out: Optional pre-allocated output tensor
|
| 55 |
+
|
| 56 |
+
Returns:
|
| 57 |
+
Normalized output tensor
|
| 58 |
+
"""
|
| 59 |
+
if out is None:
|
| 60 |
+
out = torch.empty_like(x)
|
| 61 |
+
|
| 62 |
+
ops.tinygrad_rms_norm_inplace(out, x, epsilon)
|
| 63 |
+
return out
|
build/torch212-cxx11-cu132-aarch64-linux/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _tinygrad_rms_cuda_1917536
|
| 3 |
+
ops = torch.ops._tinygrad_rms_cuda_1917536
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_tinygrad_rms_cuda_1917536::{op_name}"
|
build/torch212-cxx11-cu132-aarch64-linux/_tinygrad_rms_cuda_1917536.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c05d85f7ed88f1f1295872091abba69837f302c288a82fc1835af4f01ae009ea
|
| 3 |
+
size 2376632
|
build/torch212-cxx11-cu132-aarch64-linux/metadata.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "tinygrad-rms",
|
| 3 |
+
"id": "_tinygrad_rms_cuda_1917536",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "MIT",
|
| 6 |
+
"python-depends": [],
|
| 7 |
+
"backend": {
|
| 8 |
+
"type": "cuda",
|
| 9 |
+
"archs": [
|
| 10 |
+
"10.0",
|
| 11 |
+
"11.0",
|
| 12 |
+
"12.0+PTX",
|
| 13 |
+
"7.5",
|
| 14 |
+
"8.0",
|
| 15 |
+
"8.6",
|
| 16 |
+
"8.7",
|
| 17 |
+
"8.9",
|
| 18 |
+
"9.0"
|
| 19 |
+
]
|
| 20 |
+
}
|
| 21 |
+
}
|
build/torch212-cxx11-cu132-aarch64-linux/tinygrad_rms/__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")))
|