Update Torch 2.11 CUDA 12.8 BF16 FP4 producer artifact
Browse files
build/torch211-cxx11-cu128-x86_64-linux/__init__.py
CHANGED
|
@@ -31,11 +31,20 @@ def _linear_fake(
|
|
| 31 |
sfb: torch.Tensor,
|
| 32 |
out: torch.Tensor,
|
| 33 |
alpha: float = 1.0,
|
| 34 |
-
variant: int =
|
| 35 |
) -> None:
|
| 36 |
return None
|
| 37 |
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
@torch.library.register_fake(add_op_namespace_prefix("fp4_w4a16_linear_bf16"))
|
| 40 |
def _legacy_linear_fake(
|
| 41 |
a_packed: torch.Tensor,
|
|
@@ -44,7 +53,7 @@ def _legacy_linear_fake(
|
|
| 44 |
sfb: torch.Tensor,
|
| 45 |
out: torch.Tensor,
|
| 46 |
alpha: float = 1.0,
|
| 47 |
-
variant: int =
|
| 48 |
) -> None:
|
| 49 |
return None
|
| 50 |
|
|
@@ -54,6 +63,11 @@ def _quant_fake(x: torch.Tensor, packed: torch.Tensor, sfa: torch.Tensor, is_sfb
|
|
| 54 |
return None
|
| 55 |
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
@torch.library.register_fake(add_op_namespace_prefix("dequantize_fp4_sfa_fp16"))
|
| 58 |
def _dequant_fake(packed: torch.Tensor, sfa: torch.Tensor, out: torch.Tensor, is_sfb: bool = False) -> None:
|
| 59 |
return None
|
|
@@ -98,6 +112,19 @@ def quantize_fp4_sfa_fp16(
|
|
| 98 |
return packed, sfa
|
| 99 |
|
| 100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
def dequantize_fp4_sfa_fp16(
|
| 102 |
packed: torch.Tensor,
|
| 103 |
sfa: torch.Tensor,
|
|
@@ -117,7 +144,7 @@ def nvfp4_gemm_bf16(
|
|
| 117 |
sfb: torch.Tensor,
|
| 118 |
alpha: float = 1.0,
|
| 119 |
out: torch.Tensor | None = None,
|
| 120 |
-
variant: int =
|
| 121 |
) -> torch.Tensor:
|
| 122 |
if out is None:
|
| 123 |
out = torch.empty((a_packed.shape[0], b_packed.shape[0]), device=a_packed.device, dtype=torch.bfloat16)
|
|
@@ -125,6 +152,30 @@ def nvfp4_gemm_bf16(
|
|
| 125 |
return out
|
| 126 |
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
def fp4_w4a16_linear_bf16(
|
| 129 |
a_packed: torch.Tensor,
|
| 130 |
b_packed: torch.Tensor,
|
|
@@ -132,7 +183,7 @@ def fp4_w4a16_linear_bf16(
|
|
| 132 |
sfb: torch.Tensor,
|
| 133 |
alpha: float = 1.0,
|
| 134 |
out: torch.Tensor | None = None,
|
| 135 |
-
variant: int =
|
| 136 |
) -> torch.Tensor:
|
| 137 |
"""Compatibility alias for :func:`nvfp4_gemm_bf16`."""
|
| 138 |
return nvfp4_gemm_bf16(
|
|
@@ -243,6 +294,7 @@ def nvfp4_gemm_streamk_bias_bf16(
|
|
| 243 |
__all__ = [
|
| 244 |
"dequantize_fp4_sfa_fp16",
|
| 245 |
"fp4_w4a16_linear_bf16",
|
|
|
|
| 246 |
"nvfp4_gemm_bf16",
|
| 247 |
"nvfp4_gemm_bias_gelu_bf16",
|
| 248 |
"nvfp4_gemm_bias_gelu_nvfp4",
|
|
@@ -250,5 +302,6 @@ __all__ = [
|
|
| 250 |
"nvfp4_gemm_streamk_bf16",
|
| 251 |
"nvfp4_gemm_streamk_bias_bf16",
|
| 252 |
"quantize_fp4_sfa_fp16",
|
|
|
|
| 253 |
"sfa_size_bytes",
|
| 254 |
]
|
|
|
|
| 31 |
sfb: torch.Tensor,
|
| 32 |
out: torch.Tensor,
|
| 33 |
alpha: float = 1.0,
|
| 34 |
+
variant: int = -1,
|
| 35 |
) -> None:
|
| 36 |
return None
|
| 37 |
|
| 38 |
|
| 39 |
+
@torch.library.register_fake(add_op_namespace_prefix("fp4_w4a4_gemv_warpsplit_bf16"))
|
| 40 |
+
def _gemv_warpsplit_fake(a_packed, b_packed, sfa, sfb, out, alpha: float = 1.0, warps: int = 4, stages: int = 4) -> None:
|
| 41 |
+
if a_packed.shape[0] != 1:
|
| 42 |
+
raise RuntimeError("warp-split GEMV serves M=1 only")
|
| 43 |
+
if out.shape != (1, b_packed.shape[0]):
|
| 44 |
+
raise RuntimeError("out must have shape (1, N)")
|
| 45 |
+
return None
|
| 46 |
+
|
| 47 |
+
|
| 48 |
@torch.library.register_fake(add_op_namespace_prefix("fp4_w4a16_linear_bf16"))
|
| 49 |
def _legacy_linear_fake(
|
| 50 |
a_packed: torch.Tensor,
|
|
|
|
| 53 |
sfb: torch.Tensor,
|
| 54 |
out: torch.Tensor,
|
| 55 |
alpha: float = 1.0,
|
| 56 |
+
variant: int = -1,
|
| 57 |
) -> None:
|
| 58 |
return None
|
| 59 |
|
|
|
|
| 63 |
return None
|
| 64 |
|
| 65 |
|
| 66 |
+
@torch.library.register_fake(add_op_namespace_prefix("quantize_fp4_sfa_bf16"))
|
| 67 |
+
def _quant_bf16_fake(x: torch.Tensor, packed: torch.Tensor, sfa: torch.Tensor, is_sfb: bool = False) -> None:
|
| 68 |
+
return None
|
| 69 |
+
|
| 70 |
+
|
| 71 |
@torch.library.register_fake(add_op_namespace_prefix("dequantize_fp4_sfa_fp16"))
|
| 72 |
def _dequant_fake(packed: torch.Tensor, sfa: torch.Tensor, out: torch.Tensor, is_sfb: bool = False) -> None:
|
| 73 |
return None
|
|
|
|
| 112 |
return packed, sfa
|
| 113 |
|
| 114 |
|
| 115 |
+
def quantize_fp4_sfa_bf16(
|
| 116 |
+
x: torch.Tensor,
|
| 117 |
+
packed: torch.Tensor | None = None,
|
| 118 |
+
sfa: torch.Tensor | None = None,
|
| 119 |
+
is_sfb: bool = False,
|
| 120 |
+
):
|
| 121 |
+
"""Quantize BF16 directly to packed E2M1 and CUTLASS SFA/SFB."""
|
| 122 |
+
if packed is None or sfa is None:
|
| 123 |
+
packed, sfa = _alloc_fp4(x.shape[0], x.shape[1], x.device)
|
| 124 |
+
ops.quantize_fp4_sfa_bf16(x, packed, sfa, bool(is_sfb))
|
| 125 |
+
return packed, sfa
|
| 126 |
+
|
| 127 |
+
|
| 128 |
def dequantize_fp4_sfa_fp16(
|
| 129 |
packed: torch.Tensor,
|
| 130 |
sfa: torch.Tensor,
|
|
|
|
| 144 |
sfb: torch.Tensor,
|
| 145 |
alpha: float = 1.0,
|
| 146 |
out: torch.Tensor | None = None,
|
| 147 |
+
variant: int = -1,
|
| 148 |
) -> torch.Tensor:
|
| 149 |
if out is None:
|
| 150 |
out = torch.empty((a_packed.shape[0], b_packed.shape[0]), device=a_packed.device, dtype=torch.bfloat16)
|
|
|
|
| 152 |
return out
|
| 153 |
|
| 154 |
|
| 155 |
+
def fp4_w4a4_gemv_warpsplit_bf16(
|
| 156 |
+
a_packed: torch.Tensor,
|
| 157 |
+
b_packed: torch.Tensor,
|
| 158 |
+
sfa: torch.Tensor,
|
| 159 |
+
sfb: torch.Tensor,
|
| 160 |
+
*,
|
| 161 |
+
alpha: float = 1.0,
|
| 162 |
+
warps: int = 4,
|
| 163 |
+
stages: int = 4,
|
| 164 |
+
out: Optional[torch.Tensor] = None,
|
| 165 |
+
) -> torch.Tensor:
|
| 166 |
+
"""Warp-split-K NVFP4 W4A4 GEMV for the M=1 decode row (SM120).
|
| 167 |
+
|
| 168 |
+
Splits K across warps inside one block with a shared-memory reduce -
|
| 169 |
+
no cross-block intermediate, so it stays safe under CUDA-graph
|
| 170 |
+
replay - and fills the SMs the tiled GEMM underfills at long-K
|
| 171 |
+
small-M decode shapes. Same packed/scale layouts as the linear
|
| 172 |
+
entry points."""
|
| 173 |
+
if out is None:
|
| 174 |
+
out = torch.empty((1, b_packed.shape[0]), device=a_packed.device, dtype=torch.bfloat16)
|
| 175 |
+
ops.fp4_w4a4_gemv_warpsplit_bf16(a_packed, b_packed, sfa, sfb, out, float(alpha), int(warps), int(stages))
|
| 176 |
+
return out
|
| 177 |
+
|
| 178 |
+
|
| 179 |
def fp4_w4a16_linear_bf16(
|
| 180 |
a_packed: torch.Tensor,
|
| 181 |
b_packed: torch.Tensor,
|
|
|
|
| 183 |
sfb: torch.Tensor,
|
| 184 |
alpha: float = 1.0,
|
| 185 |
out: torch.Tensor | None = None,
|
| 186 |
+
variant: int = -1,
|
| 187 |
) -> torch.Tensor:
|
| 188 |
"""Compatibility alias for :func:`nvfp4_gemm_bf16`."""
|
| 189 |
return nvfp4_gemm_bf16(
|
|
|
|
| 294 |
__all__ = [
|
| 295 |
"dequantize_fp4_sfa_fp16",
|
| 296 |
"fp4_w4a16_linear_bf16",
|
| 297 |
+
"fp4_w4a4_gemv_warpsplit_bf16",
|
| 298 |
"nvfp4_gemm_bf16",
|
| 299 |
"nvfp4_gemm_bias_gelu_bf16",
|
| 300 |
"nvfp4_gemm_bias_gelu_nvfp4",
|
|
|
|
| 302 |
"nvfp4_gemm_streamk_bf16",
|
| 303 |
"nvfp4_gemm_streamk_bias_bf16",
|
| 304 |
"quantize_fp4_sfa_fp16",
|
| 305 |
+
"quantize_fp4_sfa_bf16",
|
| 306 |
"sfa_size_bytes",
|
| 307 |
]
|
build/torch211-cxx11-cu128-x86_64-linux/{_fp4_gemm_cuda_7781728.abi3.so → _fp4_gemm_cuda_83a7cd0.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:ac9c00df31abab395c44ea7f019effc0a40fe5e71a6461ca9004540a24f440c2
|
| 3 |
+
size 1825840
|
build/torch211-cxx11-cu128-x86_64-linux/_ops.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import torch
|
| 2 |
-
from . import
|
| 3 |
-
ops = torch.ops.
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
-
return f"
|
|
|
|
| 1 |
import torch
|
| 2 |
+
from . import _fp4_gemm_cuda_83a7cd0
|
| 3 |
+
ops = torch.ops._fp4_gemm_cuda_83a7cd0
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_fp4_gemm_cuda_83a7cd0::{op_name}"
|
build/torch211-cxx11-cu128-x86_64-linux/metadata.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "fp4-gemm",
|
| 3 |
-
"id": "
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
@@ -9,25 +9,5 @@
|
|
| 9 |
"archs": [
|
| 10 |
"12.0a"
|
| 11 |
]
|
| 12 |
-
},
|
| 13 |
-
"digest": {
|
| 14 |
-
"algorithm": "sha256",
|
| 15 |
-
"files": {
|
| 16 |
-
"__init__.py": "FD6tCd6u2NRYfLKq1Uz7OYi+tZV5o9GDAb+KN3GX2oU=",
|
| 17 |
-
"_fp4_gemm_cuda_7781728.abi3.so": "Q8Jgbqk4VPqkvUP3iDWXe+7V3dGgBUEatB3HmYjZmSA=",
|
| 18 |
-
"_ops.py": "4wRBLd5HIJqgJskLFCRBmKJpvQfYeE9AmKTqIPQtPnw=",
|
| 19 |
-
"fp4_gemm/__init__.py": "DFYPlrhXwYjEqCl/8n0SmWGZV8NFml5DPhMjKfv98GY="
|
| 20 |
-
}
|
| 21 |
-
},
|
| 22 |
-
"provenance": {
|
| 23 |
-
"kernel-builder": {
|
| 24 |
-
"version": "0.17.0-dev0",
|
| 25 |
-
"sha": "19aaa6421e674e9fecc352bbae6eab81d19a6bf4",
|
| 26 |
-
"dirty": false
|
| 27 |
-
},
|
| 28 |
-
"kernel": {
|
| 29 |
-
"sha": "77817286c522d8f7abf8d2cd873e1f84a79357b9",
|
| 30 |
-
"dirty": false
|
| 31 |
-
}
|
| 32 |
}
|
| 33 |
-
}
|
|
|
|
| 1 |
{
|
| 2 |
"name": "fp4-gemm",
|
| 3 |
+
"id": "_fp4_gemm_cuda_83a7cd0",
|
| 4 |
"version": 1,
|
| 5 |
"license": "Apache-2.0",
|
| 6 |
"python-depends": [],
|
|
|
|
| 9 |
"archs": [
|
| 10 |
"12.0a"
|
| 11 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
}
|
| 13 |
+
}
|