Kernels:
Trusted publisher
Uploaded using `kernel-builder`.
Browse files- .gitattributes +6 -0
- benchmarks/benchmark.py +82 -0
- build/torch210-cxx11-cu128-aarch64-linux/_ops.py +3 -3
- build/torch210-cxx11-cu128-aarch64-linux/{_sage_attention_cuda_a0cb380.abi3.so → _sage_attention_cuda_7535f60.abi3.so} +1 -1
- build/torch210-cxx11-cu128-aarch64-linux/metadata.json +1 -1
- build/torch210-cxx11-cu128-aarch64-linux/sm100_compile.py +7 -67
- build/torch210-cxx11-cu130-aarch64-linux/_ops.py +3 -3
- build/torch210-cxx11-cu130-aarch64-linux/{_sage_attention_cuda_a0cb380.abi3.so → _sage_attention_cuda_7535f60.abi3.so} +1 -1
- build/torch210-cxx11-cu130-aarch64-linux/metadata.json +1 -1
- build/torch210-cxx11-cu130-aarch64-linux/sm100_compile.py +7 -67
- build/torch211-cxx11-cu128-aarch64-linux/_ops.py +3 -3
- build/torch211-cxx11-cu128-aarch64-linux/{_sage_attention_cuda_a0cb380.abi3.so → _sage_attention_cuda_7535f60.abi3.so} +1 -1
- build/torch211-cxx11-cu128-aarch64-linux/metadata.json +1 -1
- build/torch211-cxx11-cu128-aarch64-linux/sm100_compile.py +7 -67
- build/torch211-cxx11-cu130-aarch64-linux/_ops.py +3 -3
- build/torch211-cxx11-cu130-aarch64-linux/{_sage_attention_cuda_a0cb380.abi3.so → _sage_attention_cuda_7535f60.abi3.so} +1 -1
- build/torch211-cxx11-cu130-aarch64-linux/metadata.json +1 -1
- build/torch211-cxx11-cu130-aarch64-linux/sm100_compile.py +7 -67
- build/torch212-cxx11-cu130-aarch64-linux/_ops.py +3 -3
- build/torch212-cxx11-cu130-aarch64-linux/{_sage_attention_cuda_a0cb380.abi3.so → _sage_attention_cuda_7535f60.abi3.so} +1 -1
- build/torch212-cxx11-cu130-aarch64-linux/metadata.json +1 -1
- build/torch212-cxx11-cu130-aarch64-linux/sm100_compile.py +7 -67
- build/torch212-cxx11-cu132-aarch64-linux/_ops.py +3 -3
- build/torch212-cxx11-cu132-aarch64-linux/{_sage_attention_cuda_a0cb380.abi3.so → _sage_attention_cuda_7535f60.abi3.so} +1 -1
- build/torch212-cxx11-cu132-aarch64-linux/metadata.json +1 -1
- build/torch212-cxx11-cu132-aarch64-linux/sm100_compile.py +7 -67
.gitattributes
CHANGED
|
@@ -145,3 +145,9 @@ build/torch211-cxx11-cu128-aarch64-linux/_sage_attention_cuda_a0cb380.abi3.so fi
|
|
| 145 |
build/torch211-cxx11-cu130-aarch64-linux/_sage_attention_cuda_a0cb380.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 146 |
build/torch212-cxx11-cu130-aarch64-linux/_sage_attention_cuda_a0cb380.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 147 |
build/torch212-cxx11-cu132-aarch64-linux/_sage_attention_cuda_a0cb380.abi3.so filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
build/torch211-cxx11-cu130-aarch64-linux/_sage_attention_cuda_a0cb380.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 146 |
build/torch212-cxx11-cu130-aarch64-linux/_sage_attention_cuda_a0cb380.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 147 |
build/torch212-cxx11-cu132-aarch64-linux/_sage_attention_cuda_a0cb380.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 148 |
+
build/torch210-cxx11-cu128-aarch64-linux/_sage_attention_cuda_7535f60.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 149 |
+
build/torch210-cxx11-cu130-aarch64-linux/_sage_attention_cuda_7535f60.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 150 |
+
build/torch211-cxx11-cu128-aarch64-linux/_sage_attention_cuda_7535f60.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 151 |
+
build/torch211-cxx11-cu130-aarch64-linux/_sage_attention_cuda_7535f60.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 152 |
+
build/torch212-cxx11-cu130-aarch64-linux/_sage_attention_cuda_7535f60.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 153 |
+
build/torch212-cxx11-cu132-aarch64-linux/_sage_attention_cuda_7535f60.abi3.so filter=lfs diff=lfs merge=lfs -text
|
benchmarks/benchmark.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import torch.nn.functional as F
|
| 3 |
+
|
| 4 |
+
from kernels.benchmark import Benchmark
|
| 5 |
+
|
| 6 |
+
# SageAttention is approximate (INT8 quantized QK) so element-wise allclose
|
| 7 |
+
# is too strict. Use cosine similarity instead (threshold 0.99).
|
| 8 |
+
_orig_allclose = torch.allclose
|
| 9 |
+
torch.allclose = lambda a, b, **_kw: (
|
| 10 |
+
F.cosine_similarity(a.flatten().float().unsqueeze(0),
|
| 11 |
+
b.flatten().float().unsqueeze(0)).item() > 0.99
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def _ref(q, k, v, is_causal=False):
|
| 16 |
+
return F.scaled_dot_product_attention(q, k, v, is_causal=is_causal)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class SageAttentionBenchmark(Benchmark):
|
| 20 |
+
seed: int = 42
|
| 21 |
+
|
| 22 |
+
# --- base: B=2, H=32, L=1024, D=128 ---
|
| 23 |
+
|
| 24 |
+
def setup_base(self):
|
| 25 |
+
B, H, L, D = 2, 32, 1024, 128
|
| 26 |
+
self.q = torch.randn(B, H, L, D, dtype=torch.bfloat16, device=self.device)
|
| 27 |
+
self.k = torch.randn(B, H, L, D, dtype=torch.bfloat16, device=self.device)
|
| 28 |
+
self.v = torch.randn(B, H, L, D, dtype=torch.bfloat16, device=self.device)
|
| 29 |
+
self.out = torch.empty_like(self.q)
|
| 30 |
+
|
| 31 |
+
def benchmark_base(self):
|
| 32 |
+
self.out = self.kernel.sageattn(self.q, self.k, self.v, tensor_layout="HND")
|
| 33 |
+
|
| 34 |
+
def verify_base(self) -> torch.Tensor:
|
| 35 |
+
return _ref(self.q, self.k, self.v)
|
| 36 |
+
|
| 37 |
+
# --- causal: B=2, H=32, L=1024, D=128 with causal mask ---
|
| 38 |
+
|
| 39 |
+
def setup_causal(self):
|
| 40 |
+
B, H, L, D = 2, 32, 1024, 128
|
| 41 |
+
self.q = torch.randn(B, H, L, D, dtype=torch.bfloat16, device=self.device)
|
| 42 |
+
self.k = torch.randn(B, H, L, D, dtype=torch.bfloat16, device=self.device)
|
| 43 |
+
self.v = torch.randn(B, H, L, D, dtype=torch.bfloat16, device=self.device)
|
| 44 |
+
self.out = torch.empty_like(self.q)
|
| 45 |
+
|
| 46 |
+
def benchmark_causal(self):
|
| 47 |
+
self.out = self.kernel.sageattn(
|
| 48 |
+
self.q, self.k, self.v, tensor_layout="HND", is_causal=True
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
def verify_causal(self) -> torch.Tensor:
|
| 52 |
+
return _ref(self.q, self.k, self.v, is_causal=True)
|
| 53 |
+
|
| 54 |
+
# --- large: B=4, H=32, L=4096, D=128 ---
|
| 55 |
+
|
| 56 |
+
def setup_large(self):
|
| 57 |
+
B, H, L, D = 4, 32, 4096, 128
|
| 58 |
+
self.q = torch.randn(B, H, L, D, dtype=torch.bfloat16, device=self.device)
|
| 59 |
+
self.k = torch.randn(B, H, L, D, dtype=torch.bfloat16, device=self.device)
|
| 60 |
+
self.v = torch.randn(B, H, L, D, dtype=torch.bfloat16, device=self.device)
|
| 61 |
+
self.out = torch.empty_like(self.q)
|
| 62 |
+
|
| 63 |
+
def benchmark_large(self):
|
| 64 |
+
self.out = self.kernel.sageattn(self.q, self.k, self.v, tensor_layout="HND")
|
| 65 |
+
|
| 66 |
+
def verify_large(self) -> torch.Tensor:
|
| 67 |
+
return _ref(self.q, self.k, self.v)
|
| 68 |
+
|
| 69 |
+
# --- d64: B=4, H=32, L=2048, D=64 (smaller head dim) ---
|
| 70 |
+
|
| 71 |
+
def setup_d64(self):
|
| 72 |
+
B, H, L, D = 4, 32, 2048, 64
|
| 73 |
+
self.q = torch.randn(B, H, L, D, dtype=torch.bfloat16, device=self.device)
|
| 74 |
+
self.k = torch.randn(B, H, L, D, dtype=torch.bfloat16, device=self.device)
|
| 75 |
+
self.v = torch.randn(B, H, L, D, dtype=torch.bfloat16, device=self.device)
|
| 76 |
+
self.out = torch.empty_like(self.q)
|
| 77 |
+
|
| 78 |
+
def benchmark_d64(self):
|
| 79 |
+
self.out = self.kernel.sageattn(self.q, self.k, self.v, tensor_layout="HND")
|
| 80 |
+
|
| 81 |
+
def verify_d64(self) -> torch.Tensor:
|
| 82 |
+
return _ref(self.q, self.k, self.v)
|
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 _sage_attention_cuda_7535f60
|
| 3 |
+
ops = torch.ops._sage_attention_cuda_7535f60
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_sage_attention_cuda_7535f60::{op_name}"
|
build/torch210-cxx11-cu128-aarch64-linux/{_sage_attention_cuda_a0cb380.abi3.so → _sage_attention_cuda_7535f60.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 33330136
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:256efe8e854ed0d7e4e200b7ba56adf26b8361997eb461635cad981708ef694e
|
| 3 |
size 33330136
|
build/torch210-cxx11-cu128-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "sage-attention",
|
| 3 |
-
"id": "
|
| 4 |
"version": 2,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "sage-attention",
|
| 3 |
+
"id": "_sage_attention_cuda_7535f60",
|
| 4 |
"version": 2,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
build/torch210-cxx11-cu128-aarch64-linux/sm100_compile.py
CHANGED
|
@@ -28,31 +28,6 @@ from torch.nn.functional import scaled_dot_product_attention as sdpa
|
|
| 28 |
# Low-level ops with torch.compile support (custom_op + register_fake)
|
| 29 |
# ---------------------------------------------------------------------------
|
| 30 |
|
| 31 |
-
@torch.library.custom_op(
|
| 32 |
-
add_op_namespace_prefix("mha_fwd"), mutates_args=(), device_types="cuda"
|
| 33 |
-
)
|
| 34 |
-
def mha_fwd(
|
| 35 |
-
q: torch.Tensor,
|
| 36 |
-
k: torch.Tensor,
|
| 37 |
-
v: torch.Tensor,
|
| 38 |
-
sfq: torch.Tensor,
|
| 39 |
-
sfk: torch.Tensor,
|
| 40 |
-
sfv: torch.Tensor,
|
| 41 |
-
delta_s: torch.Tensor,
|
| 42 |
-
unpadded_k: int,
|
| 43 |
-
out: Optional[torch.Tensor],
|
| 44 |
-
softmax_scale: float,
|
| 45 |
-
is_causal: bool,
|
| 46 |
-
per_block_mean: bool,
|
| 47 |
-
is_bf16: bool,
|
| 48 |
-
) -> List[torch.Tensor]:
|
| 49 |
-
return ops.mha_fwd(
|
| 50 |
-
q, k, v, sfq, sfk, sfv, delta_s,
|
| 51 |
-
unpadded_k, out, softmax_scale, is_causal,
|
| 52 |
-
per_block_mean, is_bf16,
|
| 53 |
-
)
|
| 54 |
-
|
| 55 |
-
|
| 56 |
@torch.library.register_fake(add_op_namespace_prefix("mha_fwd"))
|
| 57 |
def mha_fwd_fake(
|
| 58 |
q: torch.Tensor,
|
|
@@ -86,20 +61,6 @@ def mha_fwd_fake(
|
|
| 86 |
return [fake_out, fake_lse]
|
| 87 |
|
| 88 |
|
| 89 |
-
@torch.library.custom_op(
|
| 90 |
-
add_op_namespace_prefix("scaled_fp4_quant"),
|
| 91 |
-
mutates_args=("output", "output_sf"),
|
| 92 |
-
device_types="cuda",
|
| 93 |
-
)
|
| 94 |
-
def scaled_fp4_quant(
|
| 95 |
-
input: torch.Tensor,
|
| 96 |
-
output: torch.Tensor,
|
| 97 |
-
output_sf: torch.Tensor,
|
| 98 |
-
tensor_layout: int,
|
| 99 |
-
) -> None:
|
| 100 |
-
ops.scaled_fp4_quant(input, output, output_sf, tensor_layout)
|
| 101 |
-
|
| 102 |
-
|
| 103 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant"))
|
| 104 |
def scaled_fp4_quant_fake(
|
| 105 |
input: torch.Tensor,
|
|
@@ -110,20 +71,6 @@ def scaled_fp4_quant_fake(
|
|
| 110 |
pass
|
| 111 |
|
| 112 |
|
| 113 |
-
@torch.library.custom_op(
|
| 114 |
-
add_op_namespace_prefix("scaled_fp4_quant_permute"),
|
| 115 |
-
mutates_args=("output", "output_sf"),
|
| 116 |
-
device_types="cuda",
|
| 117 |
-
)
|
| 118 |
-
def scaled_fp4_quant_permute(
|
| 119 |
-
input: torch.Tensor,
|
| 120 |
-
output: torch.Tensor,
|
| 121 |
-
output_sf: torch.Tensor,
|
| 122 |
-
tensor_layout: int,
|
| 123 |
-
) -> None:
|
| 124 |
-
ops.scaled_fp4_quant_permute(input, output, output_sf, tensor_layout)
|
| 125 |
-
|
| 126 |
-
|
| 127 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_permute"))
|
| 128 |
def scaled_fp4_quant_permute_fake(
|
| 129 |
input: torch.Tensor,
|
|
@@ -134,20 +81,6 @@ def scaled_fp4_quant_permute_fake(
|
|
| 134 |
pass
|
| 135 |
|
| 136 |
|
| 137 |
-
@torch.library.custom_op(
|
| 138 |
-
add_op_namespace_prefix("scaled_fp4_quant_trans"),
|
| 139 |
-
mutates_args=("output", "output_sf"),
|
| 140 |
-
device_types="cuda",
|
| 141 |
-
)
|
| 142 |
-
def scaled_fp4_quant_trans(
|
| 143 |
-
input: torch.Tensor,
|
| 144 |
-
output: torch.Tensor,
|
| 145 |
-
output_sf: torch.Tensor,
|
| 146 |
-
tensor_layout: int,
|
| 147 |
-
) -> None:
|
| 148 |
-
ops.scaled_fp4_quant_trans(input, output, output_sf, tensor_layout)
|
| 149 |
-
|
| 150 |
-
|
| 151 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_trans"))
|
| 152 |
def scaled_fp4_quant_trans_fake(
|
| 153 |
input: torch.Tensor,
|
|
@@ -158,6 +91,13 @@ def scaled_fp4_quant_trans_fake(
|
|
| 158 |
pass
|
| 159 |
|
| 160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
# ---------------------------------------------------------------------------
|
| 162 |
# Triton kernel for grouped mean subtraction
|
| 163 |
# ---------------------------------------------------------------------------
|
|
|
|
| 28 |
# Low-level ops with torch.compile support (custom_op + register_fake)
|
| 29 |
# ---------------------------------------------------------------------------
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
@torch.library.register_fake(add_op_namespace_prefix("mha_fwd"))
|
| 32 |
def mha_fwd_fake(
|
| 33 |
q: torch.Tensor,
|
|
|
|
| 61 |
return [fake_out, fake_lse]
|
| 62 |
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant"))
|
| 65 |
def scaled_fp4_quant_fake(
|
| 66 |
input: torch.Tensor,
|
|
|
|
| 71 |
pass
|
| 72 |
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_permute"))
|
| 75 |
def scaled_fp4_quant_permute_fake(
|
| 76 |
input: torch.Tensor,
|
|
|
|
| 81 |
pass
|
| 82 |
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_trans"))
|
| 85 |
def scaled_fp4_quant_trans_fake(
|
| 86 |
input: torch.Tensor,
|
|
|
|
| 91 |
pass
|
| 92 |
|
| 93 |
|
| 94 |
+
# Direct references to C++ ops (same pattern as sm89_compile.py)
|
| 95 |
+
mha_fwd = ops.mha_fwd
|
| 96 |
+
scaled_fp4_quant = ops.scaled_fp4_quant
|
| 97 |
+
scaled_fp4_quant_permute = ops.scaled_fp4_quant_permute
|
| 98 |
+
scaled_fp4_quant_trans = ops.scaled_fp4_quant_trans
|
| 99 |
+
|
| 100 |
+
|
| 101 |
# ---------------------------------------------------------------------------
|
| 102 |
# Triton kernel for grouped mean subtraction
|
| 103 |
# ---------------------------------------------------------------------------
|
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 _sage_attention_cuda_7535f60
|
| 3 |
+
ops = torch.ops._sage_attention_cuda_7535f60
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_sage_attention_cuda_7535f60::{op_name}"
|
build/torch210-cxx11-cu130-aarch64-linux/{_sage_attention_cuda_a0cb380.abi3.so → _sage_attention_cuda_7535f60.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 33810512
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:810539bd3e29dd2892d1b3fe396d7e5ad676cfdf524b884e7f9e1b6483a6369a
|
| 3 |
size 33810512
|
build/torch210-cxx11-cu130-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "sage-attention",
|
| 3 |
-
"id": "
|
| 4 |
"version": 2,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "sage-attention",
|
| 3 |
+
"id": "_sage_attention_cuda_7535f60",
|
| 4 |
"version": 2,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
build/torch210-cxx11-cu130-aarch64-linux/sm100_compile.py
CHANGED
|
@@ -28,31 +28,6 @@ from torch.nn.functional import scaled_dot_product_attention as sdpa
|
|
| 28 |
# Low-level ops with torch.compile support (custom_op + register_fake)
|
| 29 |
# ---------------------------------------------------------------------------
|
| 30 |
|
| 31 |
-
@torch.library.custom_op(
|
| 32 |
-
add_op_namespace_prefix("mha_fwd"), mutates_args=(), device_types="cuda"
|
| 33 |
-
)
|
| 34 |
-
def mha_fwd(
|
| 35 |
-
q: torch.Tensor,
|
| 36 |
-
k: torch.Tensor,
|
| 37 |
-
v: torch.Tensor,
|
| 38 |
-
sfq: torch.Tensor,
|
| 39 |
-
sfk: torch.Tensor,
|
| 40 |
-
sfv: torch.Tensor,
|
| 41 |
-
delta_s: torch.Tensor,
|
| 42 |
-
unpadded_k: int,
|
| 43 |
-
out: Optional[torch.Tensor],
|
| 44 |
-
softmax_scale: float,
|
| 45 |
-
is_causal: bool,
|
| 46 |
-
per_block_mean: bool,
|
| 47 |
-
is_bf16: bool,
|
| 48 |
-
) -> List[torch.Tensor]:
|
| 49 |
-
return ops.mha_fwd(
|
| 50 |
-
q, k, v, sfq, sfk, sfv, delta_s,
|
| 51 |
-
unpadded_k, out, softmax_scale, is_causal,
|
| 52 |
-
per_block_mean, is_bf16,
|
| 53 |
-
)
|
| 54 |
-
|
| 55 |
-
|
| 56 |
@torch.library.register_fake(add_op_namespace_prefix("mha_fwd"))
|
| 57 |
def mha_fwd_fake(
|
| 58 |
q: torch.Tensor,
|
|
@@ -86,20 +61,6 @@ def mha_fwd_fake(
|
|
| 86 |
return [fake_out, fake_lse]
|
| 87 |
|
| 88 |
|
| 89 |
-
@torch.library.custom_op(
|
| 90 |
-
add_op_namespace_prefix("scaled_fp4_quant"),
|
| 91 |
-
mutates_args=("output", "output_sf"),
|
| 92 |
-
device_types="cuda",
|
| 93 |
-
)
|
| 94 |
-
def scaled_fp4_quant(
|
| 95 |
-
input: torch.Tensor,
|
| 96 |
-
output: torch.Tensor,
|
| 97 |
-
output_sf: torch.Tensor,
|
| 98 |
-
tensor_layout: int,
|
| 99 |
-
) -> None:
|
| 100 |
-
ops.scaled_fp4_quant(input, output, output_sf, tensor_layout)
|
| 101 |
-
|
| 102 |
-
|
| 103 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant"))
|
| 104 |
def scaled_fp4_quant_fake(
|
| 105 |
input: torch.Tensor,
|
|
@@ -110,20 +71,6 @@ def scaled_fp4_quant_fake(
|
|
| 110 |
pass
|
| 111 |
|
| 112 |
|
| 113 |
-
@torch.library.custom_op(
|
| 114 |
-
add_op_namespace_prefix("scaled_fp4_quant_permute"),
|
| 115 |
-
mutates_args=("output", "output_sf"),
|
| 116 |
-
device_types="cuda",
|
| 117 |
-
)
|
| 118 |
-
def scaled_fp4_quant_permute(
|
| 119 |
-
input: torch.Tensor,
|
| 120 |
-
output: torch.Tensor,
|
| 121 |
-
output_sf: torch.Tensor,
|
| 122 |
-
tensor_layout: int,
|
| 123 |
-
) -> None:
|
| 124 |
-
ops.scaled_fp4_quant_permute(input, output, output_sf, tensor_layout)
|
| 125 |
-
|
| 126 |
-
|
| 127 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_permute"))
|
| 128 |
def scaled_fp4_quant_permute_fake(
|
| 129 |
input: torch.Tensor,
|
|
@@ -134,20 +81,6 @@ def scaled_fp4_quant_permute_fake(
|
|
| 134 |
pass
|
| 135 |
|
| 136 |
|
| 137 |
-
@torch.library.custom_op(
|
| 138 |
-
add_op_namespace_prefix("scaled_fp4_quant_trans"),
|
| 139 |
-
mutates_args=("output", "output_sf"),
|
| 140 |
-
device_types="cuda",
|
| 141 |
-
)
|
| 142 |
-
def scaled_fp4_quant_trans(
|
| 143 |
-
input: torch.Tensor,
|
| 144 |
-
output: torch.Tensor,
|
| 145 |
-
output_sf: torch.Tensor,
|
| 146 |
-
tensor_layout: int,
|
| 147 |
-
) -> None:
|
| 148 |
-
ops.scaled_fp4_quant_trans(input, output, output_sf, tensor_layout)
|
| 149 |
-
|
| 150 |
-
|
| 151 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_trans"))
|
| 152 |
def scaled_fp4_quant_trans_fake(
|
| 153 |
input: torch.Tensor,
|
|
@@ -158,6 +91,13 @@ def scaled_fp4_quant_trans_fake(
|
|
| 158 |
pass
|
| 159 |
|
| 160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
# ---------------------------------------------------------------------------
|
| 162 |
# Triton kernel for grouped mean subtraction
|
| 163 |
# ---------------------------------------------------------------------------
|
|
|
|
| 28 |
# Low-level ops with torch.compile support (custom_op + register_fake)
|
| 29 |
# ---------------------------------------------------------------------------
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
@torch.library.register_fake(add_op_namespace_prefix("mha_fwd"))
|
| 32 |
def mha_fwd_fake(
|
| 33 |
q: torch.Tensor,
|
|
|
|
| 61 |
return [fake_out, fake_lse]
|
| 62 |
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant"))
|
| 65 |
def scaled_fp4_quant_fake(
|
| 66 |
input: torch.Tensor,
|
|
|
|
| 71 |
pass
|
| 72 |
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_permute"))
|
| 75 |
def scaled_fp4_quant_permute_fake(
|
| 76 |
input: torch.Tensor,
|
|
|
|
| 81 |
pass
|
| 82 |
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_trans"))
|
| 85 |
def scaled_fp4_quant_trans_fake(
|
| 86 |
input: torch.Tensor,
|
|
|
|
| 91 |
pass
|
| 92 |
|
| 93 |
|
| 94 |
+
# Direct references to C++ ops (same pattern as sm89_compile.py)
|
| 95 |
+
mha_fwd = ops.mha_fwd
|
| 96 |
+
scaled_fp4_quant = ops.scaled_fp4_quant
|
| 97 |
+
scaled_fp4_quant_permute = ops.scaled_fp4_quant_permute
|
| 98 |
+
scaled_fp4_quant_trans = ops.scaled_fp4_quant_trans
|
| 99 |
+
|
| 100 |
+
|
| 101 |
# ---------------------------------------------------------------------------
|
| 102 |
# Triton kernel for grouped mean subtraction
|
| 103 |
# ---------------------------------------------------------------------------
|
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 _sage_attention_cuda_7535f60
|
| 3 |
+
ops = torch.ops._sage_attention_cuda_7535f60
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_sage_attention_cuda_7535f60::{op_name}"
|
build/torch211-cxx11-cu128-aarch64-linux/{_sage_attention_cuda_a0cb380.abi3.so → _sage_attention_cuda_7535f60.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 33326264
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:10c680f7b61513fc2eea02bdb61b9838776215d61c7fb50a732c3d493c10e695
|
| 3 |
size 33326264
|
build/torch211-cxx11-cu128-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "sage-attention",
|
| 3 |
-
"id": "
|
| 4 |
"version": 2,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "sage-attention",
|
| 3 |
+
"id": "_sage_attention_cuda_7535f60",
|
| 4 |
"version": 2,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
build/torch211-cxx11-cu128-aarch64-linux/sm100_compile.py
CHANGED
|
@@ -28,31 +28,6 @@ from torch.nn.functional import scaled_dot_product_attention as sdpa
|
|
| 28 |
# Low-level ops with torch.compile support (custom_op + register_fake)
|
| 29 |
# ---------------------------------------------------------------------------
|
| 30 |
|
| 31 |
-
@torch.library.custom_op(
|
| 32 |
-
add_op_namespace_prefix("mha_fwd"), mutates_args=(), device_types="cuda"
|
| 33 |
-
)
|
| 34 |
-
def mha_fwd(
|
| 35 |
-
q: torch.Tensor,
|
| 36 |
-
k: torch.Tensor,
|
| 37 |
-
v: torch.Tensor,
|
| 38 |
-
sfq: torch.Tensor,
|
| 39 |
-
sfk: torch.Tensor,
|
| 40 |
-
sfv: torch.Tensor,
|
| 41 |
-
delta_s: torch.Tensor,
|
| 42 |
-
unpadded_k: int,
|
| 43 |
-
out: Optional[torch.Tensor],
|
| 44 |
-
softmax_scale: float,
|
| 45 |
-
is_causal: bool,
|
| 46 |
-
per_block_mean: bool,
|
| 47 |
-
is_bf16: bool,
|
| 48 |
-
) -> List[torch.Tensor]:
|
| 49 |
-
return ops.mha_fwd(
|
| 50 |
-
q, k, v, sfq, sfk, sfv, delta_s,
|
| 51 |
-
unpadded_k, out, softmax_scale, is_causal,
|
| 52 |
-
per_block_mean, is_bf16,
|
| 53 |
-
)
|
| 54 |
-
|
| 55 |
-
|
| 56 |
@torch.library.register_fake(add_op_namespace_prefix("mha_fwd"))
|
| 57 |
def mha_fwd_fake(
|
| 58 |
q: torch.Tensor,
|
|
@@ -86,20 +61,6 @@ def mha_fwd_fake(
|
|
| 86 |
return [fake_out, fake_lse]
|
| 87 |
|
| 88 |
|
| 89 |
-
@torch.library.custom_op(
|
| 90 |
-
add_op_namespace_prefix("scaled_fp4_quant"),
|
| 91 |
-
mutates_args=("output", "output_sf"),
|
| 92 |
-
device_types="cuda",
|
| 93 |
-
)
|
| 94 |
-
def scaled_fp4_quant(
|
| 95 |
-
input: torch.Tensor,
|
| 96 |
-
output: torch.Tensor,
|
| 97 |
-
output_sf: torch.Tensor,
|
| 98 |
-
tensor_layout: int,
|
| 99 |
-
) -> None:
|
| 100 |
-
ops.scaled_fp4_quant(input, output, output_sf, tensor_layout)
|
| 101 |
-
|
| 102 |
-
|
| 103 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant"))
|
| 104 |
def scaled_fp4_quant_fake(
|
| 105 |
input: torch.Tensor,
|
|
@@ -110,20 +71,6 @@ def scaled_fp4_quant_fake(
|
|
| 110 |
pass
|
| 111 |
|
| 112 |
|
| 113 |
-
@torch.library.custom_op(
|
| 114 |
-
add_op_namespace_prefix("scaled_fp4_quant_permute"),
|
| 115 |
-
mutates_args=("output", "output_sf"),
|
| 116 |
-
device_types="cuda",
|
| 117 |
-
)
|
| 118 |
-
def scaled_fp4_quant_permute(
|
| 119 |
-
input: torch.Tensor,
|
| 120 |
-
output: torch.Tensor,
|
| 121 |
-
output_sf: torch.Tensor,
|
| 122 |
-
tensor_layout: int,
|
| 123 |
-
) -> None:
|
| 124 |
-
ops.scaled_fp4_quant_permute(input, output, output_sf, tensor_layout)
|
| 125 |
-
|
| 126 |
-
|
| 127 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_permute"))
|
| 128 |
def scaled_fp4_quant_permute_fake(
|
| 129 |
input: torch.Tensor,
|
|
@@ -134,20 +81,6 @@ def scaled_fp4_quant_permute_fake(
|
|
| 134 |
pass
|
| 135 |
|
| 136 |
|
| 137 |
-
@torch.library.custom_op(
|
| 138 |
-
add_op_namespace_prefix("scaled_fp4_quant_trans"),
|
| 139 |
-
mutates_args=("output", "output_sf"),
|
| 140 |
-
device_types="cuda",
|
| 141 |
-
)
|
| 142 |
-
def scaled_fp4_quant_trans(
|
| 143 |
-
input: torch.Tensor,
|
| 144 |
-
output: torch.Tensor,
|
| 145 |
-
output_sf: torch.Tensor,
|
| 146 |
-
tensor_layout: int,
|
| 147 |
-
) -> None:
|
| 148 |
-
ops.scaled_fp4_quant_trans(input, output, output_sf, tensor_layout)
|
| 149 |
-
|
| 150 |
-
|
| 151 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_trans"))
|
| 152 |
def scaled_fp4_quant_trans_fake(
|
| 153 |
input: torch.Tensor,
|
|
@@ -158,6 +91,13 @@ def scaled_fp4_quant_trans_fake(
|
|
| 158 |
pass
|
| 159 |
|
| 160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
# ---------------------------------------------------------------------------
|
| 162 |
# Triton kernel for grouped mean subtraction
|
| 163 |
# ---------------------------------------------------------------------------
|
|
|
|
| 28 |
# Low-level ops with torch.compile support (custom_op + register_fake)
|
| 29 |
# ---------------------------------------------------------------------------
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
@torch.library.register_fake(add_op_namespace_prefix("mha_fwd"))
|
| 32 |
def mha_fwd_fake(
|
| 33 |
q: torch.Tensor,
|
|
|
|
| 61 |
return [fake_out, fake_lse]
|
| 62 |
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant"))
|
| 65 |
def scaled_fp4_quant_fake(
|
| 66 |
input: torch.Tensor,
|
|
|
|
| 71 |
pass
|
| 72 |
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_permute"))
|
| 75 |
def scaled_fp4_quant_permute_fake(
|
| 76 |
input: torch.Tensor,
|
|
|
|
| 81 |
pass
|
| 82 |
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_trans"))
|
| 85 |
def scaled_fp4_quant_trans_fake(
|
| 86 |
input: torch.Tensor,
|
|
|
|
| 91 |
pass
|
| 92 |
|
| 93 |
|
| 94 |
+
# Direct references to C++ ops (same pattern as sm89_compile.py)
|
| 95 |
+
mha_fwd = ops.mha_fwd
|
| 96 |
+
scaled_fp4_quant = ops.scaled_fp4_quant
|
| 97 |
+
scaled_fp4_quant_permute = ops.scaled_fp4_quant_permute
|
| 98 |
+
scaled_fp4_quant_trans = ops.scaled_fp4_quant_trans
|
| 99 |
+
|
| 100 |
+
|
| 101 |
# ---------------------------------------------------------------------------
|
| 102 |
# Triton kernel for grouped mean subtraction
|
| 103 |
# ---------------------------------------------------------------------------
|
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 _sage_attention_cuda_7535f60
|
| 3 |
+
ops = torch.ops._sage_attention_cuda_7535f60
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_sage_attention_cuda_7535f60::{op_name}"
|
build/torch211-cxx11-cu130-aarch64-linux/{_sage_attention_cuda_a0cb380.abi3.so → _sage_attention_cuda_7535f60.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 33806648
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:51ec2a4ca4bb8f8002a971338920422bd21471a2bca43f63712a427c50b21cd2
|
| 3 |
size 33806648
|
build/torch211-cxx11-cu130-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "sage-attention",
|
| 3 |
-
"id": "
|
| 4 |
"version": 2,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "sage-attention",
|
| 3 |
+
"id": "_sage_attention_cuda_7535f60",
|
| 4 |
"version": 2,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
build/torch211-cxx11-cu130-aarch64-linux/sm100_compile.py
CHANGED
|
@@ -28,31 +28,6 @@ from torch.nn.functional import scaled_dot_product_attention as sdpa
|
|
| 28 |
# Low-level ops with torch.compile support (custom_op + register_fake)
|
| 29 |
# ---------------------------------------------------------------------------
|
| 30 |
|
| 31 |
-
@torch.library.custom_op(
|
| 32 |
-
add_op_namespace_prefix("mha_fwd"), mutates_args=(), device_types="cuda"
|
| 33 |
-
)
|
| 34 |
-
def mha_fwd(
|
| 35 |
-
q: torch.Tensor,
|
| 36 |
-
k: torch.Tensor,
|
| 37 |
-
v: torch.Tensor,
|
| 38 |
-
sfq: torch.Tensor,
|
| 39 |
-
sfk: torch.Tensor,
|
| 40 |
-
sfv: torch.Tensor,
|
| 41 |
-
delta_s: torch.Tensor,
|
| 42 |
-
unpadded_k: int,
|
| 43 |
-
out: Optional[torch.Tensor],
|
| 44 |
-
softmax_scale: float,
|
| 45 |
-
is_causal: bool,
|
| 46 |
-
per_block_mean: bool,
|
| 47 |
-
is_bf16: bool,
|
| 48 |
-
) -> List[torch.Tensor]:
|
| 49 |
-
return ops.mha_fwd(
|
| 50 |
-
q, k, v, sfq, sfk, sfv, delta_s,
|
| 51 |
-
unpadded_k, out, softmax_scale, is_causal,
|
| 52 |
-
per_block_mean, is_bf16,
|
| 53 |
-
)
|
| 54 |
-
|
| 55 |
-
|
| 56 |
@torch.library.register_fake(add_op_namespace_prefix("mha_fwd"))
|
| 57 |
def mha_fwd_fake(
|
| 58 |
q: torch.Tensor,
|
|
@@ -86,20 +61,6 @@ def mha_fwd_fake(
|
|
| 86 |
return [fake_out, fake_lse]
|
| 87 |
|
| 88 |
|
| 89 |
-
@torch.library.custom_op(
|
| 90 |
-
add_op_namespace_prefix("scaled_fp4_quant"),
|
| 91 |
-
mutates_args=("output", "output_sf"),
|
| 92 |
-
device_types="cuda",
|
| 93 |
-
)
|
| 94 |
-
def scaled_fp4_quant(
|
| 95 |
-
input: torch.Tensor,
|
| 96 |
-
output: torch.Tensor,
|
| 97 |
-
output_sf: torch.Tensor,
|
| 98 |
-
tensor_layout: int,
|
| 99 |
-
) -> None:
|
| 100 |
-
ops.scaled_fp4_quant(input, output, output_sf, tensor_layout)
|
| 101 |
-
|
| 102 |
-
|
| 103 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant"))
|
| 104 |
def scaled_fp4_quant_fake(
|
| 105 |
input: torch.Tensor,
|
|
@@ -110,20 +71,6 @@ def scaled_fp4_quant_fake(
|
|
| 110 |
pass
|
| 111 |
|
| 112 |
|
| 113 |
-
@torch.library.custom_op(
|
| 114 |
-
add_op_namespace_prefix("scaled_fp4_quant_permute"),
|
| 115 |
-
mutates_args=("output", "output_sf"),
|
| 116 |
-
device_types="cuda",
|
| 117 |
-
)
|
| 118 |
-
def scaled_fp4_quant_permute(
|
| 119 |
-
input: torch.Tensor,
|
| 120 |
-
output: torch.Tensor,
|
| 121 |
-
output_sf: torch.Tensor,
|
| 122 |
-
tensor_layout: int,
|
| 123 |
-
) -> None:
|
| 124 |
-
ops.scaled_fp4_quant_permute(input, output, output_sf, tensor_layout)
|
| 125 |
-
|
| 126 |
-
|
| 127 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_permute"))
|
| 128 |
def scaled_fp4_quant_permute_fake(
|
| 129 |
input: torch.Tensor,
|
|
@@ -134,20 +81,6 @@ def scaled_fp4_quant_permute_fake(
|
|
| 134 |
pass
|
| 135 |
|
| 136 |
|
| 137 |
-
@torch.library.custom_op(
|
| 138 |
-
add_op_namespace_prefix("scaled_fp4_quant_trans"),
|
| 139 |
-
mutates_args=("output", "output_sf"),
|
| 140 |
-
device_types="cuda",
|
| 141 |
-
)
|
| 142 |
-
def scaled_fp4_quant_trans(
|
| 143 |
-
input: torch.Tensor,
|
| 144 |
-
output: torch.Tensor,
|
| 145 |
-
output_sf: torch.Tensor,
|
| 146 |
-
tensor_layout: int,
|
| 147 |
-
) -> None:
|
| 148 |
-
ops.scaled_fp4_quant_trans(input, output, output_sf, tensor_layout)
|
| 149 |
-
|
| 150 |
-
|
| 151 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_trans"))
|
| 152 |
def scaled_fp4_quant_trans_fake(
|
| 153 |
input: torch.Tensor,
|
|
@@ -158,6 +91,13 @@ def scaled_fp4_quant_trans_fake(
|
|
| 158 |
pass
|
| 159 |
|
| 160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
# ---------------------------------------------------------------------------
|
| 162 |
# Triton kernel for grouped mean subtraction
|
| 163 |
# ---------------------------------------------------------------------------
|
|
|
|
| 28 |
# Low-level ops with torch.compile support (custom_op + register_fake)
|
| 29 |
# ---------------------------------------------------------------------------
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
@torch.library.register_fake(add_op_namespace_prefix("mha_fwd"))
|
| 32 |
def mha_fwd_fake(
|
| 33 |
q: torch.Tensor,
|
|
|
|
| 61 |
return [fake_out, fake_lse]
|
| 62 |
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant"))
|
| 65 |
def scaled_fp4_quant_fake(
|
| 66 |
input: torch.Tensor,
|
|
|
|
| 71 |
pass
|
| 72 |
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_permute"))
|
| 75 |
def scaled_fp4_quant_permute_fake(
|
| 76 |
input: torch.Tensor,
|
|
|
|
| 81 |
pass
|
| 82 |
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_trans"))
|
| 85 |
def scaled_fp4_quant_trans_fake(
|
| 86 |
input: torch.Tensor,
|
|
|
|
| 91 |
pass
|
| 92 |
|
| 93 |
|
| 94 |
+
# Direct references to C++ ops (same pattern as sm89_compile.py)
|
| 95 |
+
mha_fwd = ops.mha_fwd
|
| 96 |
+
scaled_fp4_quant = ops.scaled_fp4_quant
|
| 97 |
+
scaled_fp4_quant_permute = ops.scaled_fp4_quant_permute
|
| 98 |
+
scaled_fp4_quant_trans = ops.scaled_fp4_quant_trans
|
| 99 |
+
|
| 100 |
+
|
| 101 |
# ---------------------------------------------------------------------------
|
| 102 |
# Triton kernel for grouped mean subtraction
|
| 103 |
# ---------------------------------------------------------------------------
|
build/torch212-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 _sage_attention_cuda_7535f60
|
| 3 |
+
ops = torch.ops._sage_attention_cuda_7535f60
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_sage_attention_cuda_7535f60::{op_name}"
|
build/torch212-cxx11-cu130-aarch64-linux/{_sage_attention_cuda_a0cb380.abi3.so → _sage_attention_cuda_7535f60.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 33810192
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3d4a3a414a1677470451d1dde012fbc31666990c8cb6701843f9b1bccd0a05d4
|
| 3 |
size 33810192
|
build/torch212-cxx11-cu130-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "sage-attention",
|
| 3 |
-
"id": "
|
| 4 |
"version": 2,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "sage-attention",
|
| 3 |
+
"id": "_sage_attention_cuda_7535f60",
|
| 4 |
"version": 2,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
build/torch212-cxx11-cu130-aarch64-linux/sm100_compile.py
CHANGED
|
@@ -28,31 +28,6 @@ from torch.nn.functional import scaled_dot_product_attention as sdpa
|
|
| 28 |
# Low-level ops with torch.compile support (custom_op + register_fake)
|
| 29 |
# ---------------------------------------------------------------------------
|
| 30 |
|
| 31 |
-
@torch.library.custom_op(
|
| 32 |
-
add_op_namespace_prefix("mha_fwd"), mutates_args=(), device_types="cuda"
|
| 33 |
-
)
|
| 34 |
-
def mha_fwd(
|
| 35 |
-
q: torch.Tensor,
|
| 36 |
-
k: torch.Tensor,
|
| 37 |
-
v: torch.Tensor,
|
| 38 |
-
sfq: torch.Tensor,
|
| 39 |
-
sfk: torch.Tensor,
|
| 40 |
-
sfv: torch.Tensor,
|
| 41 |
-
delta_s: torch.Tensor,
|
| 42 |
-
unpadded_k: int,
|
| 43 |
-
out: Optional[torch.Tensor],
|
| 44 |
-
softmax_scale: float,
|
| 45 |
-
is_causal: bool,
|
| 46 |
-
per_block_mean: bool,
|
| 47 |
-
is_bf16: bool,
|
| 48 |
-
) -> List[torch.Tensor]:
|
| 49 |
-
return ops.mha_fwd(
|
| 50 |
-
q, k, v, sfq, sfk, sfv, delta_s,
|
| 51 |
-
unpadded_k, out, softmax_scale, is_causal,
|
| 52 |
-
per_block_mean, is_bf16,
|
| 53 |
-
)
|
| 54 |
-
|
| 55 |
-
|
| 56 |
@torch.library.register_fake(add_op_namespace_prefix("mha_fwd"))
|
| 57 |
def mha_fwd_fake(
|
| 58 |
q: torch.Tensor,
|
|
@@ -86,20 +61,6 @@ def mha_fwd_fake(
|
|
| 86 |
return [fake_out, fake_lse]
|
| 87 |
|
| 88 |
|
| 89 |
-
@torch.library.custom_op(
|
| 90 |
-
add_op_namespace_prefix("scaled_fp4_quant"),
|
| 91 |
-
mutates_args=("output", "output_sf"),
|
| 92 |
-
device_types="cuda",
|
| 93 |
-
)
|
| 94 |
-
def scaled_fp4_quant(
|
| 95 |
-
input: torch.Tensor,
|
| 96 |
-
output: torch.Tensor,
|
| 97 |
-
output_sf: torch.Tensor,
|
| 98 |
-
tensor_layout: int,
|
| 99 |
-
) -> None:
|
| 100 |
-
ops.scaled_fp4_quant(input, output, output_sf, tensor_layout)
|
| 101 |
-
|
| 102 |
-
|
| 103 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant"))
|
| 104 |
def scaled_fp4_quant_fake(
|
| 105 |
input: torch.Tensor,
|
|
@@ -110,20 +71,6 @@ def scaled_fp4_quant_fake(
|
|
| 110 |
pass
|
| 111 |
|
| 112 |
|
| 113 |
-
@torch.library.custom_op(
|
| 114 |
-
add_op_namespace_prefix("scaled_fp4_quant_permute"),
|
| 115 |
-
mutates_args=("output", "output_sf"),
|
| 116 |
-
device_types="cuda",
|
| 117 |
-
)
|
| 118 |
-
def scaled_fp4_quant_permute(
|
| 119 |
-
input: torch.Tensor,
|
| 120 |
-
output: torch.Tensor,
|
| 121 |
-
output_sf: torch.Tensor,
|
| 122 |
-
tensor_layout: int,
|
| 123 |
-
) -> None:
|
| 124 |
-
ops.scaled_fp4_quant_permute(input, output, output_sf, tensor_layout)
|
| 125 |
-
|
| 126 |
-
|
| 127 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_permute"))
|
| 128 |
def scaled_fp4_quant_permute_fake(
|
| 129 |
input: torch.Tensor,
|
|
@@ -134,20 +81,6 @@ def scaled_fp4_quant_permute_fake(
|
|
| 134 |
pass
|
| 135 |
|
| 136 |
|
| 137 |
-
@torch.library.custom_op(
|
| 138 |
-
add_op_namespace_prefix("scaled_fp4_quant_trans"),
|
| 139 |
-
mutates_args=("output", "output_sf"),
|
| 140 |
-
device_types="cuda",
|
| 141 |
-
)
|
| 142 |
-
def scaled_fp4_quant_trans(
|
| 143 |
-
input: torch.Tensor,
|
| 144 |
-
output: torch.Tensor,
|
| 145 |
-
output_sf: torch.Tensor,
|
| 146 |
-
tensor_layout: int,
|
| 147 |
-
) -> None:
|
| 148 |
-
ops.scaled_fp4_quant_trans(input, output, output_sf, tensor_layout)
|
| 149 |
-
|
| 150 |
-
|
| 151 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_trans"))
|
| 152 |
def scaled_fp4_quant_trans_fake(
|
| 153 |
input: torch.Tensor,
|
|
@@ -158,6 +91,13 @@ def scaled_fp4_quant_trans_fake(
|
|
| 158 |
pass
|
| 159 |
|
| 160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
# ---------------------------------------------------------------------------
|
| 162 |
# Triton kernel for grouped mean subtraction
|
| 163 |
# ---------------------------------------------------------------------------
|
|
|
|
| 28 |
# Low-level ops with torch.compile support (custom_op + register_fake)
|
| 29 |
# ---------------------------------------------------------------------------
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
@torch.library.register_fake(add_op_namespace_prefix("mha_fwd"))
|
| 32 |
def mha_fwd_fake(
|
| 33 |
q: torch.Tensor,
|
|
|
|
| 61 |
return [fake_out, fake_lse]
|
| 62 |
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant"))
|
| 65 |
def scaled_fp4_quant_fake(
|
| 66 |
input: torch.Tensor,
|
|
|
|
| 71 |
pass
|
| 72 |
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_permute"))
|
| 75 |
def scaled_fp4_quant_permute_fake(
|
| 76 |
input: torch.Tensor,
|
|
|
|
| 81 |
pass
|
| 82 |
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_trans"))
|
| 85 |
def scaled_fp4_quant_trans_fake(
|
| 86 |
input: torch.Tensor,
|
|
|
|
| 91 |
pass
|
| 92 |
|
| 93 |
|
| 94 |
+
# Direct references to C++ ops (same pattern as sm89_compile.py)
|
| 95 |
+
mha_fwd = ops.mha_fwd
|
| 96 |
+
scaled_fp4_quant = ops.scaled_fp4_quant
|
| 97 |
+
scaled_fp4_quant_permute = ops.scaled_fp4_quant_permute
|
| 98 |
+
scaled_fp4_quant_trans = ops.scaled_fp4_quant_trans
|
| 99 |
+
|
| 100 |
+
|
| 101 |
# ---------------------------------------------------------------------------
|
| 102 |
# Triton kernel for grouped mean subtraction
|
| 103 |
# ---------------------------------------------------------------------------
|
build/torch212-cxx11-cu132-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 _sage_attention_cuda_7535f60
|
| 3 |
+
ops = torch.ops._sage_attention_cuda_7535f60
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_sage_attention_cuda_7535f60::{op_name}"
|
build/torch212-cxx11-cu132-aarch64-linux/{_sage_attention_cuda_a0cb380.abi3.so → _sage_attention_cuda_7535f60.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 33753872
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7a34459318d6736e53202e2d7244d1a609d533273ca31f5cf0c3184dcfdf1a05
|
| 3 |
size 33753872
|
build/torch212-cxx11-cu132-aarch64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "sage-attention",
|
| 3 |
-
"id": "
|
| 4 |
"version": 2,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
|
|
| 1 |
{
|
| 2 |
"name": "sage-attention",
|
| 3 |
+
"id": "_sage_attention_cuda_7535f60",
|
| 4 |
"version": 2,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
build/torch212-cxx11-cu132-aarch64-linux/sm100_compile.py
CHANGED
|
@@ -28,31 +28,6 @@ from torch.nn.functional import scaled_dot_product_attention as sdpa
|
|
| 28 |
# Low-level ops with torch.compile support (custom_op + register_fake)
|
| 29 |
# ---------------------------------------------------------------------------
|
| 30 |
|
| 31 |
-
@torch.library.custom_op(
|
| 32 |
-
add_op_namespace_prefix("mha_fwd"), mutates_args=(), device_types="cuda"
|
| 33 |
-
)
|
| 34 |
-
def mha_fwd(
|
| 35 |
-
q: torch.Tensor,
|
| 36 |
-
k: torch.Tensor,
|
| 37 |
-
v: torch.Tensor,
|
| 38 |
-
sfq: torch.Tensor,
|
| 39 |
-
sfk: torch.Tensor,
|
| 40 |
-
sfv: torch.Tensor,
|
| 41 |
-
delta_s: torch.Tensor,
|
| 42 |
-
unpadded_k: int,
|
| 43 |
-
out: Optional[torch.Tensor],
|
| 44 |
-
softmax_scale: float,
|
| 45 |
-
is_causal: bool,
|
| 46 |
-
per_block_mean: bool,
|
| 47 |
-
is_bf16: bool,
|
| 48 |
-
) -> List[torch.Tensor]:
|
| 49 |
-
return ops.mha_fwd(
|
| 50 |
-
q, k, v, sfq, sfk, sfv, delta_s,
|
| 51 |
-
unpadded_k, out, softmax_scale, is_causal,
|
| 52 |
-
per_block_mean, is_bf16,
|
| 53 |
-
)
|
| 54 |
-
|
| 55 |
-
|
| 56 |
@torch.library.register_fake(add_op_namespace_prefix("mha_fwd"))
|
| 57 |
def mha_fwd_fake(
|
| 58 |
q: torch.Tensor,
|
|
@@ -86,20 +61,6 @@ def mha_fwd_fake(
|
|
| 86 |
return [fake_out, fake_lse]
|
| 87 |
|
| 88 |
|
| 89 |
-
@torch.library.custom_op(
|
| 90 |
-
add_op_namespace_prefix("scaled_fp4_quant"),
|
| 91 |
-
mutates_args=("output", "output_sf"),
|
| 92 |
-
device_types="cuda",
|
| 93 |
-
)
|
| 94 |
-
def scaled_fp4_quant(
|
| 95 |
-
input: torch.Tensor,
|
| 96 |
-
output: torch.Tensor,
|
| 97 |
-
output_sf: torch.Tensor,
|
| 98 |
-
tensor_layout: int,
|
| 99 |
-
) -> None:
|
| 100 |
-
ops.scaled_fp4_quant(input, output, output_sf, tensor_layout)
|
| 101 |
-
|
| 102 |
-
|
| 103 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant"))
|
| 104 |
def scaled_fp4_quant_fake(
|
| 105 |
input: torch.Tensor,
|
|
@@ -110,20 +71,6 @@ def scaled_fp4_quant_fake(
|
|
| 110 |
pass
|
| 111 |
|
| 112 |
|
| 113 |
-
@torch.library.custom_op(
|
| 114 |
-
add_op_namespace_prefix("scaled_fp4_quant_permute"),
|
| 115 |
-
mutates_args=("output", "output_sf"),
|
| 116 |
-
device_types="cuda",
|
| 117 |
-
)
|
| 118 |
-
def scaled_fp4_quant_permute(
|
| 119 |
-
input: torch.Tensor,
|
| 120 |
-
output: torch.Tensor,
|
| 121 |
-
output_sf: torch.Tensor,
|
| 122 |
-
tensor_layout: int,
|
| 123 |
-
) -> None:
|
| 124 |
-
ops.scaled_fp4_quant_permute(input, output, output_sf, tensor_layout)
|
| 125 |
-
|
| 126 |
-
|
| 127 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_permute"))
|
| 128 |
def scaled_fp4_quant_permute_fake(
|
| 129 |
input: torch.Tensor,
|
|
@@ -134,20 +81,6 @@ def scaled_fp4_quant_permute_fake(
|
|
| 134 |
pass
|
| 135 |
|
| 136 |
|
| 137 |
-
@torch.library.custom_op(
|
| 138 |
-
add_op_namespace_prefix("scaled_fp4_quant_trans"),
|
| 139 |
-
mutates_args=("output", "output_sf"),
|
| 140 |
-
device_types="cuda",
|
| 141 |
-
)
|
| 142 |
-
def scaled_fp4_quant_trans(
|
| 143 |
-
input: torch.Tensor,
|
| 144 |
-
output: torch.Tensor,
|
| 145 |
-
output_sf: torch.Tensor,
|
| 146 |
-
tensor_layout: int,
|
| 147 |
-
) -> None:
|
| 148 |
-
ops.scaled_fp4_quant_trans(input, output, output_sf, tensor_layout)
|
| 149 |
-
|
| 150 |
-
|
| 151 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_trans"))
|
| 152 |
def scaled_fp4_quant_trans_fake(
|
| 153 |
input: torch.Tensor,
|
|
@@ -158,6 +91,13 @@ def scaled_fp4_quant_trans_fake(
|
|
| 158 |
pass
|
| 159 |
|
| 160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
# ---------------------------------------------------------------------------
|
| 162 |
# Triton kernel for grouped mean subtraction
|
| 163 |
# ---------------------------------------------------------------------------
|
|
|
|
| 28 |
# Low-level ops with torch.compile support (custom_op + register_fake)
|
| 29 |
# ---------------------------------------------------------------------------
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
@torch.library.register_fake(add_op_namespace_prefix("mha_fwd"))
|
| 32 |
def mha_fwd_fake(
|
| 33 |
q: torch.Tensor,
|
|
|
|
| 61 |
return [fake_out, fake_lse]
|
| 62 |
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant"))
|
| 65 |
def scaled_fp4_quant_fake(
|
| 66 |
input: torch.Tensor,
|
|
|
|
| 71 |
pass
|
| 72 |
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_permute"))
|
| 75 |
def scaled_fp4_quant_permute_fake(
|
| 76 |
input: torch.Tensor,
|
|
|
|
| 81 |
pass
|
| 82 |
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
@torch.library.register_fake(add_op_namespace_prefix("scaled_fp4_quant_trans"))
|
| 85 |
def scaled_fp4_quant_trans_fake(
|
| 86 |
input: torch.Tensor,
|
|
|
|
| 91 |
pass
|
| 92 |
|
| 93 |
|
| 94 |
+
# Direct references to C++ ops (same pattern as sm89_compile.py)
|
| 95 |
+
mha_fwd = ops.mha_fwd
|
| 96 |
+
scaled_fp4_quant = ops.scaled_fp4_quant
|
| 97 |
+
scaled_fp4_quant_permute = ops.scaled_fp4_quant_permute
|
| 98 |
+
scaled_fp4_quant_trans = ops.scaled_fp4_quant_trans
|
| 99 |
+
|
| 100 |
+
|
| 101 |
# ---------------------------------------------------------------------------
|
| 102 |
# Triton kernel for grouped mean subtraction
|
| 103 |
# ---------------------------------------------------------------------------
|