liangsu9988 commited on
Commit
1d02f2e
·
verified ·
1 Parent(s): 4356ec3

Promote latest kernel artifacts to main

Browse files
README.md DELETED
@@ -1,9 +0,0 @@
1
- # flashrt/flashrt-fused-quant
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-fused-quant
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-cu128-x86_64-linux/{_flashrt_fused_quant_cuda_c4d802d.abi3.so → _flashrt_fused_quant_cuda_9e33734.abi3.so} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:67c419be13dcb2be2ab262886bc60fc9008864a1e200a4bcfa04a9c51d40e363
3
- size 171912
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ac55df181b1610fd179c0bf619b3405fe37129dd05dd008841d0a18c9cc5089
3
+ size 171880
build/torch211-cxx11-cu128-x86_64-linux/_ops.py CHANGED
@@ -1,9 +1,9 @@
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
  """
7
  Prefix op by namespace.
8
  """
9
- return f"_flashrt_fused_quant_cuda_c4d802d::{op_name}"
 
1
  import torch
2
+ from . import _flashrt_fused_quant_cuda_9e33734
3
+ ops = torch.ops._flashrt_fused_quant_cuda_9e33734
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
+ return f"_flashrt_fused_quant_cuda_9e33734::{op_name}"
build/torch211-cxx11-cu128-x86_64-linux/metadata.json CHANGED
@@ -1,13 +1,13 @@
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
- "12.0"
11
  ]
12
  }
13
  }
 
1
  {
2
  "name": "flashrt-fused-quant",
3
+ "id": "_flashrt_fused_quant_cuda_9e33734",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
7
  "backend": {
8
  "type": "cuda",
9
  "archs": [
10
+ "12.0a"
11
  ]
12
  }
13
  }
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/{torch212-cxx11-cu132-x86_64-linux → torch211-cxx11-cu130-aarch64-linux}/_flashrt_fused_quant_cuda_c4d802d.abi3.so RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:f601af5cea5587f32940bdba39e431bd504ae33c0aee613381d57d3e134adace
3
- size 182504
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad647c1ce6480eb86f543591683eee80dadd2d0eeae85476e7ee008158f91fd4
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,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.0a"
11
+ ]
12
+ },
13
+ "digest": {
14
+ "algorithm": "sha256",
15
+ "files": {
16
+ "__init__.py": "O7W74GfPuHsHXV2HuZEIUUcyhmlCL+2rOXdYH4eW4VE=",
17
+ "_flashrt_fused_quant_cuda_c4d802d.abi3.so": "rWR8HOZIDrhvVDWRaD7ugNrdLQ7q6FR25+4AgVj5H9Q=",
18
+ "_ops.py": "568RL653nmkbqVCzLNOwZsqHvzbRpUvL8pCVpSTGlYQ=",
19
+ "flashrt_fused_quant/__init__.py": "v6p5XMfQzddhi1fLSAw4HX9CyS0rQsidvu9VsT01xi4="
20
+ }
21
+ },
22
+ "provenance": {
23
+ "kernel": {
24
+ "sha": "9e33734",
25
+ "dirty": false
26
+ },
27
+ "validation": {
28
+ "torch": "2.11.0+cu130",
29
+ "cuda": "13.0"
30
+ }
31
+ }
32
+ }
build/torch211-cxx11-cu130-x86_64-linux/{_flashrt_fused_quant_cuda_c4d802d.abi3.so → _flashrt_fused_quant_cuda_9e33734.abi3.so} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:1d766f8d7c97a42c60a5c92680c03f5b21c1d2d73b8df02629f493fdd1dcee1b
3
- size 176568
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:537a1e9ab8da8c40f6aa98c2e2b529986dd79acb899f430922cb942152023fbd
3
+ size 246184
build/torch211-cxx11-cu130-x86_64-linux/_ops.py CHANGED
@@ -1,9 +1,9 @@
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
  """
7
  Prefix op by namespace.
8
  """
9
- return f"_flashrt_fused_quant_cuda_c4d802d::{op_name}"
 
1
  import torch
2
+ from . import _flashrt_fused_quant_cuda_9e33734
3
+ ops = torch.ops._flashrt_fused_quant_cuda_9e33734
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
+ return f"_flashrt_fused_quant_cuda_9e33734::{op_name}"
build/torch211-cxx11-cu130-x86_64-linux/metadata.json CHANGED
@@ -1,13 +1,14 @@
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
- "12.0"
 
11
  ]
12
  }
13
  }
 
1
  {
2
  "name": "flashrt-fused-quant",
3
+ "id": "_flashrt_fused_quant_cuda_9e33734",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
7
  "backend": {
8
  "type": "cuda",
9
  "archs": [
10
+ "11.0a",
11
+ "12.0a"
12
  ]
13
  }
14
  }
build/torch212-cxx11-cu130-x86_64-linux/{_flashrt_fused_quant_cuda_c4d802d.abi3.so → _flashrt_fused_quant_cuda_9e33734.abi3.so} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:df5e3115af67a95306487c04b1acc8b85b8a59bfdf5759b93349c9e2a291bf37
3
- size 182504
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f042d68b2762cca912d3b34bd4ceb6fd6ea139b3bf624662536d58ed25276c6e
3
+ size 248016
build/torch212-cxx11-cu130-x86_64-linux/_ops.py CHANGED
@@ -1,9 +1,9 @@
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
  """
7
  Prefix op by namespace.
8
  """
9
- return f"_flashrt_fused_quant_cuda_c4d802d::{op_name}"
 
1
  import torch
2
+ from . import _flashrt_fused_quant_cuda_9e33734
3
+ ops = torch.ops._flashrt_fused_quant_cuda_9e33734
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
+ return f"_flashrt_fused_quant_cuda_9e33734::{op_name}"
build/torch212-cxx11-cu130-x86_64-linux/metadata.json CHANGED
@@ -1,13 +1,14 @@
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
- "12.0"
 
11
  ]
12
  }
13
  }
 
1
  {
2
  "name": "flashrt-fused-quant",
3
+ "id": "_flashrt_fused_quant_cuda_9e33734",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
7
  "backend": {
8
  "type": "cuda",
9
  "archs": [
10
+ "11.0a",
11
+ "12.0a"
12
  ]
13
  }
14
  }
build/torch212-cxx11-cu132-x86_64-linux/_flashrt_fused_quant_cuda_9e33734.abi3.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a5e697bd5c66b86cb193970b9d7549d9a7e1b2b777f629ccdb4e7b44f2a08482
3
+ size 252112
build/torch212-cxx11-cu132-x86_64-linux/_ops.py CHANGED
@@ -1,9 +1,9 @@
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
  """
7
  Prefix op by namespace.
8
  """
9
- return f"_flashrt_fused_quant_cuda_c4d802d::{op_name}"
 
1
  import torch
2
+ from . import _flashrt_fused_quant_cuda_9e33734
3
+ ops = torch.ops._flashrt_fused_quant_cuda_9e33734
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
+ return f"_flashrt_fused_quant_cuda_9e33734::{op_name}"
build/torch212-cxx11-cu132-x86_64-linux/metadata.json CHANGED
@@ -1,13 +1,14 @@
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
- "12.0"
 
11
  ]
12
  }
13
  }
 
1
  {
2
  "name": "flashrt-fused-quant",
3
+ "id": "_flashrt_fused_quant_cuda_9e33734",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
7
  "backend": {
8
  "type": "cuda",
9
  "archs": [
10
+ "11.0a",
11
+ "12.0a"
12
  ]
13
  }
14
  }