liangsu9988 commited on
Commit
fb1e09b
·
verified ·
1 Parent(s): 335606a

Add torch211-cxx11-cu130-aarch64-linux SM110 artifact

Browse files
build/torch211-cxx11-cu130-aarch64-linux/__init__.py ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """FlashRT fused activation and quantization kernels."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Optional
6
+
7
+ import torch
8
+
9
+ from ._ops import add_op_namespace_prefix, ops
10
+
11
+
12
+ @torch.library.register_fake(add_op_namespace_prefix("silu_mul_quant_nvfp4_swizzled_bf16"))
13
+ def _silu_mul_quant_nvfp4_swizzled_bf16_fake(
14
+ gate: torch.Tensor,
15
+ up: torch.Tensor,
16
+ packed: torch.Tensor,
17
+ scales: torch.Tensor,
18
+ ) -> None:
19
+ if packed.shape != (gate.shape[0], gate.shape[1] // 2):
20
+ raise RuntimeError("packed shape must be (rows, cols / 2)")
21
+ return None
22
+
23
+
24
+ @torch.library.register_fake(add_op_namespace_prefix("silu_mul_merged_quant_nvfp4_swizzled_bf16"))
25
+ def _silu_mul_merged_quant_nvfp4_swizzled_bf16_fake(
26
+ merged_gate_up: torch.Tensor,
27
+ packed: torch.Tensor,
28
+ scales: torch.Tensor,
29
+ ) -> None:
30
+ rows, merged_cols = merged_gate_up.shape
31
+ if packed.shape != (rows, merged_cols // 4):
32
+ raise RuntimeError("packed shape must be (rows, merged_cols / 4)")
33
+ return None
34
+
35
+
36
+ def nvfp4_swizzled_scale_bytes(rows: int, cols: int) -> int:
37
+ """Return byte count for a CUTLASS Sm1xx NVFP4 swizzled scale buffer."""
38
+
39
+ if rows <= 0:
40
+ raise ValueError("rows must be positive")
41
+ if cols <= 0 or cols % 16 != 0:
42
+ raise ValueError("cols must be positive and divisible by 16")
43
+ n_blocks = cols // 16
44
+ return ((rows + 127) // 128) * ((n_blocks + 3) // 4) * 512
45
+
46
+
47
+ def _allocate_outputs(
48
+ rows: int,
49
+ cols: int,
50
+ device: torch.device,
51
+ packed: Optional[torch.Tensor],
52
+ scales: Optional[torch.Tensor],
53
+ ) -> tuple[torch.Tensor, torch.Tensor]:
54
+ if packed is None:
55
+ packed = torch.empty((rows, cols // 2), device=device, dtype=torch.uint8)
56
+ if scales is None:
57
+ scales = torch.zeros(
58
+ (nvfp4_swizzled_scale_bytes(rows, cols),),
59
+ device=device,
60
+ dtype=torch.uint8,
61
+ )
62
+ return packed, scales
63
+
64
+
65
+ def silu_mul_quant_nvfp4_swizzled_bf16(
66
+ gate: torch.Tensor,
67
+ up: torch.Tensor,
68
+ *,
69
+ packed: Optional[torch.Tensor] = None,
70
+ scales: Optional[torch.Tensor] = None,
71
+ ) -> tuple[torch.Tensor, torch.Tensor]:
72
+ """Compute ``SiLU(gate) * up`` and quantize to NVFP4 swizzled layout.
73
+
74
+ ``gate`` and ``up`` must be contiguous BF16 tensors with shape
75
+ ``(rows, cols)``. ``cols`` must be divisible by 16. The returned ``packed``
76
+ tensor has shape ``(rows, cols / 2)`` and dtype ``torch.uint8``. The
77
+ returned ``scales`` tensor is a flat CUTLASS Sm1xx swizzled UE4M3
78
+ scale-factor byte buffer.
79
+ """
80
+
81
+ if gate.dim() != 2:
82
+ raise ValueError("gate must have shape (rows, cols)")
83
+ rows, cols = gate.shape
84
+ packed, scales = _allocate_outputs(rows, cols, gate.device, packed, scales)
85
+ ops.silu_mul_quant_nvfp4_swizzled_bf16(gate, up, packed, scales)
86
+ return packed, scales
87
+
88
+
89
+ def silu_mul_merged_quant_nvfp4_swizzled_bf16(
90
+ merged_gate_up: torch.Tensor,
91
+ *,
92
+ packed: Optional[torch.Tensor] = None,
93
+ scales: Optional[torch.Tensor] = None,
94
+ ) -> tuple[torch.Tensor, torch.Tensor]:
95
+ """Compute merged ``[gate | up]`` SiLU product and NVFP4 quantization.
96
+
97
+ ``merged_gate_up`` must be contiguous BF16 with shape ``(rows, 2 * cols)``
98
+ and row layout ``[gate | up]``.
99
+ """
100
+
101
+ if merged_gate_up.dim() != 2:
102
+ raise ValueError("merged_gate_up must have shape (rows, 2 * cols)")
103
+ rows, merged_cols = merged_gate_up.shape
104
+ if merged_cols % 2 != 0:
105
+ raise ValueError("merged_gate_up.shape[1] must be even")
106
+ cols = merged_cols // 2
107
+ packed, scales = _allocate_outputs(
108
+ rows, cols, merged_gate_up.device, packed, scales
109
+ )
110
+ ops.silu_mul_merged_quant_nvfp4_swizzled_bf16(
111
+ merged_gate_up,
112
+ packed,
113
+ scales,
114
+ )
115
+ return packed, scales
116
+
117
+
118
+ __all__ = [
119
+ "nvfp4_swizzled_scale_bytes",
120
+ "silu_mul_quant_nvfp4_swizzled_bf16",
121
+ "silu_mul_merged_quant_nvfp4_swizzled_bf16",
122
+ ]
build/torch211-cxx11-cu130-aarch64-linux/_flashrt_fused_quant_cuda_c4d802d.abi3.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f6d95803f9bd5045b0c93677efa93f216d4dc726a006a0302c0c07af917d3c88
3
+ size 238224
build/torch211-cxx11-cu130-aarch64-linux/_ops.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import torch
2
+ from . import _flashrt_fused_quant_cuda_c4d802d
3
+ ops = torch.ops._flashrt_fused_quant_cuda_c4d802d
4
+
5
+ def add_op_namespace_prefix(op_name: str):
6
+ return f"_flashrt_fused_quant_cuda_c4d802d::{op_name}"
build/torch211-cxx11-cu130-aarch64-linux/flashrt_fused_quant/__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/torch211-cxx11-cu130-aarch64-linux/metadata.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "flashrt-fused-quant",
3
+ "id": "_flashrt_fused_quant_cuda_c4d802d",
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": "O7W74GfPuHsHXV2HuZEIUUcyhmlCL+2rOXdYH4eW4VE=",
17
+ "_flashrt_fused_quant_cuda_c4d802d.abi3.so": "9tlYA/m9UEWwyTZ376k/IW1NxyagBqAwLAwHr5F9PIg=",
18
+ "_ops.py": "568RL653nmkbqVCzLNOwZsqHvzbRpUvL8pCVpSTGlYQ=",
19
+ "flashrt_fused_quant/__init__.py": "v6p5XMfQzddhi1fLSAw4HX9CyS0rQsidvu9VsT01xi4="
20
+ }
21
+ }
22
+ }