danieldk HF Staff commited on
Commit
c554bb5
·
1 Parent(s): d9e5445

Remove builds incompatible with kernels >= 0.14

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. build/torch210-cu128-x86_64-windows/activation/__init__.py +0 -75
  2. build/torch210-cu128-x86_64-windows/activation/_activation_e1b4b08.pyd +0 -3
  3. build/torch210-cu128-x86_64-windows/activation/_ops.py +0 -9
  4. build/torch210-cu128-x86_64-windows/activation/layers.py +0 -201
  5. build/torch210-cu128-x86_64-windows/metadata.json +0 -4
  6. build/torch211-cu128-x86_64-windows/__init__.py +0 -75
  7. build/torch211-cu128-x86_64-windows/_activation_cuda_47eab20.pyd +0 -3
  8. build/torch211-cu128-x86_64-windows/_ops.py +0 -9
  9. build/torch211-cu128-x86_64-windows/activation/__init__.py +0 -26
  10. build/torch211-cu128-x86_64-windows/layers.py +0 -201
  11. build/torch211-cu128-x86_64-windows/metadata.json +0 -21
  12. build/torch27-cxx11-cu118-x86_64-linux/activation/__init__.py +0 -75
  13. build/torch27-cxx11-cu118-x86_64-linux/activation/__pycache__/__init__.cpython-313.pyc +0 -0
  14. build/torch27-cxx11-cu118-x86_64-linux/activation/__pycache__/_ops.cpython-313.pyc +0 -0
  15. build/torch27-cxx11-cu118-x86_64-linux/activation/__pycache__/layers.cpython-313.pyc +0 -0
  16. build/torch27-cxx11-cu118-x86_64-linux/activation/_activation_beeaae6.abi3.so +0 -3
  17. build/torch27-cxx11-cu118-x86_64-linux/activation/_ops.py +0 -9
  18. build/torch27-cxx11-cu118-x86_64-linux/activation/layers.py +0 -179
  19. build/torch27-cxx11-cu126-x86_64-linux/activation/__init__.py +0 -75
  20. build/torch27-cxx11-cu126-x86_64-linux/activation/__pycache__/__init__.cpython-313.pyc +0 -0
  21. build/torch27-cxx11-cu126-x86_64-linux/activation/__pycache__/_ops.cpython-313.pyc +0 -0
  22. build/torch27-cxx11-cu126-x86_64-linux/activation/__pycache__/layers.cpython-313.pyc +0 -0
  23. build/torch27-cxx11-cu126-x86_64-linux/activation/_activation_beeaae6.abi3.so +0 -3
  24. build/torch27-cxx11-cu126-x86_64-linux/activation/_ops.py +0 -9
  25. build/torch27-cxx11-cu126-x86_64-linux/activation/layers.py +0 -179
  26. build/torch27-cxx11-cu128-aarch64-linux/activation/__init__.py +0 -75
  27. build/torch27-cxx11-cu128-aarch64-linux/activation/__pycache__/__init__.cpython-313.pyc +0 -0
  28. build/torch27-cxx11-cu128-aarch64-linux/activation/__pycache__/_ops.cpython-313.pyc +0 -0
  29. build/torch27-cxx11-cu128-aarch64-linux/activation/__pycache__/layers.cpython-313.pyc +0 -0
  30. build/torch27-cxx11-cu128-aarch64-linux/activation/_activation_320b408.abi3.so +0 -3
  31. build/torch27-cxx11-cu128-aarch64-linux/activation/_ops.py +0 -9
  32. build/torch27-cxx11-cu128-aarch64-linux/activation/layers.py +0 -179
  33. build/torch27-cxx11-cu128-x86_64-linux/activation/__init__.py +0 -75
  34. build/torch27-cxx11-cu128-x86_64-linux/activation/__pycache__/__init__.cpython-313.pyc +0 -0
  35. build/torch27-cxx11-cu128-x86_64-linux/activation/__pycache__/_ops.cpython-313.pyc +0 -0
  36. build/torch27-cxx11-cu128-x86_64-linux/activation/__pycache__/layers.cpython-313.pyc +0 -0
  37. build/torch27-cxx11-cu128-x86_64-linux/activation/_activation_beeaae6.abi3.so +0 -3
  38. build/torch27-cxx11-cu128-x86_64-linux/activation/_ops.py +0 -9
  39. build/torch27-cxx11-cu128-x86_64-linux/activation/layers.py +0 -179
  40. build/torch28-cxx11-cu126-aarch64-linux/activation/__init__.py +0 -57
  41. build/torch28-cxx11-cu126-aarch64-linux/activation/__pycache__/__init__.cpython-313.pyc +0 -0
  42. build/torch28-cxx11-cu126-aarch64-linux/activation/__pycache__/_ops.cpython-313.pyc +0 -0
  43. build/torch28-cxx11-cu126-aarch64-linux/activation/__pycache__/layers.cpython-313.pyc +0 -0
  44. build/torch28-cxx11-cu126-aarch64-linux/activation/_activation_0c3eb4e_dirty.abi3.so +0 -3
  45. build/torch28-cxx11-cu126-aarch64-linux/activation/_ops.py +0 -9
  46. build/torch28-cxx11-cu126-aarch64-linux/activation/layers.py +0 -128
  47. build/torch28-cxx11-cu126-x86_64-linux/__init__.py +0 -75
  48. build/torch28-cxx11-cu126-x86_64-linux/_activation_f8d6759.abi3.so +0 -3
  49. build/torch28-cxx11-cu126-x86_64-linux/_ops.py +0 -9
  50. build/torch28-cxx11-cu126-x86_64-linux/activation/__init__.py +0 -26
build/torch210-cu128-x86_64-windows/activation/__init__.py DELETED
@@ -1,75 +0,0 @@
1
- import torch
2
-
3
- from ._ops import ops
4
-
5
- from . import layers
6
-
7
-
8
- def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
9
- ops.silu_and_mul(out, x)
10
- return out
11
-
12
-
13
- def mul_and_silu(out: torch.Tensor, x: torch.Tensor) -> None:
14
- ops.mul_and_silu(out, x)
15
- return out
16
-
17
-
18
- def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
19
- ops.gelu_and_mul(out, x)
20
- return out
21
-
22
-
23
- def gelu_tanh_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
24
- ops.gelu_tanh_and_mul(out, x)
25
- return out
26
-
27
-
28
- def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0) -> None:
29
- ops.fatrelu_and_mul(out, x, threshold)
30
- return out
31
-
32
-
33
- def gelu(out: torch.Tensor, x: torch.Tensor) -> None:
34
- ops.gelu(out, x)
35
- return out
36
-
37
- def silu(out: torch.Tensor, x: torch.Tensor) -> None:
38
- ops.silu(out, x)
39
- return out
40
-
41
-
42
- def gelu_tanh(out: torch.Tensor, x: torch.Tensor) -> None:
43
- ops.gelu_tanh(out, x)
44
- return out
45
-
46
-
47
- def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> None:
48
- ops.gelu_fast(out, x)
49
- return out
50
-
51
-
52
- def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
53
- ops.gelu_new(out, x)
54
- return out
55
-
56
-
57
- def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
58
- ops.gelu_quick(out, x)
59
- return out
60
-
61
-
62
- __all__ = [
63
- "silu_and_mul",
64
- "mul_and_silu",
65
- "gelu_and_mul",
66
- "gelu_tanh_and_mul",
67
- "fatrelu_and_mul",
68
- "gelu_fast",
69
- "gelu_new",
70
- "gelu_quick",
71
- "gelu_tanh",
72
- "silu",
73
- "gelu",
74
- "layers",
75
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/torch210-cu128-x86_64-windows/activation/_activation_e1b4b08.pyd DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:d741006dd4fe8a85ed461fa3727d4d9f1b438083d2f1075ae54650bbdd2dc179
3
- size 2463744
 
 
 
 
build/torch210-cu128-x86_64-windows/activation/_ops.py DELETED
@@ -1,9 +0,0 @@
1
- import torch
2
- from . import _activation_e1b4b08
3
- ops = torch.ops._activation_e1b4b08
4
-
5
- def add_op_namespace_prefix(op_name: str):
6
- """
7
- Prefix op by namespace.
8
- """
9
- return f"_activation_e1b4b08::{op_name}"
 
 
 
 
 
 
 
 
 
 
build/torch210-cu128-x86_64-windows/activation/layers.py DELETED
@@ -1,201 +0,0 @@
1
- import torch
2
- import torch.nn as nn
3
-
4
- from ._ops import ops
5
-
6
-
7
- class SiluAndMul(nn.Module):
8
- """An activation function for SwiGLU.
9
-
10
- The function computes x -> silu(x[:d]) * x[d:] where d = x.shape[-1] // 2.
11
-
12
- Shapes:
13
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
14
- return: (num_tokens, d) or (batch_size, seq_len, d)
15
- """
16
-
17
- can_torch_compile: bool = True
18
-
19
- def forward(self, x: torch.Tensor):
20
- if not x.is_contiguous():
21
- x = x.contiguous()
22
- d = x.shape[-1] // 2
23
- output_shape = x.shape[:-1] + (d,)
24
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
25
- ops.silu_and_mul(out, x)
26
- return out
27
-
28
- class Silu(nn.Module):
29
- """An activation function for SiLU.
30
-
31
- The function computes x -> silu(x).
32
-
33
- Shapes:
34
- x: (num_tokens, d) or (batch_size, seq_len, d)
35
- return: (num_tokens, d) or (batch_size, seq_len, d)
36
- """
37
-
38
- can_torch_compile: bool = True
39
-
40
- def forward(self, x: torch.Tensor):
41
- if not x.is_contiguous():
42
- x = x.contiguous()
43
- out = torch.empty_like(x)
44
- ops.silu(out, x)
45
- return out
46
-
47
- class Gelu(nn.Module):
48
- """An activation function for GELU.
49
-
50
- The function computes x -> gelu(x).
51
-
52
- Shapes:
53
- x: (num_tokens, d) or (batch_size, seq_len, d)
54
- return: (num_tokens, d) or (batch_size, seq_len, d)
55
- """
56
-
57
- can_torch_compile: bool = True
58
-
59
- def forward(self, x: torch.Tensor):
60
- if not x.is_contiguous():
61
- x = x.contiguous()
62
- out = torch.empty_like(x)
63
- ops.gelu(out, x)
64
- return out
65
-
66
- class GeluTanh(nn.Module):
67
- """An activation function for GELU with `tanh` approximation.
68
-
69
- The function computes x -> gelu_tanh(x).
70
-
71
- Shapes:
72
- x: (num_tokens, d) or (batch_size, seq_len, d)
73
- return: (num_tokens, d) or (batch_size, seq_len, d)
74
- """
75
-
76
- can_torch_compile: bool = True
77
-
78
- def forward(self, x: torch.Tensor):
79
- if not x.is_contiguous():
80
- x = x.contiguous()
81
- out = torch.empty_like(x)
82
- ops.gelu_tanh(out, x)
83
- return out
84
-
85
-
86
- class MulAndSilu(nn.Module):
87
- """An activation function for SwiGLU.
88
-
89
- The function computes x -> x[:d] * silu(x[d:]) where d = x.shape[-1] // 2.
90
-
91
- Shapes:
92
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
93
- return: (num_tokens, d) or (batch_size, seq_len, d)
94
- """
95
-
96
- can_torch_compile: bool = True
97
-
98
- def forward(self, x: torch.Tensor) -> torch.Tensor:
99
- if not x.is_contiguous():
100
- x = x.contiguous()
101
- d = x.shape[-1] // 2
102
- output_shape = x.shape[:-1] + (d,)
103
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
104
- ops.mul_and_silu(out, x)
105
- return out
106
-
107
-
108
- class GeluAndMul(nn.Module):
109
- """An activation function for GeGLU.
110
-
111
- The function computes x -> GELU(x[:d]) * x[d:] where d = x.shape[-1] // 2.
112
-
113
- Shapes:
114
- x: (batch_size, seq_len, 2 * d) or (num_tokens, 2 * d)
115
- return: (batch_size, seq_len, d) or (num_tokens, d)
116
- """
117
-
118
- can_torch_compile: bool = True
119
-
120
- def forward(self, x: torch.Tensor):
121
- if not x.is_contiguous():
122
- x = x.contiguous()
123
- d = x.shape[-1] // 2
124
- output_shape = x.shape[:-1] + (d,)
125
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
126
- ops.gelu_and_mul(out, x)
127
- return out
128
-
129
-
130
- class GeluTanhAndMul(nn.Module):
131
- can_torch_compile: bool = True
132
-
133
- def forward(self, x: torch.Tensor):
134
- if not x.is_contiguous():
135
- x = x.contiguous()
136
- d = x.shape[-1] // 2
137
- output_shape = x.shape[:-1] + (d,)
138
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
139
- ops.gelu_tanh_and_mul(out, x)
140
- return out
141
-
142
-
143
- class FatreluAndMul(nn.Module):
144
- """An activation function for FATReLU.
145
-
146
- The function computes x -> FATReLU(x[:d]) * x[d:] where
147
- d = x.shape[-1] // 2.
148
- This is used in openbmb/MiniCPM-S-1B-sft.
149
-
150
- Shapes:
151
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
152
- return: (num_tokens, d) or (batch_size, seq_len, d)
153
- """
154
-
155
- can_torch_compile: bool = True
156
-
157
- def __init__(self, threshold: float = 0.0):
158
- super().__init__()
159
- self.threshold = threshold
160
-
161
- def forward(self, x: torch.Tensor):
162
- if not x.is_contiguous():
163
- x = x.contiguous()
164
- d = x.shape[-1] // 2
165
- output_shape = x.shape[:-1] + (d,)
166
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
167
- ops.fatrelu_and_mul(out, x, self.threshold)
168
- return out
169
-
170
-
171
- class FastGELU(nn.Module):
172
- can_torch_compile: bool = True
173
-
174
- def forward(self, x: torch.Tensor) -> torch.Tensor:
175
- if not x.is_contiguous():
176
- x = x.contiguous()
177
- out = torch.empty_like(x)
178
- ops.gelu_fast(out, x)
179
- return out
180
-
181
-
182
- class NewGELU(nn.Module):
183
- can_torch_compile: bool = True
184
-
185
- def forward(self, x: torch.Tensor) -> torch.Tensor:
186
- if not x.is_contiguous():
187
- x = x.contiguous()
188
- out = torch.empty_like(x)
189
- ops.gelu_new(out, x)
190
- return out
191
-
192
-
193
- class QuickGELU(nn.Module):
194
- can_torch_compile: bool = True
195
-
196
- def forward(self, x: torch.Tensor) -> torch.Tensor:
197
- if not x.is_contiguous():
198
- x = x.contiguous()
199
- out = torch.empty_like(x)
200
- ops.gelu_quick(out, x)
201
- return out
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/torch210-cu128-x86_64-windows/metadata.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "version": 1,
3
- "python-depends": []
4
- }
 
 
 
 
 
build/torch211-cu128-x86_64-windows/__init__.py DELETED
@@ -1,75 +0,0 @@
1
- import torch
2
-
3
- from ._ops import ops
4
-
5
- from . import layers
6
-
7
-
8
- def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
9
- ops.silu_and_mul(out, x)
10
- return out
11
-
12
-
13
- def mul_and_silu(out: torch.Tensor, x: torch.Tensor) -> None:
14
- ops.mul_and_silu(out, x)
15
- return out
16
-
17
-
18
- def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
19
- ops.gelu_and_mul(out, x)
20
- return out
21
-
22
-
23
- def gelu_tanh_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
24
- ops.gelu_tanh_and_mul(out, x)
25
- return out
26
-
27
-
28
- def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0) -> None:
29
- ops.fatrelu_and_mul(out, x, threshold)
30
- return out
31
-
32
-
33
- def gelu(out: torch.Tensor, x: torch.Tensor) -> None:
34
- ops.gelu(out, x)
35
- return out
36
-
37
- def silu(out: torch.Tensor, x: torch.Tensor) -> None:
38
- ops.silu(out, x)
39
- return out
40
-
41
-
42
- def gelu_tanh(out: torch.Tensor, x: torch.Tensor) -> None:
43
- ops.gelu_tanh(out, x)
44
- return out
45
-
46
-
47
- def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> None:
48
- ops.gelu_fast(out, x)
49
- return out
50
-
51
-
52
- def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
53
- ops.gelu_new(out, x)
54
- return out
55
-
56
-
57
- def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
58
- ops.gelu_quick(out, x)
59
- return out
60
-
61
-
62
- __all__ = [
63
- "silu_and_mul",
64
- "mul_and_silu",
65
- "gelu_and_mul",
66
- "gelu_tanh_and_mul",
67
- "fatrelu_and_mul",
68
- "gelu_fast",
69
- "gelu_new",
70
- "gelu_quick",
71
- "gelu_tanh",
72
- "silu",
73
- "gelu",
74
- "layers",
75
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/torch211-cu128-x86_64-windows/_activation_cuda_47eab20.pyd DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:93643f052fbcac3db67fed466c5a0a080ff9d3ad7fffa463793fa2f35a275785
3
- size 2464256
 
 
 
 
build/torch211-cu128-x86_64-windows/_ops.py DELETED
@@ -1,9 +0,0 @@
1
- import torch
2
- from . import _activation_cuda_47eab20
3
- ops = torch.ops._activation_cuda_47eab20
4
-
5
- def add_op_namespace_prefix(op_name: str):
6
- """
7
- Prefix op by namespace.
8
- """
9
- return f"_activation_cuda_47eab20::{op_name}"
 
 
 
 
 
 
 
 
 
 
build/torch211-cu128-x86_64-windows/activation/__init__.py DELETED
@@ -1,26 +0,0 @@
1
- import ctypes
2
- import importlib.util
3
- import sys
4
- from pathlib import Path
5
- from types import ModuleType
6
-
7
-
8
- def _import_from_path(file_path: Path) -> ModuleType:
9
- # We cannot use the module name as-is, after adding it to `sys.modules`,
10
- # it would also be used for other imports. So, we make a module name that
11
- # depends on the path for it to be unique using the hex-encoded hash of
12
- # the path.
13
- path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
14
- module_name = path_hash
15
- spec = importlib.util.spec_from_file_location(module_name, file_path)
16
- if spec is None:
17
- raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
18
- module = importlib.util.module_from_spec(spec)
19
- if module is None:
20
- raise ImportError(f"Cannot load module {module_name} from spec")
21
- sys.modules[module_name] = module
22
- spec.loader.exec_module(module) # type: ignore
23
- return module
24
-
25
-
26
- globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/torch211-cu128-x86_64-windows/layers.py DELETED
@@ -1,201 +0,0 @@
1
- import torch
2
- import torch.nn as nn
3
-
4
- from ._ops import ops
5
-
6
-
7
- class SiluAndMul(nn.Module):
8
- """An activation function for SwiGLU.
9
-
10
- The function computes x -> silu(x[:d]) * x[d:] where d = x.shape[-1] // 2.
11
-
12
- Shapes:
13
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
14
- return: (num_tokens, d) or (batch_size, seq_len, d)
15
- """
16
-
17
- can_torch_compile: bool = True
18
-
19
- def forward(self, x: torch.Tensor):
20
- if not x.is_contiguous():
21
- x = x.contiguous()
22
- d = x.shape[-1] // 2
23
- output_shape = x.shape[:-1] + (d,)
24
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
25
- ops.silu_and_mul(out, x)
26
- return out
27
-
28
- class Silu(nn.Module):
29
- """An activation function for SiLU.
30
-
31
- The function computes x -> silu(x).
32
-
33
- Shapes:
34
- x: (num_tokens, d) or (batch_size, seq_len, d)
35
- return: (num_tokens, d) or (batch_size, seq_len, d)
36
- """
37
-
38
- can_torch_compile: bool = True
39
-
40
- def forward(self, x: torch.Tensor):
41
- if not x.is_contiguous():
42
- x = x.contiguous()
43
- out = torch.empty_like(x)
44
- ops.silu(out, x)
45
- return out
46
-
47
- class Gelu(nn.Module):
48
- """An activation function for GELU.
49
-
50
- The function computes x -> gelu(x).
51
-
52
- Shapes:
53
- x: (num_tokens, d) or (batch_size, seq_len, d)
54
- return: (num_tokens, d) or (batch_size, seq_len, d)
55
- """
56
-
57
- can_torch_compile: bool = True
58
-
59
- def forward(self, x: torch.Tensor):
60
- if not x.is_contiguous():
61
- x = x.contiguous()
62
- out = torch.empty_like(x)
63
- ops.gelu(out, x)
64
- return out
65
-
66
- class GeluTanh(nn.Module):
67
- """An activation function for GELU with `tanh` approximation.
68
-
69
- The function computes x -> gelu_tanh(x).
70
-
71
- Shapes:
72
- x: (num_tokens, d) or (batch_size, seq_len, d)
73
- return: (num_tokens, d) or (batch_size, seq_len, d)
74
- """
75
-
76
- can_torch_compile: bool = True
77
-
78
- def forward(self, x: torch.Tensor):
79
- if not x.is_contiguous():
80
- x = x.contiguous()
81
- out = torch.empty_like(x)
82
- ops.gelu_tanh(out, x)
83
- return out
84
-
85
-
86
- class MulAndSilu(nn.Module):
87
- """An activation function for SwiGLU.
88
-
89
- The function computes x -> x[:d] * silu(x[d:]) where d = x.shape[-1] // 2.
90
-
91
- Shapes:
92
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
93
- return: (num_tokens, d) or (batch_size, seq_len, d)
94
- """
95
-
96
- can_torch_compile: bool = True
97
-
98
- def forward(self, x: torch.Tensor) -> torch.Tensor:
99
- if not x.is_contiguous():
100
- x = x.contiguous()
101
- d = x.shape[-1] // 2
102
- output_shape = x.shape[:-1] + (d,)
103
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
104
- ops.mul_and_silu(out, x)
105
- return out
106
-
107
-
108
- class GeluAndMul(nn.Module):
109
- """An activation function for GeGLU.
110
-
111
- The function computes x -> GELU(x[:d]) * x[d:] where d = x.shape[-1] // 2.
112
-
113
- Shapes:
114
- x: (batch_size, seq_len, 2 * d) or (num_tokens, 2 * d)
115
- return: (batch_size, seq_len, d) or (num_tokens, d)
116
- """
117
-
118
- can_torch_compile: bool = True
119
-
120
- def forward(self, x: torch.Tensor):
121
- if not x.is_contiguous():
122
- x = x.contiguous()
123
- d = x.shape[-1] // 2
124
- output_shape = x.shape[:-1] + (d,)
125
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
126
- ops.gelu_and_mul(out, x)
127
- return out
128
-
129
-
130
- class GeluTanhAndMul(nn.Module):
131
- can_torch_compile: bool = True
132
-
133
- def forward(self, x: torch.Tensor):
134
- if not x.is_contiguous():
135
- x = x.contiguous()
136
- d = x.shape[-1] // 2
137
- output_shape = x.shape[:-1] + (d,)
138
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
139
- ops.gelu_tanh_and_mul(out, x)
140
- return out
141
-
142
-
143
- class FatreluAndMul(nn.Module):
144
- """An activation function for FATReLU.
145
-
146
- The function computes x -> FATReLU(x[:d]) * x[d:] where
147
- d = x.shape[-1] // 2.
148
- This is used in openbmb/MiniCPM-S-1B-sft.
149
-
150
- Shapes:
151
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
152
- return: (num_tokens, d) or (batch_size, seq_len, d)
153
- """
154
-
155
- can_torch_compile: bool = True
156
-
157
- def __init__(self, threshold: float = 0.0):
158
- super().__init__()
159
- self.threshold = threshold
160
-
161
- def forward(self, x: torch.Tensor):
162
- if not x.is_contiguous():
163
- x = x.contiguous()
164
- d = x.shape[-1] // 2
165
- output_shape = x.shape[:-1] + (d,)
166
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
167
- ops.fatrelu_and_mul(out, x, self.threshold)
168
- return out
169
-
170
-
171
- class FastGELU(nn.Module):
172
- can_torch_compile: bool = True
173
-
174
- def forward(self, x: torch.Tensor) -> torch.Tensor:
175
- if not x.is_contiguous():
176
- x = x.contiguous()
177
- out = torch.empty_like(x)
178
- ops.gelu_fast(out, x)
179
- return out
180
-
181
-
182
- class NewGELU(nn.Module):
183
- can_torch_compile: bool = True
184
-
185
- def forward(self, x: torch.Tensor) -> torch.Tensor:
186
- if not x.is_contiguous():
187
- x = x.contiguous()
188
- out = torch.empty_like(x)
189
- ops.gelu_new(out, x)
190
- return out
191
-
192
-
193
- class QuickGELU(nn.Module):
194
- can_torch_compile: bool = True
195
-
196
- def forward(self, x: torch.Tensor) -> torch.Tensor:
197
- if not x.is_contiguous():
198
- x = x.contiguous()
199
- out = torch.empty_like(x)
200
- ops.gelu_quick(out, x)
201
- return out
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/torch211-cu128-x86_64-windows/metadata.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "version": 1,
3
- "license": "Apache-2.0",
4
- "python-depends": [],
5
- "backend": {
6
- "type": "cuda",
7
- "archs": [
8
- "10.0",
9
- "10.1",
10
- "12.0+PTX",
11
- "7.0",
12
- "7.2",
13
- "7.5",
14
- "8.0",
15
- "8.6",
16
- "8.7",
17
- "8.9",
18
- "9.0"
19
- ]
20
- }
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/torch27-cxx11-cu118-x86_64-linux/activation/__init__.py DELETED
@@ -1,75 +0,0 @@
1
- import torch
2
-
3
- from ._ops import ops
4
-
5
- from . import layers
6
-
7
-
8
- def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
9
- ops.silu_and_mul(out, x)
10
- return out
11
-
12
-
13
- def mul_and_silu(out: torch.Tensor, x: torch.Tensor) -> None:
14
- ops.mul_and_silu(out, x)
15
- return out
16
-
17
-
18
- def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
19
- ops.gelu_and_mul(out, x)
20
- return out
21
-
22
-
23
- def gelu_tanh_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
24
- ops.gelu_tanh_and_mul(out, x)
25
- return out
26
-
27
-
28
- def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0) -> None:
29
- ops.fatrelu_and_mul(out, x, threshold)
30
- return out
31
-
32
-
33
- def gelu(out: torch.Tensor, x: torch.Tensor) -> None:
34
- ops.gelu(out, x)
35
- return out
36
-
37
- def silu(out: torch.Tensor, x: torch.Tensor) -> None:
38
- ops.silu(out, x)
39
- return out
40
-
41
-
42
- def gelu_tanh(out: torch.Tensor, x: torch.Tensor) -> None:
43
- ops.gelu_tanh(out, x)
44
- return out
45
-
46
-
47
- def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> None:
48
- ops.gelu_fast(out, x)
49
- return out
50
-
51
-
52
- def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
53
- ops.gelu_new(out, x)
54
- return out
55
-
56
-
57
- def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
58
- ops.gelu_quick(out, x)
59
- return out
60
-
61
-
62
- __all__ = [
63
- "silu_and_mul",
64
- "mul_and_silu",
65
- "gelu_and_mul",
66
- "gelu_tanh_and_mul",
67
- "fatrelu_and_mul",
68
- "gelu_fast",
69
- "gelu_new",
70
- "gelu_quick",
71
- "gelu_tanh",
72
- "silu",
73
- "gelu",
74
- "layers",
75
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/torch27-cxx11-cu118-x86_64-linux/activation/__pycache__/__init__.cpython-313.pyc DELETED
Binary file (3.25 kB)
 
build/torch27-cxx11-cu118-x86_64-linux/activation/__pycache__/_ops.cpython-313.pyc DELETED
Binary file (526 Bytes)
 
build/torch27-cxx11-cu118-x86_64-linux/activation/__pycache__/layers.cpython-313.pyc DELETED
Binary file (8.92 kB)
 
build/torch27-cxx11-cu118-x86_64-linux/activation/_activation_beeaae6.abi3.so DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:ce06ec284ecd4ac5423d3822a60cd9eeb686d0054b38d66567de73e1137b0567
3
- size 2773632
 
 
 
 
build/torch27-cxx11-cu118-x86_64-linux/activation/_ops.py DELETED
@@ -1,9 +0,0 @@
1
- import torch
2
- from . import _activation_beeaae6
3
- ops = torch.ops._activation_beeaae6
4
-
5
- def add_op_namespace_prefix(op_name: str):
6
- """
7
- Prefix op by namespace.
8
- """
9
- return f"_activation_beeaae6::{op_name}"
 
 
 
 
 
 
 
 
 
 
build/torch27-cxx11-cu118-x86_64-linux/activation/layers.py DELETED
@@ -1,179 +0,0 @@
1
- import torch
2
- import torch.nn as nn
3
-
4
- from ._ops import ops
5
-
6
-
7
- class SiluAndMul(nn.Module):
8
- """An activation function for SwiGLU.
9
-
10
- The function computes x -> silu(x[:d]) * x[d:] where d = x.shape[-1] // 2.
11
-
12
- Shapes:
13
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
14
- return: (num_tokens, d) or (batch_size, seq_len, d)
15
- """
16
-
17
- can_torch_compile: bool = True
18
-
19
- def forward(self, x: torch.Tensor):
20
- d = x.shape[-1] // 2
21
- output_shape = x.shape[:-1] + (d,)
22
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
23
- ops.silu_and_mul(out, x)
24
- return out
25
-
26
- class Silu(nn.Module):
27
- """An activation function for SiLU.
28
-
29
- The function computes x -> silu(x).
30
-
31
- Shapes:
32
- x: (num_tokens, d) or (batch_size, seq_len, d)
33
- return: (num_tokens, d) or (batch_size, seq_len, d)
34
- """
35
-
36
- can_torch_compile: bool = True
37
-
38
- def forward(self, x: torch.Tensor):
39
- out = torch.empty_like(x)
40
- ops.silu(out, x)
41
- return out
42
-
43
- class Gelu(nn.Module):
44
- """An activation function for GELU.
45
-
46
- The function computes x -> gelu(x).
47
-
48
- Shapes:
49
- x: (num_tokens, d) or (batch_size, seq_len, d)
50
- return: (num_tokens, d) or (batch_size, seq_len, d)
51
- """
52
-
53
- can_torch_compile: bool = True
54
-
55
- def forward(self, x: torch.Tensor):
56
- out = torch.empty_like(x)
57
- ops.gelu(out, x)
58
- return out
59
-
60
- class GeluTanh(nn.Module):
61
- """An activation function for GELU with `tanh` approximation.
62
-
63
- The function computes x -> gelu_tanh(x).
64
-
65
- Shapes:
66
- x: (num_tokens, d) or (batch_size, seq_len, d)
67
- return: (num_tokens, d) or (batch_size, seq_len, d)
68
- """
69
-
70
- can_torch_compile: bool = True
71
-
72
- def forward(self, x: torch.Tensor):
73
- out = torch.empty_like(x)
74
- ops.gelu_tanh(out, x)
75
- return out
76
-
77
-
78
- class MulAndSilu(nn.Module):
79
- """An activation function for SwiGLU.
80
-
81
- The function computes x -> x[:d] * silu(x[d:]) where d = x.shape[-1] // 2.
82
-
83
- Shapes:
84
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
85
- return: (num_tokens, d) or (batch_size, seq_len, d)
86
- """
87
-
88
- can_torch_compile: bool = True
89
-
90
- def forward(self, x: torch.Tensor) -> torch.Tensor:
91
- d = x.shape[-1] // 2
92
- output_shape = x.shape[:-1] + (d,)
93
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
94
- ops.mul_and_silu(out, x)
95
- return out
96
-
97
-
98
- class GeluAndMul(nn.Module):
99
- """An activation function for GeGLU.
100
-
101
- The function computes x -> GELU(x[:d]) * x[d:] where d = x.shape[-1] // 2.
102
-
103
- Shapes:
104
- x: (batch_size, seq_len, 2 * d) or (num_tokens, 2 * d)
105
- return: (batch_size, seq_len, d) or (num_tokens, d)
106
- """
107
-
108
- can_torch_compile: bool = True
109
-
110
- def forward(self, x: torch.Tensor):
111
- d = x.shape[-1] // 2
112
- output_shape = x.shape[:-1] + (d,)
113
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
114
- ops.gelu_and_mul(out, x)
115
- return out
116
-
117
-
118
- class GeluTanhAndMul(nn.Module):
119
- can_torch_compile: bool = True
120
-
121
- def forward(self, x: torch.Tensor):
122
- d = x.shape[-1] // 2
123
- output_shape = x.shape[:-1] + (d,)
124
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
125
- ops.gelu_tanh_and_mul(out, x)
126
- return out
127
-
128
-
129
- class FatreluAndMul(nn.Module):
130
- """An activation function for FATReLU.
131
-
132
- The function computes x -> FATReLU(x[:d]) * x[d:] where
133
- d = x.shape[-1] // 2.
134
- This is used in openbmb/MiniCPM-S-1B-sft.
135
-
136
- Shapes:
137
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
138
- return: (num_tokens, d) or (batch_size, seq_len, d)
139
- """
140
-
141
- can_torch_compile: bool = True
142
-
143
- def __init__(self, threshold: float = 0.0):
144
- super().__init__()
145
- self.threshold = threshold
146
-
147
- def forward(self, x: torch.Tensor):
148
- d = x.shape[-1] // 2
149
- output_shape = x.shape[:-1] + (d,)
150
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
151
- ops.fatrelu_and_mul(out, x, self.threshold)
152
- return out
153
-
154
-
155
- class FastGELU(nn.Module):
156
- can_torch_compile: bool = True
157
-
158
- def forward(self, x: torch.Tensor) -> torch.Tensor:
159
- out = torch.empty_like(x)
160
- ops.gelu_fast(out, x)
161
- return out
162
-
163
-
164
- class NewGELU(nn.Module):
165
- can_torch_compile: bool = True
166
-
167
- def forward(self, x: torch.Tensor) -> torch.Tensor:
168
- out = torch.empty_like(x)
169
- ops.gelu_new(out, x)
170
- return out
171
-
172
-
173
- class QuickGELU(nn.Module):
174
- can_torch_compile: bool = True
175
-
176
- def forward(self, x: torch.Tensor) -> torch.Tensor:
177
- out = torch.empty_like(x)
178
- ops.gelu_quick(out, x)
179
- return out
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/torch27-cxx11-cu126-x86_64-linux/activation/__init__.py DELETED
@@ -1,75 +0,0 @@
1
- import torch
2
-
3
- from ._ops import ops
4
-
5
- from . import layers
6
-
7
-
8
- def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
9
- ops.silu_and_mul(out, x)
10
- return out
11
-
12
-
13
- def mul_and_silu(out: torch.Tensor, x: torch.Tensor) -> None:
14
- ops.mul_and_silu(out, x)
15
- return out
16
-
17
-
18
- def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
19
- ops.gelu_and_mul(out, x)
20
- return out
21
-
22
-
23
- def gelu_tanh_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
24
- ops.gelu_tanh_and_mul(out, x)
25
- return out
26
-
27
-
28
- def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0) -> None:
29
- ops.fatrelu_and_mul(out, x, threshold)
30
- return out
31
-
32
-
33
- def gelu(out: torch.Tensor, x: torch.Tensor) -> None:
34
- ops.gelu(out, x)
35
- return out
36
-
37
- def silu(out: torch.Tensor, x: torch.Tensor) -> None:
38
- ops.silu(out, x)
39
- return out
40
-
41
-
42
- def gelu_tanh(out: torch.Tensor, x: torch.Tensor) -> None:
43
- ops.gelu_tanh(out, x)
44
- return out
45
-
46
-
47
- def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> None:
48
- ops.gelu_fast(out, x)
49
- return out
50
-
51
-
52
- def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
53
- ops.gelu_new(out, x)
54
- return out
55
-
56
-
57
- def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
58
- ops.gelu_quick(out, x)
59
- return out
60
-
61
-
62
- __all__ = [
63
- "silu_and_mul",
64
- "mul_and_silu",
65
- "gelu_and_mul",
66
- "gelu_tanh_and_mul",
67
- "fatrelu_and_mul",
68
- "gelu_fast",
69
- "gelu_new",
70
- "gelu_quick",
71
- "gelu_tanh",
72
- "silu",
73
- "gelu",
74
- "layers",
75
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/torch27-cxx11-cu126-x86_64-linux/activation/__pycache__/__init__.cpython-313.pyc DELETED
Binary file (3.25 kB)
 
build/torch27-cxx11-cu126-x86_64-linux/activation/__pycache__/_ops.cpython-313.pyc DELETED
Binary file (526 Bytes)
 
build/torch27-cxx11-cu126-x86_64-linux/activation/__pycache__/layers.cpython-313.pyc DELETED
Binary file (8.92 kB)
 
build/torch27-cxx11-cu126-x86_64-linux/activation/_activation_beeaae6.abi3.so DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:a529bd105aca5081398d63329e829b6b159570424cd654d3a9f275ca9a720e82
3
- size 2852200
 
 
 
 
build/torch27-cxx11-cu126-x86_64-linux/activation/_ops.py DELETED
@@ -1,9 +0,0 @@
1
- import torch
2
- from . import _activation_beeaae6
3
- ops = torch.ops._activation_beeaae6
4
-
5
- def add_op_namespace_prefix(op_name: str):
6
- """
7
- Prefix op by namespace.
8
- """
9
- return f"_activation_beeaae6::{op_name}"
 
 
 
 
 
 
 
 
 
 
build/torch27-cxx11-cu126-x86_64-linux/activation/layers.py DELETED
@@ -1,179 +0,0 @@
1
- import torch
2
- import torch.nn as nn
3
-
4
- from ._ops import ops
5
-
6
-
7
- class SiluAndMul(nn.Module):
8
- """An activation function for SwiGLU.
9
-
10
- The function computes x -> silu(x[:d]) * x[d:] where d = x.shape[-1] // 2.
11
-
12
- Shapes:
13
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
14
- return: (num_tokens, d) or (batch_size, seq_len, d)
15
- """
16
-
17
- can_torch_compile: bool = True
18
-
19
- def forward(self, x: torch.Tensor):
20
- d = x.shape[-1] // 2
21
- output_shape = x.shape[:-1] + (d,)
22
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
23
- ops.silu_and_mul(out, x)
24
- return out
25
-
26
- class Silu(nn.Module):
27
- """An activation function for SiLU.
28
-
29
- The function computes x -> silu(x).
30
-
31
- Shapes:
32
- x: (num_tokens, d) or (batch_size, seq_len, d)
33
- return: (num_tokens, d) or (batch_size, seq_len, d)
34
- """
35
-
36
- can_torch_compile: bool = True
37
-
38
- def forward(self, x: torch.Tensor):
39
- out = torch.empty_like(x)
40
- ops.silu(out, x)
41
- return out
42
-
43
- class Gelu(nn.Module):
44
- """An activation function for GELU.
45
-
46
- The function computes x -> gelu(x).
47
-
48
- Shapes:
49
- x: (num_tokens, d) or (batch_size, seq_len, d)
50
- return: (num_tokens, d) or (batch_size, seq_len, d)
51
- """
52
-
53
- can_torch_compile: bool = True
54
-
55
- def forward(self, x: torch.Tensor):
56
- out = torch.empty_like(x)
57
- ops.gelu(out, x)
58
- return out
59
-
60
- class GeluTanh(nn.Module):
61
- """An activation function for GELU with `tanh` approximation.
62
-
63
- The function computes x -> gelu_tanh(x).
64
-
65
- Shapes:
66
- x: (num_tokens, d) or (batch_size, seq_len, d)
67
- return: (num_tokens, d) or (batch_size, seq_len, d)
68
- """
69
-
70
- can_torch_compile: bool = True
71
-
72
- def forward(self, x: torch.Tensor):
73
- out = torch.empty_like(x)
74
- ops.gelu_tanh(out, x)
75
- return out
76
-
77
-
78
- class MulAndSilu(nn.Module):
79
- """An activation function for SwiGLU.
80
-
81
- The function computes x -> x[:d] * silu(x[d:]) where d = x.shape[-1] // 2.
82
-
83
- Shapes:
84
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
85
- return: (num_tokens, d) or (batch_size, seq_len, d)
86
- """
87
-
88
- can_torch_compile: bool = True
89
-
90
- def forward(self, x: torch.Tensor) -> torch.Tensor:
91
- d = x.shape[-1] // 2
92
- output_shape = x.shape[:-1] + (d,)
93
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
94
- ops.mul_and_silu(out, x)
95
- return out
96
-
97
-
98
- class GeluAndMul(nn.Module):
99
- """An activation function for GeGLU.
100
-
101
- The function computes x -> GELU(x[:d]) * x[d:] where d = x.shape[-1] // 2.
102
-
103
- Shapes:
104
- x: (batch_size, seq_len, 2 * d) or (num_tokens, 2 * d)
105
- return: (batch_size, seq_len, d) or (num_tokens, d)
106
- """
107
-
108
- can_torch_compile: bool = True
109
-
110
- def forward(self, x: torch.Tensor):
111
- d = x.shape[-1] // 2
112
- output_shape = x.shape[:-1] + (d,)
113
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
114
- ops.gelu_and_mul(out, x)
115
- return out
116
-
117
-
118
- class GeluTanhAndMul(nn.Module):
119
- can_torch_compile: bool = True
120
-
121
- def forward(self, x: torch.Tensor):
122
- d = x.shape[-1] // 2
123
- output_shape = x.shape[:-1] + (d,)
124
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
125
- ops.gelu_tanh_and_mul(out, x)
126
- return out
127
-
128
-
129
- class FatreluAndMul(nn.Module):
130
- """An activation function for FATReLU.
131
-
132
- The function computes x -> FATReLU(x[:d]) * x[d:] where
133
- d = x.shape[-1] // 2.
134
- This is used in openbmb/MiniCPM-S-1B-sft.
135
-
136
- Shapes:
137
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
138
- return: (num_tokens, d) or (batch_size, seq_len, d)
139
- """
140
-
141
- can_torch_compile: bool = True
142
-
143
- def __init__(self, threshold: float = 0.0):
144
- super().__init__()
145
- self.threshold = threshold
146
-
147
- def forward(self, x: torch.Tensor):
148
- d = x.shape[-1] // 2
149
- output_shape = x.shape[:-1] + (d,)
150
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
151
- ops.fatrelu_and_mul(out, x, self.threshold)
152
- return out
153
-
154
-
155
- class FastGELU(nn.Module):
156
- can_torch_compile: bool = True
157
-
158
- def forward(self, x: torch.Tensor) -> torch.Tensor:
159
- out = torch.empty_like(x)
160
- ops.gelu_fast(out, x)
161
- return out
162
-
163
-
164
- class NewGELU(nn.Module):
165
- can_torch_compile: bool = True
166
-
167
- def forward(self, x: torch.Tensor) -> torch.Tensor:
168
- out = torch.empty_like(x)
169
- ops.gelu_new(out, x)
170
- return out
171
-
172
-
173
- class QuickGELU(nn.Module):
174
- can_torch_compile: bool = True
175
-
176
- def forward(self, x: torch.Tensor) -> torch.Tensor:
177
- out = torch.empty_like(x)
178
- ops.gelu_quick(out, x)
179
- return out
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/torch27-cxx11-cu128-aarch64-linux/activation/__init__.py DELETED
@@ -1,75 +0,0 @@
1
- import torch
2
-
3
- from ._ops import ops
4
-
5
- from . import layers
6
-
7
-
8
- def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
9
- ops.silu_and_mul(out, x)
10
- return out
11
-
12
-
13
- def mul_and_silu(out: torch.Tensor, x: torch.Tensor) -> None:
14
- ops.mul_and_silu(out, x)
15
- return out
16
-
17
-
18
- def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
19
- ops.gelu_and_mul(out, x)
20
- return out
21
-
22
-
23
- def gelu_tanh_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
24
- ops.gelu_tanh_and_mul(out, x)
25
- return out
26
-
27
-
28
- def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0) -> None:
29
- ops.fatrelu_and_mul(out, x, threshold)
30
- return out
31
-
32
-
33
- def gelu(out: torch.Tensor, x: torch.Tensor) -> None:
34
- ops.gelu(out, x)
35
- return out
36
-
37
- def silu(out: torch.Tensor, x: torch.Tensor) -> None:
38
- ops.silu(out, x)
39
- return out
40
-
41
-
42
- def gelu_tanh(out: torch.Tensor, x: torch.Tensor) -> None:
43
- ops.gelu_tanh(out, x)
44
- return out
45
-
46
-
47
- def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> None:
48
- ops.gelu_fast(out, x)
49
- return out
50
-
51
-
52
- def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
53
- ops.gelu_new(out, x)
54
- return out
55
-
56
-
57
- def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
58
- ops.gelu_quick(out, x)
59
- return out
60
-
61
-
62
- __all__ = [
63
- "silu_and_mul",
64
- "mul_and_silu",
65
- "gelu_and_mul",
66
- "gelu_tanh_and_mul",
67
- "fatrelu_and_mul",
68
- "gelu_fast",
69
- "gelu_new",
70
- "gelu_quick",
71
- "gelu_tanh",
72
- "silu",
73
- "gelu",
74
- "layers",
75
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/torch27-cxx11-cu128-aarch64-linux/activation/__pycache__/__init__.cpython-313.pyc DELETED
Binary file (3.25 kB)
 
build/torch27-cxx11-cu128-aarch64-linux/activation/__pycache__/_ops.cpython-313.pyc DELETED
Binary file (527 Bytes)
 
build/torch27-cxx11-cu128-aarch64-linux/activation/__pycache__/layers.cpython-313.pyc DELETED
Binary file (8.92 kB)
 
build/torch27-cxx11-cu128-aarch64-linux/activation/_activation_320b408.abi3.so DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:34bdeb9ab72686850aef0a16b225b1b956162edb2cf46cba65c5e5b92ae267ae
3
- size 4207000
 
 
 
 
build/torch27-cxx11-cu128-aarch64-linux/activation/_ops.py DELETED
@@ -1,9 +0,0 @@
1
- import torch
2
- from . import _activation_320b408
3
- ops = torch.ops._activation_320b408
4
-
5
- def add_op_namespace_prefix(op_name: str):
6
- """
7
- Prefix op by namespace.
8
- """
9
- return f"_activation_320b408::{op_name}"
 
 
 
 
 
 
 
 
 
 
build/torch27-cxx11-cu128-aarch64-linux/activation/layers.py DELETED
@@ -1,179 +0,0 @@
1
- import torch
2
- import torch.nn as nn
3
-
4
- from ._ops import ops
5
-
6
-
7
- class SiluAndMul(nn.Module):
8
- """An activation function for SwiGLU.
9
-
10
- The function computes x -> silu(x[:d]) * x[d:] where d = x.shape[-1] // 2.
11
-
12
- Shapes:
13
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
14
- return: (num_tokens, d) or (batch_size, seq_len, d)
15
- """
16
-
17
- can_torch_compile: bool = True
18
-
19
- def forward(self, x: torch.Tensor):
20
- d = x.shape[-1] // 2
21
- output_shape = x.shape[:-1] + (d,)
22
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
23
- ops.silu_and_mul(out, x)
24
- return out
25
-
26
- class Silu(nn.Module):
27
- """An activation function for SiLU.
28
-
29
- The function computes x -> silu(x).
30
-
31
- Shapes:
32
- x: (num_tokens, d) or (batch_size, seq_len, d)
33
- return: (num_tokens, d) or (batch_size, seq_len, d)
34
- """
35
-
36
- can_torch_compile: bool = True
37
-
38
- def forward(self, x: torch.Tensor):
39
- out = torch.empty_like(x)
40
- ops.silu(out, x)
41
- return out
42
-
43
- class Gelu(nn.Module):
44
- """An activation function for GELU.
45
-
46
- The function computes x -> gelu(x).
47
-
48
- Shapes:
49
- x: (num_tokens, d) or (batch_size, seq_len, d)
50
- return: (num_tokens, d) or (batch_size, seq_len, d)
51
- """
52
-
53
- can_torch_compile: bool = True
54
-
55
- def forward(self, x: torch.Tensor):
56
- out = torch.empty_like(x)
57
- ops.gelu(out, x)
58
- return out
59
-
60
- class GeluTanh(nn.Module):
61
- """An activation function for GELU with `tanh` approximation.
62
-
63
- The function computes x -> gelu_tanh(x).
64
-
65
- Shapes:
66
- x: (num_tokens, d) or (batch_size, seq_len, d)
67
- return: (num_tokens, d) or (batch_size, seq_len, d)
68
- """
69
-
70
- can_torch_compile: bool = True
71
-
72
- def forward(self, x: torch.Tensor):
73
- out = torch.empty_like(x)
74
- ops.gelu_tanh(out, x)
75
- return out
76
-
77
-
78
- class MulAndSilu(nn.Module):
79
- """An activation function for SwiGLU.
80
-
81
- The function computes x -> x[:d] * silu(x[d:]) where d = x.shape[-1] // 2.
82
-
83
- Shapes:
84
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
85
- return: (num_tokens, d) or (batch_size, seq_len, d)
86
- """
87
-
88
- can_torch_compile: bool = True
89
-
90
- def forward(self, x: torch.Tensor) -> torch.Tensor:
91
- d = x.shape[-1] // 2
92
- output_shape = x.shape[:-1] + (d,)
93
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
94
- ops.mul_and_silu(out, x)
95
- return out
96
-
97
-
98
- class GeluAndMul(nn.Module):
99
- """An activation function for GeGLU.
100
-
101
- The function computes x -> GELU(x[:d]) * x[d:] where d = x.shape[-1] // 2.
102
-
103
- Shapes:
104
- x: (batch_size, seq_len, 2 * d) or (num_tokens, 2 * d)
105
- return: (batch_size, seq_len, d) or (num_tokens, d)
106
- """
107
-
108
- can_torch_compile: bool = True
109
-
110
- def forward(self, x: torch.Tensor):
111
- d = x.shape[-1] // 2
112
- output_shape = x.shape[:-1] + (d,)
113
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
114
- ops.gelu_and_mul(out, x)
115
- return out
116
-
117
-
118
- class GeluTanhAndMul(nn.Module):
119
- can_torch_compile: bool = True
120
-
121
- def forward(self, x: torch.Tensor):
122
- d = x.shape[-1] // 2
123
- output_shape = x.shape[:-1] + (d,)
124
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
125
- ops.gelu_tanh_and_mul(out, x)
126
- return out
127
-
128
-
129
- class FatreluAndMul(nn.Module):
130
- """An activation function for FATReLU.
131
-
132
- The function computes x -> FATReLU(x[:d]) * x[d:] where
133
- d = x.shape[-1] // 2.
134
- This is used in openbmb/MiniCPM-S-1B-sft.
135
-
136
- Shapes:
137
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
138
- return: (num_tokens, d) or (batch_size, seq_len, d)
139
- """
140
-
141
- can_torch_compile: bool = True
142
-
143
- def __init__(self, threshold: float = 0.0):
144
- super().__init__()
145
- self.threshold = threshold
146
-
147
- def forward(self, x: torch.Tensor):
148
- d = x.shape[-1] // 2
149
- output_shape = x.shape[:-1] + (d,)
150
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
151
- ops.fatrelu_and_mul(out, x, self.threshold)
152
- return out
153
-
154
-
155
- class FastGELU(nn.Module):
156
- can_torch_compile: bool = True
157
-
158
- def forward(self, x: torch.Tensor) -> torch.Tensor:
159
- out = torch.empty_like(x)
160
- ops.gelu_fast(out, x)
161
- return out
162
-
163
-
164
- class NewGELU(nn.Module):
165
- can_torch_compile: bool = True
166
-
167
- def forward(self, x: torch.Tensor) -> torch.Tensor:
168
- out = torch.empty_like(x)
169
- ops.gelu_new(out, x)
170
- return out
171
-
172
-
173
- class QuickGELU(nn.Module):
174
- can_torch_compile: bool = True
175
-
176
- def forward(self, x: torch.Tensor) -> torch.Tensor:
177
- out = torch.empty_like(x)
178
- ops.gelu_quick(out, x)
179
- return out
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/torch27-cxx11-cu128-x86_64-linux/activation/__init__.py DELETED
@@ -1,75 +0,0 @@
1
- import torch
2
-
3
- from ._ops import ops
4
-
5
- from . import layers
6
-
7
-
8
- def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
9
- ops.silu_and_mul(out, x)
10
- return out
11
-
12
-
13
- def mul_and_silu(out: torch.Tensor, x: torch.Tensor) -> None:
14
- ops.mul_and_silu(out, x)
15
- return out
16
-
17
-
18
- def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
19
- ops.gelu_and_mul(out, x)
20
- return out
21
-
22
-
23
- def gelu_tanh_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
24
- ops.gelu_tanh_and_mul(out, x)
25
- return out
26
-
27
-
28
- def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0) -> None:
29
- ops.fatrelu_and_mul(out, x, threshold)
30
- return out
31
-
32
-
33
- def gelu(out: torch.Tensor, x: torch.Tensor) -> None:
34
- ops.gelu(out, x)
35
- return out
36
-
37
- def silu(out: torch.Tensor, x: torch.Tensor) -> None:
38
- ops.silu(out, x)
39
- return out
40
-
41
-
42
- def gelu_tanh(out: torch.Tensor, x: torch.Tensor) -> None:
43
- ops.gelu_tanh(out, x)
44
- return out
45
-
46
-
47
- def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> None:
48
- ops.gelu_fast(out, x)
49
- return out
50
-
51
-
52
- def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
53
- ops.gelu_new(out, x)
54
- return out
55
-
56
-
57
- def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
58
- ops.gelu_quick(out, x)
59
- return out
60
-
61
-
62
- __all__ = [
63
- "silu_and_mul",
64
- "mul_and_silu",
65
- "gelu_and_mul",
66
- "gelu_tanh_and_mul",
67
- "fatrelu_and_mul",
68
- "gelu_fast",
69
- "gelu_new",
70
- "gelu_quick",
71
- "gelu_tanh",
72
- "silu",
73
- "gelu",
74
- "layers",
75
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/torch27-cxx11-cu128-x86_64-linux/activation/__pycache__/__init__.cpython-313.pyc DELETED
Binary file (3.25 kB)
 
build/torch27-cxx11-cu128-x86_64-linux/activation/__pycache__/_ops.cpython-313.pyc DELETED
Binary file (526 Bytes)
 
build/torch27-cxx11-cu128-x86_64-linux/activation/__pycache__/layers.cpython-313.pyc DELETED
Binary file (8.92 kB)
 
build/torch27-cxx11-cu128-x86_64-linux/activation/_activation_beeaae6.abi3.so DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:0f2cffcb6b5b9a49f03a2df46fc2ad36765676edecb468c233e78e1f5e21e206
3
- size 4127872
 
 
 
 
build/torch27-cxx11-cu128-x86_64-linux/activation/_ops.py DELETED
@@ -1,9 +0,0 @@
1
- import torch
2
- from . import _activation_beeaae6
3
- ops = torch.ops._activation_beeaae6
4
-
5
- def add_op_namespace_prefix(op_name: str):
6
- """
7
- Prefix op by namespace.
8
- """
9
- return f"_activation_beeaae6::{op_name}"
 
 
 
 
 
 
 
 
 
 
build/torch27-cxx11-cu128-x86_64-linux/activation/layers.py DELETED
@@ -1,179 +0,0 @@
1
- import torch
2
- import torch.nn as nn
3
-
4
- from ._ops import ops
5
-
6
-
7
- class SiluAndMul(nn.Module):
8
- """An activation function for SwiGLU.
9
-
10
- The function computes x -> silu(x[:d]) * x[d:] where d = x.shape[-1] // 2.
11
-
12
- Shapes:
13
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
14
- return: (num_tokens, d) or (batch_size, seq_len, d)
15
- """
16
-
17
- can_torch_compile: bool = True
18
-
19
- def forward(self, x: torch.Tensor):
20
- d = x.shape[-1] // 2
21
- output_shape = x.shape[:-1] + (d,)
22
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
23
- ops.silu_and_mul(out, x)
24
- return out
25
-
26
- class Silu(nn.Module):
27
- """An activation function for SiLU.
28
-
29
- The function computes x -> silu(x).
30
-
31
- Shapes:
32
- x: (num_tokens, d) or (batch_size, seq_len, d)
33
- return: (num_tokens, d) or (batch_size, seq_len, d)
34
- """
35
-
36
- can_torch_compile: bool = True
37
-
38
- def forward(self, x: torch.Tensor):
39
- out = torch.empty_like(x)
40
- ops.silu(out, x)
41
- return out
42
-
43
- class Gelu(nn.Module):
44
- """An activation function for GELU.
45
-
46
- The function computes x -> gelu(x).
47
-
48
- Shapes:
49
- x: (num_tokens, d) or (batch_size, seq_len, d)
50
- return: (num_tokens, d) or (batch_size, seq_len, d)
51
- """
52
-
53
- can_torch_compile: bool = True
54
-
55
- def forward(self, x: torch.Tensor):
56
- out = torch.empty_like(x)
57
- ops.gelu(out, x)
58
- return out
59
-
60
- class GeluTanh(nn.Module):
61
- """An activation function for GELU with `tanh` approximation.
62
-
63
- The function computes x -> gelu_tanh(x).
64
-
65
- Shapes:
66
- x: (num_tokens, d) or (batch_size, seq_len, d)
67
- return: (num_tokens, d) or (batch_size, seq_len, d)
68
- """
69
-
70
- can_torch_compile: bool = True
71
-
72
- def forward(self, x: torch.Tensor):
73
- out = torch.empty_like(x)
74
- ops.gelu_tanh(out, x)
75
- return out
76
-
77
-
78
- class MulAndSilu(nn.Module):
79
- """An activation function for SwiGLU.
80
-
81
- The function computes x -> x[:d] * silu(x[d:]) where d = x.shape[-1] // 2.
82
-
83
- Shapes:
84
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
85
- return: (num_tokens, d) or (batch_size, seq_len, d)
86
- """
87
-
88
- can_torch_compile: bool = True
89
-
90
- def forward(self, x: torch.Tensor) -> torch.Tensor:
91
- d = x.shape[-1] // 2
92
- output_shape = x.shape[:-1] + (d,)
93
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
94
- ops.mul_and_silu(out, x)
95
- return out
96
-
97
-
98
- class GeluAndMul(nn.Module):
99
- """An activation function for GeGLU.
100
-
101
- The function computes x -> GELU(x[:d]) * x[d:] where d = x.shape[-1] // 2.
102
-
103
- Shapes:
104
- x: (batch_size, seq_len, 2 * d) or (num_tokens, 2 * d)
105
- return: (batch_size, seq_len, d) or (num_tokens, d)
106
- """
107
-
108
- can_torch_compile: bool = True
109
-
110
- def forward(self, x: torch.Tensor):
111
- d = x.shape[-1] // 2
112
- output_shape = x.shape[:-1] + (d,)
113
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
114
- ops.gelu_and_mul(out, x)
115
- return out
116
-
117
-
118
- class GeluTanhAndMul(nn.Module):
119
- can_torch_compile: bool = True
120
-
121
- def forward(self, x: torch.Tensor):
122
- d = x.shape[-1] // 2
123
- output_shape = x.shape[:-1] + (d,)
124
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
125
- ops.gelu_tanh_and_mul(out, x)
126
- return out
127
-
128
-
129
- class FatreluAndMul(nn.Module):
130
- """An activation function for FATReLU.
131
-
132
- The function computes x -> FATReLU(x[:d]) * x[d:] where
133
- d = x.shape[-1] // 2.
134
- This is used in openbmb/MiniCPM-S-1B-sft.
135
-
136
- Shapes:
137
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
138
- return: (num_tokens, d) or (batch_size, seq_len, d)
139
- """
140
-
141
- can_torch_compile: bool = True
142
-
143
- def __init__(self, threshold: float = 0.0):
144
- super().__init__()
145
- self.threshold = threshold
146
-
147
- def forward(self, x: torch.Tensor):
148
- d = x.shape[-1] // 2
149
- output_shape = x.shape[:-1] + (d,)
150
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
151
- ops.fatrelu_and_mul(out, x, self.threshold)
152
- return out
153
-
154
-
155
- class FastGELU(nn.Module):
156
- can_torch_compile: bool = True
157
-
158
- def forward(self, x: torch.Tensor) -> torch.Tensor:
159
- out = torch.empty_like(x)
160
- ops.gelu_fast(out, x)
161
- return out
162
-
163
-
164
- class NewGELU(nn.Module):
165
- can_torch_compile: bool = True
166
-
167
- def forward(self, x: torch.Tensor) -> torch.Tensor:
168
- out = torch.empty_like(x)
169
- ops.gelu_new(out, x)
170
- return out
171
-
172
-
173
- class QuickGELU(nn.Module):
174
- can_torch_compile: bool = True
175
-
176
- def forward(self, x: torch.Tensor) -> torch.Tensor:
177
- out = torch.empty_like(x)
178
- ops.gelu_quick(out, x)
179
- return out
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/torch28-cxx11-cu126-aarch64-linux/activation/__init__.py DELETED
@@ -1,57 +0,0 @@
1
- import torch
2
-
3
- from ._ops import ops
4
-
5
- from . import layers
6
-
7
-
8
- def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
9
- ops.silu_and_mul(out, x)
10
- return out
11
-
12
-
13
- def mul_and_silu(out: torch.Tensor, x: torch.Tensor) -> None:
14
- ops.mul_and_silu(out, x)
15
- return out
16
-
17
-
18
- def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
19
- ops.gelu_and_mul(out, x)
20
- return out
21
-
22
-
23
- def gelu_tanh_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
24
- ops.gelu_tanh_and_mul(out, x)
25
- return out
26
-
27
-
28
- def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0) -> None:
29
- ops.fatrelu_and_mul(out, x, threshold)
30
- return out
31
-
32
-
33
- def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> None:
34
- ops.gelu_fast(out, x)
35
- return out
36
-
37
-
38
- def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
39
- ops.gelu_new(out, x)
40
- return out
41
-
42
-
43
- def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
44
- ops.gelu_quick(out, x)
45
- return out
46
-
47
-
48
- __all__ = [
49
- "silu_and_mul",
50
- "gelu_and_mul",
51
- "gelu_tanh_and_mul",
52
- "fatrelu_and_mul",
53
- "gelu_fast",
54
- "gelu_new",
55
- "gelu_quick",
56
- "layers",
57
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/torch28-cxx11-cu126-aarch64-linux/activation/__pycache__/__init__.cpython-313.pyc DELETED
Binary file (2.5 kB)
 
build/torch28-cxx11-cu126-aarch64-linux/activation/__pycache__/_ops.cpython-313.pyc DELETED
Binary file (539 Bytes)
 
build/torch28-cxx11-cu126-aarch64-linux/activation/__pycache__/layers.cpython-313.pyc DELETED
Binary file (6.92 kB)
 
build/torch28-cxx11-cu126-aarch64-linux/activation/_activation_0c3eb4e_dirty.abi3.so DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:02b62f5d045f370c3fb7c0e7ef458165feb987fba186b8cb9aee55c735a82e93
3
- size 2699928
 
 
 
 
build/torch28-cxx11-cu126-aarch64-linux/activation/_ops.py DELETED
@@ -1,9 +0,0 @@
1
- import torch
2
- from . import _activation_0c3eb4e_dirty
3
- ops = torch.ops._activation_0c3eb4e_dirty
4
-
5
- def add_op_namespace_prefix(op_name: str):
6
- """
7
- Prefix op by namespace.
8
- """
9
- return f"_activation_0c3eb4e_dirty::{op_name}"
 
 
 
 
 
 
 
 
 
 
build/torch28-cxx11-cu126-aarch64-linux/activation/layers.py DELETED
@@ -1,128 +0,0 @@
1
- import torch
2
- import torch.nn as nn
3
-
4
- from ._ops import ops
5
-
6
-
7
- class SiluAndMul(nn.Module):
8
- """An activation function for SwiGLU.
9
-
10
- The function computes x -> silu(x[:d]) * x[d:] where d = x.shape[-1] // 2.
11
-
12
- Shapes:
13
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
14
- return: (num_tokens, d) or (batch_size, seq_len, d)
15
- """
16
-
17
- can_torch_compile: bool = True
18
-
19
- def forward(self, x: torch.Tensor):
20
- d = x.shape[-1] // 2
21
- output_shape = x.shape[:-1] + (d,)
22
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
23
- ops.silu_and_mul(out, x)
24
- return out
25
-
26
-
27
- class MulAndSilu(nn.Module):
28
- """An activation function for SwiGLU.
29
-
30
- The function computes x -> x[:d] * silu(x[d:]) where d = x.shape[-1] // 2.
31
-
32
- Shapes:
33
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
34
- return: (num_tokens, d) or (batch_size, seq_len, d)
35
- """
36
-
37
- can_torch_compile: bool = True
38
-
39
- def forward(self, x: torch.Tensor) -> torch.Tensor:
40
- d = x.shape[-1] // 2
41
- output_shape = x.shape[:-1] + (d,)
42
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
43
- ops.mul_and_silu(out, x)
44
- return out
45
-
46
-
47
- class GeluAndMul(nn.Module):
48
- """An activation function for GeGLU.
49
-
50
- The function computes x -> GELU(x[:d]) * x[d:] where d = x.shape[-1] // 2.
51
-
52
- Shapes:
53
- x: (batch_size, seq_len, 2 * d) or (num_tokens, 2 * d)
54
- return: (batch_size, seq_len, d) or (num_tokens, d)
55
- """
56
-
57
- can_torch_compile: bool = True
58
-
59
- def forward(self, x: torch.Tensor):
60
- d = x.shape[-1] // 2
61
- output_shape = x.shape[:-1] + (d,)
62
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
63
- ops.gelu_and_mul(out, x)
64
- return out
65
-
66
-
67
- class GeluTanhAndMul(nn.Module):
68
- can_torch_compile: bool = True
69
-
70
- def forward(self, x: torch.Tensor):
71
- d = x.shape[-1] // 2
72
- output_shape = x.shape[:-1] + (d,)
73
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
74
- ops.gelu_tanh_and_mul(out, x)
75
- return out
76
-
77
-
78
- class FatreluAndMul(nn.Module):
79
- """An activation function for FATReLU.
80
-
81
- The function computes x -> FATReLU(x[:d]) * x[d:] where
82
- d = x.shape[-1] // 2.
83
- This is used in openbmb/MiniCPM-S-1B-sft.
84
-
85
- Shapes:
86
- x: (num_tokens, 2 * d) or (batch_size, seq_len, 2 * d)
87
- return: (num_tokens, d) or (batch_size, seq_len, d)
88
- """
89
-
90
- can_torch_compile: bool = True
91
-
92
- def __init__(self, threshold: float = 0.0):
93
- super().__init__()
94
- self.threshold = threshold
95
-
96
- def forward(self, x: torch.Tensor):
97
- d = x.shape[-1] // 2
98
- output_shape = x.shape[:-1] + (d,)
99
- out = torch.empty(output_shape, dtype=x.dtype, device=x.device)
100
- ops.fatrelu_and_mul(out, x, self.threshold)
101
- return out
102
-
103
-
104
- class FastGELU(nn.Module):
105
- can_torch_compile: bool = True
106
-
107
- def forward(self, x: torch.Tensor) -> torch.Tensor:
108
- out = torch.empty_like(x)
109
- ops.gelu_fast(out, x)
110
- return out
111
-
112
-
113
- class NewGELU(nn.Module):
114
- can_torch_compile: bool = True
115
-
116
- def forward(self, x: torch.Tensor) -> torch.Tensor:
117
- out = torch.empty_like(x)
118
- ops.gelu_new(out, x)
119
- return out
120
-
121
-
122
- class QuickGELU(nn.Module):
123
- can_torch_compile: bool = True
124
-
125
- def forward(self, x: torch.Tensor) -> torch.Tensor:
126
- out = torch.empty_like(x)
127
- ops.gelu_quick(out, x)
128
- return out
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/torch28-cxx11-cu126-x86_64-linux/__init__.py DELETED
@@ -1,75 +0,0 @@
1
- import torch
2
-
3
- from ._ops import ops
4
-
5
- from . import layers
6
-
7
-
8
- def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
9
- ops.silu_and_mul(out, x)
10
- return out
11
-
12
-
13
- def mul_and_silu(out: torch.Tensor, x: torch.Tensor) -> None:
14
- ops.mul_and_silu(out, x)
15
- return out
16
-
17
-
18
- def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
19
- ops.gelu_and_mul(out, x)
20
- return out
21
-
22
-
23
- def gelu_tanh_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
24
- ops.gelu_tanh_and_mul(out, x)
25
- return out
26
-
27
-
28
- def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0) -> None:
29
- ops.fatrelu_and_mul(out, x, threshold)
30
- return out
31
-
32
-
33
- def gelu(out: torch.Tensor, x: torch.Tensor) -> None:
34
- ops.gelu(out, x)
35
- return out
36
-
37
- def silu(out: torch.Tensor, x: torch.Tensor) -> None:
38
- ops.silu(out, x)
39
- return out
40
-
41
-
42
- def gelu_tanh(out: torch.Tensor, x: torch.Tensor) -> None:
43
- ops.gelu_tanh(out, x)
44
- return out
45
-
46
-
47
- def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> None:
48
- ops.gelu_fast(out, x)
49
- return out
50
-
51
-
52
- def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
53
- ops.gelu_new(out, x)
54
- return out
55
-
56
-
57
- def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
58
- ops.gelu_quick(out, x)
59
- return out
60
-
61
-
62
- __all__ = [
63
- "silu_and_mul",
64
- "mul_and_silu",
65
- "gelu_and_mul",
66
- "gelu_tanh_and_mul",
67
- "fatrelu_and_mul",
68
- "gelu_fast",
69
- "gelu_new",
70
- "gelu_quick",
71
- "gelu_tanh",
72
- "silu",
73
- "gelu",
74
- "layers",
75
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/torch28-cxx11-cu126-x86_64-linux/_activation_f8d6759.abi3.so DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:cf76431ff46ef5bc002ce8813eeed3ae9618a15094d98ef4b164f7a10a54f0bc
3
- size 3121056
 
 
 
 
build/torch28-cxx11-cu126-x86_64-linux/_ops.py DELETED
@@ -1,9 +0,0 @@
1
- import torch
2
- from . import _activation_f8d6759
3
- ops = torch.ops._activation_f8d6759
4
-
5
- def add_op_namespace_prefix(op_name: str):
6
- """
7
- Prefix op by namespace.
8
- """
9
- return f"_activation_f8d6759::{op_name}"
 
 
 
 
 
 
 
 
 
 
build/torch28-cxx11-cu126-x86_64-linux/activation/__init__.py DELETED
@@ -1,26 +0,0 @@
1
- import ctypes
2
- import sys
3
-
4
- import importlib
5
- from pathlib import Path
6
- from types import ModuleType
7
-
8
- def _import_from_path(file_path: Path) -> ModuleType:
9
- # We cannot use the module name as-is, after adding it to `sys.modules`,
10
- # it would also be used for other imports. So, we make a module name that
11
- # depends on the path for it to be unique using the hex-encoded hash of
12
- # the path.
13
- path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
14
- module_name = path_hash
15
- spec = importlib.util.spec_from_file_location(module_name, file_path)
16
- if spec is None:
17
- raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
18
- module = importlib.util.module_from_spec(spec)
19
- if module is None:
20
- raise ImportError(f"Cannot load module {module_name} from spec")
21
- sys.modules[module_name] = module
22
- spec.loader.exec_module(module) # type: ignore
23
- return module
24
-
25
-
26
- globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))