Add torch213-cxx11-cu130-aarch64-linux artifact
Browse files- build/torch213-cxx11-cu130-aarch64-linux/__init__.py +115 -0
- build/torch213-cxx11-cu130-aarch64-linux/_ops.py +6 -0
- build/torch213-cxx11-cu130-aarch64-linux/flashrt_adaptive_norms/__init__.py +14 -0
- build/torch213-cxx11-cu130-aarch64-linux/flashrt_adaptive_norms_test.abi3.so +3 -0
- build/torch213-cxx11-cu130-aarch64-linux/metadata.json +32 -0
build/torch213-cxx11-cu130-aarch64-linux/__init__.py
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FlashRT adaptive norm kernels."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import torch
|
| 6 |
+
|
| 7 |
+
from ._ops import add_op_namespace_prefix, ops
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def _check_adaptive_shapes(
|
| 11 |
+
x: torch.Tensor,
|
| 12 |
+
weight: torch.Tensor,
|
| 13 |
+
style: torch.Tensor,
|
| 14 |
+
out: torch.Tensor,
|
| 15 |
+
gate_out: torch.Tensor,
|
| 16 |
+
) -> None:
|
| 17 |
+
if x.dim() != 2:
|
| 18 |
+
raise RuntimeError("x must have shape (rows, dim)")
|
| 19 |
+
rows, dim = x.shape
|
| 20 |
+
if dim % 2 != 0:
|
| 21 |
+
raise RuntimeError("x.shape[1] must be even")
|
| 22 |
+
if weight.shape != (dim,):
|
| 23 |
+
raise RuntimeError("weight must have shape (dim,)")
|
| 24 |
+
if style.shape != (rows, 3 * dim):
|
| 25 |
+
raise RuntimeError("style must have shape (rows, 3 * dim)")
|
| 26 |
+
if out.shape != x.shape or gate_out.shape != x.shape:
|
| 27 |
+
raise RuntimeError("out and gate_out must have the same shape as x")
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
@torch.library.register_fake(add_op_namespace_prefix("ada_rms_norm_style_bf16"))
|
| 31 |
+
def _ada_rms_norm_style_bf16_fake(
|
| 32 |
+
x: torch.Tensor,
|
| 33 |
+
weight: torch.Tensor,
|
| 34 |
+
style: torch.Tensor,
|
| 35 |
+
eps: float,
|
| 36 |
+
out: torch.Tensor,
|
| 37 |
+
gate_out: torch.Tensor,
|
| 38 |
+
) -> None:
|
| 39 |
+
_check_adaptive_shapes(x, weight, style, out, gate_out)
|
| 40 |
+
return None
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
@torch.library.register_fake(add_op_namespace_prefix("gate_residual_ada_norm_fp8_static_bf16"))
|
| 44 |
+
def _gate_residual_ada_norm_fp8_static_bf16_fake(
|
| 45 |
+
residual: torch.Tensor,
|
| 46 |
+
x: torch.Tensor,
|
| 47 |
+
gate: torch.Tensor,
|
| 48 |
+
weight: torch.Tensor,
|
| 49 |
+
style: torch.Tensor,
|
| 50 |
+
scale: torch.Tensor,
|
| 51 |
+
eps: float,
|
| 52 |
+
out: torch.Tensor,
|
| 53 |
+
gate_out: torch.Tensor,
|
| 54 |
+
) -> None:
|
| 55 |
+
_check_adaptive_shapes(residual, weight, style, out, gate_out)
|
| 56 |
+
if x.shape != residual.shape or gate.shape != residual.shape:
|
| 57 |
+
raise RuntimeError("x and gate must have the same shape as residual")
|
| 58 |
+
if scale.numel() != 1:
|
| 59 |
+
raise RuntimeError("scale must be a scalar tensor")
|
| 60 |
+
return None
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def ada_rms_norm_style_bf16(
|
| 64 |
+
x: torch.Tensor,
|
| 65 |
+
weight: torch.Tensor,
|
| 66 |
+
style: torch.Tensor,
|
| 67 |
+
eps: float = 1e-6,
|
| 68 |
+
out: torch.Tensor | None = None,
|
| 69 |
+
gate_out: torch.Tensor | None = None,
|
| 70 |
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
| 71 |
+
"""Apply RMSNorm, style scale/shift, and return the style gate."""
|
| 72 |
+
|
| 73 |
+
if out is None:
|
| 74 |
+
out = torch.empty_like(x)
|
| 75 |
+
if gate_out is None:
|
| 76 |
+
gate_out = torch.empty_like(x)
|
| 77 |
+
ops.ada_rms_norm_style_bf16(x, weight, style, float(eps), out, gate_out)
|
| 78 |
+
return out, gate_out
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def gate_residual_ada_norm_fp8_static_bf16(
|
| 82 |
+
residual: torch.Tensor,
|
| 83 |
+
x: torch.Tensor,
|
| 84 |
+
gate: torch.Tensor,
|
| 85 |
+
weight: torch.Tensor,
|
| 86 |
+
style: torch.Tensor,
|
| 87 |
+
scale: torch.Tensor,
|
| 88 |
+
eps: float = 1e-6,
|
| 89 |
+
out: torch.Tensor | None = None,
|
| 90 |
+
gate_out: torch.Tensor | None = None,
|
| 91 |
+
) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
| 92 |
+
"""Update residual in place, apply AdaRMSNorm, and emit static-scale FP8."""
|
| 93 |
+
|
| 94 |
+
if out is None:
|
| 95 |
+
out = torch.empty_like(residual, dtype=torch.float8_e4m3fn)
|
| 96 |
+
if gate_out is None:
|
| 97 |
+
gate_out = torch.empty_like(residual)
|
| 98 |
+
ops.gate_residual_ada_norm_fp8_static_bf16(
|
| 99 |
+
residual,
|
| 100 |
+
x,
|
| 101 |
+
gate,
|
| 102 |
+
weight,
|
| 103 |
+
style,
|
| 104 |
+
scale,
|
| 105 |
+
float(eps),
|
| 106 |
+
out,
|
| 107 |
+
gate_out,
|
| 108 |
+
)
|
| 109 |
+
return residual, out, gate_out
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
__all__ = [
|
| 113 |
+
"ada_rms_norm_style_bf16",
|
| 114 |
+
"gate_residual_ada_norm_fp8_static_bf16",
|
| 115 |
+
]
|
build/torch213-cxx11-cu130-aarch64-linux/_ops.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import flashrt_adaptive_norms_test
|
| 3 |
+
ops = torch.ops.flashrt_adaptive_norms_test
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
return f"flashrt_adaptive_norms_test::{op_name}"
|
build/torch213-cxx11-cu130-aarch64-linux/flashrt_adaptive_norms/__init__.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import ctypes
|
| 2 |
+
import importlib.util
|
| 3 |
+
import sys
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
+
def _import_from_path(file_path: Path):
|
| 7 |
+
path_hash = '{:x}'.format(ctypes.c_size_t(hash(file_path.absolute())).value)
|
| 8 |
+
spec = importlib.util.spec_from_file_location(path_hash, file_path)
|
| 9 |
+
module = importlib.util.module_from_spec(spec)
|
| 10 |
+
sys.modules[path_hash] = module
|
| 11 |
+
spec.loader.exec_module(module)
|
| 12 |
+
return module
|
| 13 |
+
|
| 14 |
+
globals().update(vars(_import_from_path(Path(__file__).parent.parent / '__init__.py')))
|
build/torch213-cxx11-cu130-aarch64-linux/flashrt_adaptive_norms_test.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:de09a9bab79d28c6a9dd109c47c8e5792aa773c5d069455bd8fc808afb4c30cb
|
| 3 |
+
size 240872
|
build/torch213-cxx11-cu130-aarch64-linux/metadata.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "flashrt-adaptive-norms",
|
| 3 |
+
"id": "flashrt_adaptive_norms_test",
|
| 4 |
+
"version": 1,
|
| 5 |
+
"license": "Apache-2.0",
|
| 6 |
+
"python-depends": [],
|
| 7 |
+
"backend": {
|
| 8 |
+
"type": "cuda",
|
| 9 |
+
"archs": [
|
| 10 |
+
"11.0"
|
| 11 |
+
]
|
| 12 |
+
},
|
| 13 |
+
"digest": {
|
| 14 |
+
"algorithm": "sha256",
|
| 15 |
+
"files": {
|
| 16 |
+
"__init__.py": "kv6yHmnnIUpOpDGE4dHU9J32michTE3ygV62h/+D+RI=",
|
| 17 |
+
"flashrt_adaptive_norms_test.abi3.so": "3gmpuredKMap3RCcR8jleSqnc8XQaUVb2PyAivtMMMs=",
|
| 18 |
+
"_ops.py": "JOw3+PHqZUGoT770CFlNJojgiXwMOTvFMrvsxZXy7Xc=",
|
| 19 |
+
"flashrt_adaptive_norms/__init__.py": "v6p5XMfQzddhi1fLSAw4HX9CyS0rQsidvu9VsT01xi4="
|
| 20 |
+
}
|
| 21 |
+
},
|
| 22 |
+
"provenance": {
|
| 23 |
+
"kernel": {
|
| 24 |
+
"sha": "456d297",
|
| 25 |
+
"dirty": false
|
| 26 |
+
},
|
| 27 |
+
"validation": {
|
| 28 |
+
"torch": "2.13.0+cu130",
|
| 29 |
+
"cuda": "13.0"
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
}
|