Promote latest kernel artifacts to main
Browse files- README.md +0 -9
- build/torch211-cxx11-cu130-aarch64-linux/__init__.py +158 -0
- build/torch211-cxx11-cu130-aarch64-linux/{_flashrt_fp8_ffn_cuda_255584f.abi3.so → _flashrt_fp8_ffn_cuda_230e467.abi3.so} +2 -2
- build/torch211-cxx11-cu130-aarch64-linux/_ops.py +3 -3
- build/torch211-cxx11-cu130-aarch64-linux/metadata.json +11 -5
- build/torch213-cxx11-cu130-aarch64-linux/__init__.py +158 -0
- build/torch213-cxx11-cu130-aarch64-linux/{flashrt_fp8_ffn_test.abi3.so → _flashrt_fp8_ffn_cuda_230e467.abi3.so} +2 -2
- build/torch213-cxx11-cu130-aarch64-linux/_ops.py +3 -3
- build/torch213-cxx11-cu130-aarch64-linux/metadata.json +6 -10
README.md
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
# flashrt/flashrt-fp8-ffn
|
| 2 |
-
|
| 3 |
-
This repository is a compatibility mirror for older `kernels` clients
|
| 4 |
-
that resolve repositories through the default Hugging Face model repo API.
|
| 5 |
-
|
| 6 |
-
Canonical Kernel Hub repo: https://huggingface.co/kernels/flashrt/flashrt-fp8-ffn
|
| 7 |
-
|
| 8 |
-
Do not edit this mirror by hand. It is generated from the Kernel Hub
|
| 9 |
-
`vN` branches and contains the same `build/**` artifacts.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/torch211-cxx11-cu130-aarch64-linux/__init__.py
CHANGED
|
@@ -145,6 +145,27 @@ def _fp8_gelu_mlp_bf16_fake(
|
|
| 145 |
return None
|
| 146 |
|
| 147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
@torch.library.register_fake(add_op_namespace_prefix("bf16_fp8_gelu_mlp_bf16"))
|
| 149 |
def _bf16_fp8_gelu_mlp_bf16_fake(
|
| 150 |
input: torch.Tensor,
|
|
@@ -173,6 +194,29 @@ def _bf16_fp8_gelu_mlp_bf16_fake(
|
|
| 173 |
return None
|
| 174 |
|
| 175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
def _scalar_scale_like(input: torch.Tensor, value: float = 1.0) -> torch.Tensor:
|
| 177 |
return torch.tensor([value], device=input.device, dtype=torch.float32)
|
| 178 |
|
|
@@ -433,11 +477,125 @@ def bf16_fp8_gelu_mlp_bf16(
|
|
| 433 |
return out[:logical_m]
|
| 434 |
|
| 435 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 436 |
__all__ = [
|
| 437 |
"bf16_fp8_linear_bias_bf16",
|
| 438 |
"bf16_fp8_gelu_mlp_bf16",
|
|
|
|
| 439 |
"fp8_gemm_bf16",
|
| 440 |
"fp8_gelu_mlp_bf16",
|
|
|
|
| 441 |
"fp8_linear_bias_bf16",
|
| 442 |
"fp8_linear_bias_gelu_quant_bf16",
|
| 443 |
]
|
|
|
|
| 145 |
return None
|
| 146 |
|
| 147 |
|
| 148 |
+
@torch.library.register_fake(add_op_namespace_prefix("fp8_gelu_mlp_v2_bf16"))
|
| 149 |
+
def _fp8_gelu_mlp_v2_bf16_fake(
|
| 150 |
+
input: torch.Tensor,
|
| 151 |
+
up_weight: torch.Tensor,
|
| 152 |
+
up_bias: torch.Tensor,
|
| 153 |
+
down_weight: torch.Tensor,
|
| 154 |
+
down_bias: torch.Tensor,
|
| 155 |
+
input_scale: torch.Tensor,
|
| 156 |
+
up_weight_scale: torch.Tensor,
|
| 157 |
+
hidden_scale: torch.Tensor,
|
| 158 |
+
down_weight_scale: torch.Tensor,
|
| 159 |
+
hidden_bf16: torch.Tensor,
|
| 160 |
+
hidden_fp8: torch.Tensor,
|
| 161 |
+
out: torch.Tensor,
|
| 162 |
+
) -> None:
|
| 163 |
+
return _fp8_gelu_mlp_bf16_fake(
|
| 164 |
+
input, up_weight, up_bias, down_weight, down_bias, input_scale,
|
| 165 |
+
up_weight_scale, hidden_scale, down_weight_scale, hidden_bf16,
|
| 166 |
+
hidden_fp8, out)
|
| 167 |
+
|
| 168 |
+
|
| 169 |
@torch.library.register_fake(add_op_namespace_prefix("bf16_fp8_gelu_mlp_bf16"))
|
| 170 |
def _bf16_fp8_gelu_mlp_bf16_fake(
|
| 171 |
input: torch.Tensor,
|
|
|
|
| 194 |
return None
|
| 195 |
|
| 196 |
|
| 197 |
+
@torch.library.register_fake(
|
| 198 |
+
add_op_namespace_prefix("bf16_fp8_gelu_mlp_v2_bf16"))
|
| 199 |
+
def _bf16_fp8_gelu_mlp_v2_bf16_fake(
|
| 200 |
+
input: torch.Tensor,
|
| 201 |
+
up_weight: torch.Tensor,
|
| 202 |
+
up_bias: torch.Tensor,
|
| 203 |
+
down_weight: torch.Tensor,
|
| 204 |
+
down_bias: torch.Tensor,
|
| 205 |
+
input_scale: torch.Tensor,
|
| 206 |
+
up_weight_scale: torch.Tensor,
|
| 207 |
+
hidden_scale: torch.Tensor,
|
| 208 |
+
down_weight_scale: torch.Tensor,
|
| 209 |
+
input_fp8: torch.Tensor,
|
| 210 |
+
hidden_bf16: torch.Tensor,
|
| 211 |
+
hidden_fp8: torch.Tensor,
|
| 212 |
+
out: torch.Tensor,
|
| 213 |
+
) -> None:
|
| 214 |
+
return _bf16_fp8_gelu_mlp_bf16_fake(
|
| 215 |
+
input, up_weight, up_bias, down_weight, down_bias, input_scale,
|
| 216 |
+
up_weight_scale, hidden_scale, down_weight_scale, input_fp8,
|
| 217 |
+
hidden_bf16, hidden_fp8, out)
|
| 218 |
+
|
| 219 |
+
|
| 220 |
def _scalar_scale_like(input: torch.Tensor, value: float = 1.0) -> torch.Tensor:
|
| 221 |
return torch.tensor([value], device=input.device, dtype=torch.float32)
|
| 222 |
|
|
|
|
| 477 |
return out[:logical_m]
|
| 478 |
|
| 479 |
|
| 480 |
+
def fp8_gelu_mlp_v2_bf16(
|
| 481 |
+
input: torch.Tensor,
|
| 482 |
+
up_weight: torch.Tensor,
|
| 483 |
+
up_bias: torch.Tensor,
|
| 484 |
+
down_weight: torch.Tensor,
|
| 485 |
+
down_bias: torch.Tensor,
|
| 486 |
+
input_scale: torch.Tensor,
|
| 487 |
+
up_weight_scale: torch.Tensor,
|
| 488 |
+
hidden_scale: torch.Tensor,
|
| 489 |
+
down_weight_scale: torch.Tensor,
|
| 490 |
+
hidden_bf16: torch.Tensor | None = None,
|
| 491 |
+
hidden_fp8: torch.Tensor | None = None,
|
| 492 |
+
out: torch.Tensor | None = None,
|
| 493 |
+
) -> torch.Tensor:
|
| 494 |
+
"""``fp8_gelu_mlp_bf16`` with the down bias in the GEMM epilogue.
|
| 495 |
+
|
| 496 |
+
Same contract and buffers as the v1 entry; one launch and one full
|
| 497 |
+
write of ``out`` less per call on targets whose cublasLt path
|
| 498 |
+
accepts the BIAS epilogue (elsewhere the runtime falls back to the
|
| 499 |
+
v1 two-launch tail, still correct).
|
| 500 |
+
"""
|
| 501 |
+
|
| 502 |
+
if hidden_bf16 is None:
|
| 503 |
+
hidden_bf16 = torch.empty(
|
| 504 |
+
(input.shape[0], up_weight.shape[0]),
|
| 505 |
+
device=input.device,
|
| 506 |
+
dtype=torch.bfloat16,
|
| 507 |
+
)
|
| 508 |
+
if hidden_fp8 is None:
|
| 509 |
+
hidden_fp8 = torch.empty_like(hidden_bf16, dtype=_fp8_dtype())
|
| 510 |
+
if out is None:
|
| 511 |
+
out = torch.empty(
|
| 512 |
+
(input.shape[0], down_weight.shape[0]),
|
| 513 |
+
device=input.device,
|
| 514 |
+
dtype=torch.bfloat16,
|
| 515 |
+
)
|
| 516 |
+
ops.fp8_gelu_mlp_v2_bf16(
|
| 517 |
+
input,
|
| 518 |
+
up_weight,
|
| 519 |
+
up_bias,
|
| 520 |
+
down_weight,
|
| 521 |
+
down_bias,
|
| 522 |
+
input_scale,
|
| 523 |
+
up_weight_scale,
|
| 524 |
+
hidden_scale,
|
| 525 |
+
down_weight_scale,
|
| 526 |
+
hidden_bf16,
|
| 527 |
+
hidden_fp8,
|
| 528 |
+
out,
|
| 529 |
+
)
|
| 530 |
+
return out
|
| 531 |
+
|
| 532 |
+
|
| 533 |
+
def bf16_fp8_gelu_mlp_v2_bf16(
|
| 534 |
+
input: torch.Tensor,
|
| 535 |
+
up_weight: torch.Tensor,
|
| 536 |
+
up_bias: torch.Tensor,
|
| 537 |
+
down_weight: torch.Tensor,
|
| 538 |
+
down_bias: torch.Tensor,
|
| 539 |
+
input_scale: torch.Tensor,
|
| 540 |
+
up_weight_scale: torch.Tensor,
|
| 541 |
+
hidden_scale: torch.Tensor,
|
| 542 |
+
down_weight_scale: torch.Tensor,
|
| 543 |
+
input_fp8: torch.Tensor | None = None,
|
| 544 |
+
hidden_bf16: torch.Tensor | None = None,
|
| 545 |
+
hidden_fp8: torch.Tensor | None = None,
|
| 546 |
+
out: torch.Tensor | None = None,
|
| 547 |
+
*,
|
| 548 |
+
pad_to: int | None = None,
|
| 549 |
+
) -> torch.Tensor:
|
| 550 |
+
"""``bf16_fp8_gelu_mlp_bf16`` with the down bias in the epilogue.
|
| 551 |
+
|
| 552 |
+
Identical padding and buffer contract to the v1 entry.
|
| 553 |
+
"""
|
| 554 |
+
|
| 555 |
+
logical_m = input.shape[0]
|
| 556 |
+
padded_m = _midm_padded_rows(input) if pad_to is None else pad_to
|
| 557 |
+
if padded_m < logical_m:
|
| 558 |
+
raise ValueError("pad_to must be >= input.shape[0]")
|
| 559 |
+
device = input.device
|
| 560 |
+
if input_fp8 is None:
|
| 561 |
+
input_fp8 = torch.empty(
|
| 562 |
+
(padded_m, input.shape[1]), device=device, dtype=_fp8_dtype()
|
| 563 |
+
)
|
| 564 |
+
if hidden_bf16 is None:
|
| 565 |
+
hidden_bf16 = torch.empty(
|
| 566 |
+
(padded_m, up_weight.shape[0]), device=device, dtype=torch.bfloat16
|
| 567 |
+
)
|
| 568 |
+
if hidden_fp8 is None:
|
| 569 |
+
hidden_fp8 = torch.empty_like(hidden_bf16, dtype=_fp8_dtype())
|
| 570 |
+
if out is None:
|
| 571 |
+
out = torch.empty(
|
| 572 |
+
(padded_m, down_weight.shape[0]), device=device, dtype=torch.bfloat16
|
| 573 |
+
)
|
| 574 |
+
ops.bf16_fp8_gelu_mlp_v2_bf16(
|
| 575 |
+
input,
|
| 576 |
+
up_weight,
|
| 577 |
+
up_bias,
|
| 578 |
+
down_weight,
|
| 579 |
+
down_bias,
|
| 580 |
+
input_scale,
|
| 581 |
+
up_weight_scale,
|
| 582 |
+
hidden_scale,
|
| 583 |
+
down_weight_scale,
|
| 584 |
+
input_fp8,
|
| 585 |
+
hidden_bf16,
|
| 586 |
+
hidden_fp8,
|
| 587 |
+
out,
|
| 588 |
+
)
|
| 589 |
+
return out[:logical_m]
|
| 590 |
+
|
| 591 |
+
|
| 592 |
__all__ = [
|
| 593 |
"bf16_fp8_linear_bias_bf16",
|
| 594 |
"bf16_fp8_gelu_mlp_bf16",
|
| 595 |
+
"bf16_fp8_gelu_mlp_v2_bf16",
|
| 596 |
"fp8_gemm_bf16",
|
| 597 |
"fp8_gelu_mlp_bf16",
|
| 598 |
+
"fp8_gelu_mlp_v2_bf16",
|
| 599 |
"fp8_linear_bias_bf16",
|
| 600 |
"fp8_linear_bias_gelu_quant_bf16",
|
| 601 |
]
|
build/torch211-cxx11-cu130-aarch64-linux/{_flashrt_fp8_ffn_cuda_255584f.abi3.so → _flashrt_fp8_ffn_cuda_230e467.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:36c3c74bc022516143f5c906cfa9a8dbf17cff61569d1ca8474fda55b73ce76c
|
| 3 |
+
size 257080
|
build/torch211-cxx11-cu130-aarch64-linux/_ops.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _flashrt_fp8_ffn_cuda_230e467
|
| 3 |
+
ops = torch.ops._flashrt_fp8_ffn_cuda_230e467
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
return f"_flashrt_fp8_ffn_cuda_230e467::{op_name}"
|
build/torch211-cxx11-cu130-aarch64-linux/metadata.json
CHANGED
|
@@ -1,22 +1,28 @@
|
|
| 1 |
{
|
| 2 |
"name": "flashrt-fp8-ffn",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
| 7 |
"backend": {
|
| 8 |
"type": "cuda",
|
| 9 |
"archs": [
|
| 10 |
-
"11.
|
| 11 |
]
|
| 12 |
},
|
| 13 |
"digest": {
|
| 14 |
"algorithm": "sha256",
|
| 15 |
"files": {
|
| 16 |
-
"__init__.py": "
|
| 17 |
-
"
|
| 18 |
-
"_ops.py": "
|
| 19 |
"flashrt_fp8_ffn/__init__.py": "v6p5XMfQzddhi1fLSAw4HX9CyS0rQsidvu9VsT01xi4="
|
| 20 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
}
|
| 22 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"name": "flashrt-fp8-ffn",
|
| 3 |
+
"id": "_flashrt_fp8_ffn_cuda_230e467",
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
| 7 |
"backend": {
|
| 8 |
"type": "cuda",
|
| 9 |
"archs": [
|
| 10 |
+
"11.0a"
|
| 11 |
]
|
| 12 |
},
|
| 13 |
"digest": {
|
| 14 |
"algorithm": "sha256",
|
| 15 |
"files": {
|
| 16 |
+
"__init__.py": "O5OvnWgzbfzKB83CtQwQy60BSAa83vizBgNuMnx6D6A=",
|
| 17 |
+
"_flashrt_fp8_ffn_cuda_230e467.abi3.so": "NsPHS8AiUWFD9ckGz6mo2/F8/2FWnRyoR0/aVbc852w=",
|
| 18 |
+
"_ops.py": "MmNuiXB4ECVn/fPAOD6Abcdco5Bb4KAyVc26dklNvvc=",
|
| 19 |
"flashrt_fp8_ffn/__init__.py": "v6p5XMfQzddhi1fLSAw4HX9CyS0rQsidvu9VsT01xi4="
|
| 20 |
}
|
| 21 |
+
},
|
| 22 |
+
"provenance": {
|
| 23 |
+
"kernel": {
|
| 24 |
+
"sha": "230e467",
|
| 25 |
+
"dirty": false
|
| 26 |
+
}
|
| 27 |
}
|
| 28 |
}
|
build/torch213-cxx11-cu130-aarch64-linux/__init__.py
CHANGED
|
@@ -145,6 +145,27 @@ def _fp8_gelu_mlp_bf16_fake(
|
|
| 145 |
return None
|
| 146 |
|
| 147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
@torch.library.register_fake(add_op_namespace_prefix("bf16_fp8_gelu_mlp_bf16"))
|
| 149 |
def _bf16_fp8_gelu_mlp_bf16_fake(
|
| 150 |
input: torch.Tensor,
|
|
@@ -173,6 +194,29 @@ def _bf16_fp8_gelu_mlp_bf16_fake(
|
|
| 173 |
return None
|
| 174 |
|
| 175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
def _scalar_scale_like(input: torch.Tensor, value: float = 1.0) -> torch.Tensor:
|
| 177 |
return torch.tensor([value], device=input.device, dtype=torch.float32)
|
| 178 |
|
|
@@ -433,11 +477,125 @@ def bf16_fp8_gelu_mlp_bf16(
|
|
| 433 |
return out[:logical_m]
|
| 434 |
|
| 435 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 436 |
__all__ = [
|
| 437 |
"bf16_fp8_linear_bias_bf16",
|
| 438 |
"bf16_fp8_gelu_mlp_bf16",
|
|
|
|
| 439 |
"fp8_gemm_bf16",
|
| 440 |
"fp8_gelu_mlp_bf16",
|
|
|
|
| 441 |
"fp8_linear_bias_bf16",
|
| 442 |
"fp8_linear_bias_gelu_quant_bf16",
|
| 443 |
]
|
|
|
|
| 145 |
return None
|
| 146 |
|
| 147 |
|
| 148 |
+
@torch.library.register_fake(add_op_namespace_prefix("fp8_gelu_mlp_v2_bf16"))
|
| 149 |
+
def _fp8_gelu_mlp_v2_bf16_fake(
|
| 150 |
+
input: torch.Tensor,
|
| 151 |
+
up_weight: torch.Tensor,
|
| 152 |
+
up_bias: torch.Tensor,
|
| 153 |
+
down_weight: torch.Tensor,
|
| 154 |
+
down_bias: torch.Tensor,
|
| 155 |
+
input_scale: torch.Tensor,
|
| 156 |
+
up_weight_scale: torch.Tensor,
|
| 157 |
+
hidden_scale: torch.Tensor,
|
| 158 |
+
down_weight_scale: torch.Tensor,
|
| 159 |
+
hidden_bf16: torch.Tensor,
|
| 160 |
+
hidden_fp8: torch.Tensor,
|
| 161 |
+
out: torch.Tensor,
|
| 162 |
+
) -> None:
|
| 163 |
+
return _fp8_gelu_mlp_bf16_fake(
|
| 164 |
+
input, up_weight, up_bias, down_weight, down_bias, input_scale,
|
| 165 |
+
up_weight_scale, hidden_scale, down_weight_scale, hidden_bf16,
|
| 166 |
+
hidden_fp8, out)
|
| 167 |
+
|
| 168 |
+
|
| 169 |
@torch.library.register_fake(add_op_namespace_prefix("bf16_fp8_gelu_mlp_bf16"))
|
| 170 |
def _bf16_fp8_gelu_mlp_bf16_fake(
|
| 171 |
input: torch.Tensor,
|
|
|
|
| 194 |
return None
|
| 195 |
|
| 196 |
|
| 197 |
+
@torch.library.register_fake(
|
| 198 |
+
add_op_namespace_prefix("bf16_fp8_gelu_mlp_v2_bf16"))
|
| 199 |
+
def _bf16_fp8_gelu_mlp_v2_bf16_fake(
|
| 200 |
+
input: torch.Tensor,
|
| 201 |
+
up_weight: torch.Tensor,
|
| 202 |
+
up_bias: torch.Tensor,
|
| 203 |
+
down_weight: torch.Tensor,
|
| 204 |
+
down_bias: torch.Tensor,
|
| 205 |
+
input_scale: torch.Tensor,
|
| 206 |
+
up_weight_scale: torch.Tensor,
|
| 207 |
+
hidden_scale: torch.Tensor,
|
| 208 |
+
down_weight_scale: torch.Tensor,
|
| 209 |
+
input_fp8: torch.Tensor,
|
| 210 |
+
hidden_bf16: torch.Tensor,
|
| 211 |
+
hidden_fp8: torch.Tensor,
|
| 212 |
+
out: torch.Tensor,
|
| 213 |
+
) -> None:
|
| 214 |
+
return _bf16_fp8_gelu_mlp_bf16_fake(
|
| 215 |
+
input, up_weight, up_bias, down_weight, down_bias, input_scale,
|
| 216 |
+
up_weight_scale, hidden_scale, down_weight_scale, input_fp8,
|
| 217 |
+
hidden_bf16, hidden_fp8, out)
|
| 218 |
+
|
| 219 |
+
|
| 220 |
def _scalar_scale_like(input: torch.Tensor, value: float = 1.0) -> torch.Tensor:
|
| 221 |
return torch.tensor([value], device=input.device, dtype=torch.float32)
|
| 222 |
|
|
|
|
| 477 |
return out[:logical_m]
|
| 478 |
|
| 479 |
|
| 480 |
+
def fp8_gelu_mlp_v2_bf16(
|
| 481 |
+
input: torch.Tensor,
|
| 482 |
+
up_weight: torch.Tensor,
|
| 483 |
+
up_bias: torch.Tensor,
|
| 484 |
+
down_weight: torch.Tensor,
|
| 485 |
+
down_bias: torch.Tensor,
|
| 486 |
+
input_scale: torch.Tensor,
|
| 487 |
+
up_weight_scale: torch.Tensor,
|
| 488 |
+
hidden_scale: torch.Tensor,
|
| 489 |
+
down_weight_scale: torch.Tensor,
|
| 490 |
+
hidden_bf16: torch.Tensor | None = None,
|
| 491 |
+
hidden_fp8: torch.Tensor | None = None,
|
| 492 |
+
out: torch.Tensor | None = None,
|
| 493 |
+
) -> torch.Tensor:
|
| 494 |
+
"""``fp8_gelu_mlp_bf16`` with the down bias in the GEMM epilogue.
|
| 495 |
+
|
| 496 |
+
Same contract and buffers as the v1 entry; one launch and one full
|
| 497 |
+
write of ``out`` less per call on targets whose cublasLt path
|
| 498 |
+
accepts the BIAS epilogue (elsewhere the runtime falls back to the
|
| 499 |
+
v1 two-launch tail, still correct).
|
| 500 |
+
"""
|
| 501 |
+
|
| 502 |
+
if hidden_bf16 is None:
|
| 503 |
+
hidden_bf16 = torch.empty(
|
| 504 |
+
(input.shape[0], up_weight.shape[0]),
|
| 505 |
+
device=input.device,
|
| 506 |
+
dtype=torch.bfloat16,
|
| 507 |
+
)
|
| 508 |
+
if hidden_fp8 is None:
|
| 509 |
+
hidden_fp8 = torch.empty_like(hidden_bf16, dtype=_fp8_dtype())
|
| 510 |
+
if out is None:
|
| 511 |
+
out = torch.empty(
|
| 512 |
+
(input.shape[0], down_weight.shape[0]),
|
| 513 |
+
device=input.device,
|
| 514 |
+
dtype=torch.bfloat16,
|
| 515 |
+
)
|
| 516 |
+
ops.fp8_gelu_mlp_v2_bf16(
|
| 517 |
+
input,
|
| 518 |
+
up_weight,
|
| 519 |
+
up_bias,
|
| 520 |
+
down_weight,
|
| 521 |
+
down_bias,
|
| 522 |
+
input_scale,
|
| 523 |
+
up_weight_scale,
|
| 524 |
+
hidden_scale,
|
| 525 |
+
down_weight_scale,
|
| 526 |
+
hidden_bf16,
|
| 527 |
+
hidden_fp8,
|
| 528 |
+
out,
|
| 529 |
+
)
|
| 530 |
+
return out
|
| 531 |
+
|
| 532 |
+
|
| 533 |
+
def bf16_fp8_gelu_mlp_v2_bf16(
|
| 534 |
+
input: torch.Tensor,
|
| 535 |
+
up_weight: torch.Tensor,
|
| 536 |
+
up_bias: torch.Tensor,
|
| 537 |
+
down_weight: torch.Tensor,
|
| 538 |
+
down_bias: torch.Tensor,
|
| 539 |
+
input_scale: torch.Tensor,
|
| 540 |
+
up_weight_scale: torch.Tensor,
|
| 541 |
+
hidden_scale: torch.Tensor,
|
| 542 |
+
down_weight_scale: torch.Tensor,
|
| 543 |
+
input_fp8: torch.Tensor | None = None,
|
| 544 |
+
hidden_bf16: torch.Tensor | None = None,
|
| 545 |
+
hidden_fp8: torch.Tensor | None = None,
|
| 546 |
+
out: torch.Tensor | None = None,
|
| 547 |
+
*,
|
| 548 |
+
pad_to: int | None = None,
|
| 549 |
+
) -> torch.Tensor:
|
| 550 |
+
"""``bf16_fp8_gelu_mlp_bf16`` with the down bias in the epilogue.
|
| 551 |
+
|
| 552 |
+
Identical padding and buffer contract to the v1 entry.
|
| 553 |
+
"""
|
| 554 |
+
|
| 555 |
+
logical_m = input.shape[0]
|
| 556 |
+
padded_m = _midm_padded_rows(input) if pad_to is None else pad_to
|
| 557 |
+
if padded_m < logical_m:
|
| 558 |
+
raise ValueError("pad_to must be >= input.shape[0]")
|
| 559 |
+
device = input.device
|
| 560 |
+
if input_fp8 is None:
|
| 561 |
+
input_fp8 = torch.empty(
|
| 562 |
+
(padded_m, input.shape[1]), device=device, dtype=_fp8_dtype()
|
| 563 |
+
)
|
| 564 |
+
if hidden_bf16 is None:
|
| 565 |
+
hidden_bf16 = torch.empty(
|
| 566 |
+
(padded_m, up_weight.shape[0]), device=device, dtype=torch.bfloat16
|
| 567 |
+
)
|
| 568 |
+
if hidden_fp8 is None:
|
| 569 |
+
hidden_fp8 = torch.empty_like(hidden_bf16, dtype=_fp8_dtype())
|
| 570 |
+
if out is None:
|
| 571 |
+
out = torch.empty(
|
| 572 |
+
(padded_m, down_weight.shape[0]), device=device, dtype=torch.bfloat16
|
| 573 |
+
)
|
| 574 |
+
ops.bf16_fp8_gelu_mlp_v2_bf16(
|
| 575 |
+
input,
|
| 576 |
+
up_weight,
|
| 577 |
+
up_bias,
|
| 578 |
+
down_weight,
|
| 579 |
+
down_bias,
|
| 580 |
+
input_scale,
|
| 581 |
+
up_weight_scale,
|
| 582 |
+
hidden_scale,
|
| 583 |
+
down_weight_scale,
|
| 584 |
+
input_fp8,
|
| 585 |
+
hidden_bf16,
|
| 586 |
+
hidden_fp8,
|
| 587 |
+
out,
|
| 588 |
+
)
|
| 589 |
+
return out[:logical_m]
|
| 590 |
+
|
| 591 |
+
|
| 592 |
__all__ = [
|
| 593 |
"bf16_fp8_linear_bias_bf16",
|
| 594 |
"bf16_fp8_gelu_mlp_bf16",
|
| 595 |
+
"bf16_fp8_gelu_mlp_v2_bf16",
|
| 596 |
"fp8_gemm_bf16",
|
| 597 |
"fp8_gelu_mlp_bf16",
|
| 598 |
+
"fp8_gelu_mlp_v2_bf16",
|
| 599 |
"fp8_linear_bias_bf16",
|
| 600 |
"fp8_linear_bias_gelu_quant_bf16",
|
| 601 |
]
|
build/torch213-cxx11-cu130-aarch64-linux/{flashrt_fp8_ffn_test.abi3.so → _flashrt_fp8_ffn_cuda_230e467.abi3.so}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:15af85e5b0676f35438b6918df8e0808d6dda1a3eb7ccee0e1253391f1ff2f1b
|
| 3 |
+
size 257080
|
build/torch213-cxx11-cu130-aarch64-linux/_ops.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _flashrt_fp8_ffn_cuda_230e467
|
| 3 |
+
ops = torch.ops._flashrt_fp8_ffn_cuda_230e467
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
return f"_flashrt_fp8_ffn_cuda_230e467::{op_name}"
|
build/torch213-cxx11-cu130-aarch64-linux/metadata.json
CHANGED
|
@@ -1,32 +1,28 @@
|
|
| 1 |
{
|
| 2 |
"name": "flashrt-fp8-ffn",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
| 7 |
"backend": {
|
| 8 |
"type": "cuda",
|
| 9 |
"archs": [
|
| 10 |
-
"11.
|
| 11 |
]
|
| 12 |
},
|
| 13 |
"digest": {
|
| 14 |
"algorithm": "sha256",
|
| 15 |
"files": {
|
| 16 |
-
"__init__.py": "
|
| 17 |
-
"
|
| 18 |
-
"_ops.py": "
|
| 19 |
"flashrt_fp8_ffn/__init__.py": "v6p5XMfQzddhi1fLSAw4HX9CyS0rQsidvu9VsT01xi4="
|
| 20 |
}
|
| 21 |
},
|
| 22 |
"provenance": {
|
| 23 |
"kernel": {
|
| 24 |
-
"sha": "
|
| 25 |
"dirty": false
|
| 26 |
-
},
|
| 27 |
-
"validation": {
|
| 28 |
-
"torch": "2.13.0+cu130",
|
| 29 |
-
"cuda": "13.0"
|
| 30 |
}
|
| 31 |
}
|
| 32 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"name": "flashrt-fp8-ffn",
|
| 3 |
+
"id": "_flashrt_fp8_ffn_cuda_230e467",
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
| 7 |
"backend": {
|
| 8 |
"type": "cuda",
|
| 9 |
"archs": [
|
| 10 |
+
"11.0a"
|
| 11 |
]
|
| 12 |
},
|
| 13 |
"digest": {
|
| 14 |
"algorithm": "sha256",
|
| 15 |
"files": {
|
| 16 |
+
"__init__.py": "O5OvnWgzbfzKB83CtQwQy60BSAa83vizBgNuMnx6D6A=",
|
| 17 |
+
"_flashrt_fp8_ffn_cuda_230e467.abi3.so": "Fa+F5bBnbzVDi2kY344ICNbdoaPrfM7g4SUzkfH/Lxs=",
|
| 18 |
+
"_ops.py": "MmNuiXB4ECVn/fPAOD6Abcdco5Bb4KAyVc26dklNvvc=",
|
| 19 |
"flashrt_fp8_ffn/__init__.py": "v6p5XMfQzddhi1fLSAw4HX9CyS0rQsidvu9VsT01xi4="
|
| 20 |
}
|
| 21 |
},
|
| 22 |
"provenance": {
|
| 23 |
"kernel": {
|
| 24 |
+
"sha": "230e467",
|
| 25 |
"dirty": false
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
}
|
| 27 |
}
|
| 28 |
}
|