Update README.md
#1
by
lysandre
HF Staff
- opened
This view is limited to 50 files because it contains too many changes.
See the raw diff here.
- README.md +2 -8
- activation/activation_kernels.cu +204 -0
- activation/cuda_compat.h +49 -0
- activation/dispatch_utils.h +35 -0
- build.toml +17 -0
- build/{torch28-cxx11-cu126-aarch64-linux → torch25-cxx11-cu118-x86_64-linux}/activation/__init__.py +9 -19
- build/{torch27-cxx11-cu118-x86_64-linux/activation/_activation_beeaae6.abi3.so → torch25-cxx11-cu118-x86_64-linux/activation/_activation_o63kkyjirmkf4.abi3.so} +2 -2
- build/{torch27-cxx11-cu118-x86_64-linux → torch25-cxx11-cu118-x86_64-linux}/activation/_ops.py +3 -3
- build/{torch28-cxx11-cu128-aarch64-linux → torch25-cxx11-cu121-x86_64-linux}/activation/__init__.py +9 -19
- build/{torch27-cxx11-cu126-x86_64-linux/activation/_activation_beeaae6.abi3.so → torch25-cxx11-cu121-x86_64-linux/activation/_activation_vrl36m2ejer54.abi3.so} +2 -2
- build/{torch27-cxx11-cu126-x86_64-linux → torch25-cxx11-cu121-x86_64-linux}/activation/_ops.py +3 -3
- build/{torch27-cxx11-cu128-aarch64-linux → torch25-cxx11-cu124-x86_64-linux}/activation/__init__.py +9 -37
- build/{torch27-cxx11-cu128-aarch64-linux/activation/_activation_320b408.abi3.so → torch25-cxx11-cu124-x86_64-linux/activation/_activation_va3moa75vw7c2.abi3.so} +2 -2
- build/{torch27-cxx11-cu128-aarch64-linux → torch25-cxx11-cu124-x86_64-linux}/activation/_ops.py +3 -3
- build/{torch27-cxx11-cu128-x86_64-linux → torch25-cxx98-cu118-x86_64-linux}/activation/__init__.py +9 -37
- build/{torch27-cxx11-cu128-x86_64-linux/activation/_activation_beeaae6.abi3.so → torch25-cxx98-cu118-x86_64-linux/activation/_activation_qr3gs3eckeig4.abi3.so} +2 -2
- build/{torch27-cxx11-cu128-x86_64-linux → torch25-cxx98-cu118-x86_64-linux}/activation/_ops.py +3 -3
- build/torch25-cxx98-cu121-x86_64-linux/activation/__init__.py +47 -0
- build/torch25-cxx98-cu121-x86_64-linux/activation/_activation_p7gbzt25w3zg2.abi3.so +3 -0
- build/torch25-cxx98-cu121-x86_64-linux/activation/_ops.py +9 -0
- build/torch25-cxx98-cu124-x86_64-linux/activation/__init__.py +47 -0
- build/torch25-cxx98-cu124-x86_64-linux/activation/_activation_jg7yaigtn7wco.abi3.so +3 -0
- build/torch25-cxx98-cu124-x86_64-linux/activation/_ops.py +9 -0
- build/torch26-cxx11-cu118-x86_64-linux/activation/__init__.py +47 -0
- build/torch26-cxx11-cu118-x86_64-linux/activation/_activation_ncisyrun7guwk.abi3.so +3 -0
- build/torch26-cxx11-cu118-x86_64-linux/activation/_ops.py +9 -0
- build/torch26-cxx11-cu124-x86_64-linux/activation/__init__.py +47 -0
- build/torch26-cxx11-cu124-x86_64-linux/activation/_activation_ochhfvlnc3vyc.abi3.so +3 -0
- build/torch26-cxx11-cu124-x86_64-linux/activation/_ops.py +9 -0
- build/torch26-cxx11-cu126-x86_64-linux/activation/__init__.py +47 -0
- build/torch26-cxx11-cu126-x86_64-linux/activation/_activation_u6vnqubnicksq.abi3.so +3 -0
- build/torch26-cxx11-cu126-x86_64-linux/activation/_ops.py +9 -0
- build/torch26-cxx98-cu118-x86_64-linux/activation/__init__.py +47 -0
- build/torch26-cxx98-cu118-x86_64-linux/activation/_activation_2vn6ty3gfqfb6.abi3.so +3 -0
- build/torch26-cxx98-cu118-x86_64-linux/activation/_ops.py +9 -0
- build/torch26-cxx98-cu124-x86_64-linux/activation/__init__.py +47 -0
- build/torch26-cxx98-cu124-x86_64-linux/activation/_activation_myvteedxdpqc6.abi3.so +3 -0
- build/torch26-cxx98-cu124-x86_64-linux/activation/_ops.py +9 -0
- build/torch26-cxx98-cu126-x86_64-linux/activation/__init__.py +47 -0
- build/torch26-cxx98-cu126-x86_64-linux/activation/_activation_rbswus6emrhm2.abi3.so +3 -0
- build/torch26-cxx98-cu126-x86_64-linux/activation/_ops.py +9 -0
- build/torch27-cxx11-cu118-x86_64-linux/activation/__init__.py +0 -75
- build/torch27-cxx11-cu118-x86_64-linux/activation/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch27-cxx11-cu118-x86_64-linux/activation/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch27-cxx11-cu118-x86_64-linux/activation/__pycache__/layers.cpython-313.pyc +0 -0
- build/torch27-cxx11-cu118-x86_64-linux/activation/layers.py +0 -179
- build/torch27-cxx11-cu126-x86_64-linux/activation/__init__.py +0 -75
- build/torch27-cxx11-cu126-x86_64-linux/activation/__pycache__/__init__.cpython-313.pyc +0 -0
- build/torch27-cxx11-cu126-x86_64-linux/activation/__pycache__/_ops.cpython-313.pyc +0 -0
- build/torch27-cxx11-cu126-x86_64-linux/activation/__pycache__/layers.cpython-313.pyc +0 -0
README.md
CHANGED
|
@@ -1,13 +1,7 @@
|
|
| 1 |
---
|
| 2 |
tags:
|
| 3 |
-
|
| 4 |
---
|
| 5 |
-
|
| 6 |
-

|
| 7 |
-
|
| 8 |
## Activation
|
| 9 |
|
| 10 |
-
Activation kernels from [vLLM](https://github.com/vllm-project/vllm/blob/main/csrc/activation_kernels.cu).
|
| 11 |
-
|
| 12 |
-
Kernel source: https://github.com/huggingface/kernels-community/tree/main/activation
|
| 13 |
-
|
|
|
|
| 1 |
---
|
| 2 |
tags:
|
| 3 |
+
- kernel
|
| 4 |
---
|
|
|
|
|
|
|
|
|
|
| 5 |
## Activation
|
| 6 |
|
| 7 |
+
Activation kernels from [vLLM](https://github.com/vllm-project/vllm/blob/main/csrc/activation_kernels.cu).
|
|
|
|
|
|
|
|
|
activation/activation_kernels.cu
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <ATen/cuda/CUDAContext.h>
|
| 2 |
+
#include <torch/all.h>
|
| 3 |
+
#include <c10/cuda/CUDAGuard.h>
|
| 4 |
+
|
| 5 |
+
#include <cmath>
|
| 6 |
+
|
| 7 |
+
#include "cuda_compat.h"
|
| 8 |
+
#include "dispatch_utils.h"
|
| 9 |
+
|
| 10 |
+
namespace vllm {
|
| 11 |
+
|
| 12 |
+
// Activation and gating kernel template.
|
| 13 |
+
template <typename scalar_t, scalar_t (*ACT_FN)(const scalar_t&)>
|
| 14 |
+
__global__ void act_and_mul_kernel(
|
| 15 |
+
scalar_t* __restrict__ out, // [..., d]
|
| 16 |
+
const scalar_t* __restrict__ input, // [..., 2, d]
|
| 17 |
+
const int d) {
|
| 18 |
+
const int64_t token_idx = blockIdx.x;
|
| 19 |
+
for (int64_t idx = threadIdx.x; idx < d; idx += blockDim.x) {
|
| 20 |
+
const scalar_t x = VLLM_LDG(&input[token_idx * 2 * d + idx]);
|
| 21 |
+
const scalar_t y = VLLM_LDG(&input[token_idx * 2 * d + d + idx]);
|
| 22 |
+
out[token_idx * d + idx] = ACT_FN(x) * y;
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
template <typename T>
|
| 27 |
+
__device__ __forceinline__ T silu_kernel(const T& x) {
|
| 28 |
+
// x * sigmoid(x)
|
| 29 |
+
return (T)(((float)x) / (1.0f + expf((float)-x)));
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
template <typename T>
|
| 33 |
+
__device__ __forceinline__ T gelu_kernel(const T& x) {
|
| 34 |
+
// Equivalent to PyTorch GELU with 'none' approximation.
|
| 35 |
+
// Refer to:
|
| 36 |
+
// https://github.com/pytorch/pytorch/blob/8ac9b20d4b090c213799e81acf48a55ea8d437d6/aten/src/ATen/native/cuda/ActivationGeluKernel.cu#L36-L38
|
| 37 |
+
const float f = (float)x;
|
| 38 |
+
constexpr float ALPHA = M_SQRT1_2;
|
| 39 |
+
return (T)(f * 0.5f * (1.0f + ::erf(f * ALPHA)));
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
template <typename T>
|
| 43 |
+
__device__ __forceinline__ T gelu_tanh_kernel(const T& x) {
|
| 44 |
+
// Equivalent to PyTorch GELU with 'tanh' approximation.
|
| 45 |
+
// Refer to:
|
| 46 |
+
// https://github.com/pytorch/pytorch/blob/8ac9b20d4b090c213799e81acf48a55ea8d437d6/aten/src/ATen/native/cuda/ActivationGeluKernel.cu#L25-L30
|
| 47 |
+
const float f = (float)x;
|
| 48 |
+
constexpr float BETA = M_SQRT2 * M_2_SQRTPI * 0.5f;
|
| 49 |
+
constexpr float KAPPA = 0.044715;
|
| 50 |
+
float x_cube = f * f * f;
|
| 51 |
+
float inner = BETA * (f + KAPPA * x_cube);
|
| 52 |
+
return (T)(0.5f * f * (1.0f + ::tanhf(inner)));
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
} // namespace vllm
|
| 56 |
+
|
| 57 |
+
// Launch activation and gating kernel.
|
| 58 |
+
#define LAUNCH_ACTIVATION_GATE_KERNEL(KERNEL) \
|
| 59 |
+
int d = input.size(-1) / 2; \
|
| 60 |
+
int64_t num_tokens = input.numel() / input.size(-1); \
|
| 61 |
+
dim3 grid(num_tokens); \
|
| 62 |
+
dim3 block(std::min(d, 1024)); \
|
| 63 |
+
const at::cuda::OptionalCUDAGuard device_guard(device_of(input)); \
|
| 64 |
+
const cudaStream_t stream = at::cuda::getCurrentCUDAStream(); \
|
| 65 |
+
VLLM_DISPATCH_FLOATING_TYPES( \
|
| 66 |
+
input.scalar_type(), "act_and_mul_kernel", [&] { \
|
| 67 |
+
vllm::act_and_mul_kernel<scalar_t, KERNEL<scalar_t>> \
|
| 68 |
+
<<<grid, block, 0, stream>>>(out.data_ptr<scalar_t>(), \
|
| 69 |
+
input.data_ptr<scalar_t>(), d); \
|
| 70 |
+
});
|
| 71 |
+
|
| 72 |
+
void silu_and_mul(torch::Tensor& out, // [..., d]
|
| 73 |
+
torch::Tensor& input) // [..., 2 * d]
|
| 74 |
+
{
|
| 75 |
+
LAUNCH_ACTIVATION_GATE_KERNEL(vllm::silu_kernel);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
void gelu_and_mul(torch::Tensor& out, // [..., d]
|
| 79 |
+
torch::Tensor& input) // [..., 2 * d]
|
| 80 |
+
{
|
| 81 |
+
LAUNCH_ACTIVATION_GATE_KERNEL(vllm::gelu_kernel);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
void gelu_tanh_and_mul(torch::Tensor& out, // [..., d]
|
| 85 |
+
torch::Tensor& input) // [..., 2 * d]
|
| 86 |
+
{
|
| 87 |
+
LAUNCH_ACTIVATION_GATE_KERNEL(vllm::gelu_tanh_kernel);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
namespace vllm {
|
| 91 |
+
|
| 92 |
+
template <typename T>
|
| 93 |
+
__device__ __forceinline__ T fatrelu_kernel(const T& x, const float threshold) {
|
| 94 |
+
const float f = (float)x;
|
| 95 |
+
return (T)(f > threshold ? f : 0.0f);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
template <typename scalar_t, scalar_t (*ACT_FN)(const scalar_t&, const float)>
|
| 99 |
+
__global__ void act_and_mul_kernel_with_param(
|
| 100 |
+
scalar_t* __restrict__ out, const scalar_t* __restrict__ input, const int d,
|
| 101 |
+
const float param) {
|
| 102 |
+
const int64_t token_idx = blockIdx.x;
|
| 103 |
+
for (int64_t idx = threadIdx.x; idx < d; idx += blockDim.x) {
|
| 104 |
+
const scalar_t x = VLLM_LDG(&input[token_idx * 2 * d + idx]);
|
| 105 |
+
const scalar_t y = VLLM_LDG(&input[token_idx * 2 * d + d + idx]);
|
| 106 |
+
out[token_idx * d + idx] = ACT_FN(x, param) * y;
|
| 107 |
+
}
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
} // namespace vllm
|
| 111 |
+
|
| 112 |
+
#define LAUNCH_ACTIVATION_GATE_KERNEL_WITH_PARAM(KERNEL, PARAM) \
|
| 113 |
+
int d = input.size(-1) / 2; \
|
| 114 |
+
int64_t num_tokens = input.numel() / input.size(-1); \
|
| 115 |
+
dim3 grid(num_tokens); \
|
| 116 |
+
dim3 block(std::min(d, 1024)); \
|
| 117 |
+
const at::cuda::OptionalCUDAGuard device_guard(device_of(input)); \
|
| 118 |
+
const cudaStream_t stream = at::cuda::getCurrentCUDAStream(); \
|
| 119 |
+
VLLM_DISPATCH_FLOATING_TYPES( \
|
| 120 |
+
input.scalar_type(), "act_and_mul_kernel_with_param", [&] { \
|
| 121 |
+
vllm::act_and_mul_kernel_with_param<scalar_t, KERNEL<scalar_t>> \
|
| 122 |
+
<<<grid, block, 0, stream>>>(out.data_ptr<scalar_t>(), \
|
| 123 |
+
input.data_ptr<scalar_t>(), d, \
|
| 124 |
+
PARAM); \
|
| 125 |
+
});
|
| 126 |
+
|
| 127 |
+
void fatrelu_and_mul(torch::Tensor& out, // [..., d],
|
| 128 |
+
torch::Tensor& input, // [..., 2 * d]
|
| 129 |
+
double threshold) {
|
| 130 |
+
LAUNCH_ACTIVATION_GATE_KERNEL_WITH_PARAM(vllm::fatrelu_kernel, threshold);
|
| 131 |
+
}
|
| 132 |
+
namespace vllm {
|
| 133 |
+
|
| 134 |
+
// Element-wise activation kernel template.
|
| 135 |
+
template <typename scalar_t, scalar_t (*ACT_FN)(const scalar_t&)>
|
| 136 |
+
__global__ void activation_kernel(
|
| 137 |
+
scalar_t* __restrict__ out, // [..., d]
|
| 138 |
+
const scalar_t* __restrict__ input, // [..., d]
|
| 139 |
+
const int d) {
|
| 140 |
+
const int64_t token_idx = blockIdx.x;
|
| 141 |
+
for (int64_t idx = threadIdx.x; idx < d; idx += blockDim.x) {
|
| 142 |
+
const scalar_t x = VLLM_LDG(&input[token_idx * d + idx]);
|
| 143 |
+
out[token_idx * d + idx] = ACT_FN(x);
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
} // namespace vllm
|
| 148 |
+
|
| 149 |
+
// Launch element-wise activation kernel.
|
| 150 |
+
#define LAUNCH_ACTIVATION_KERNEL(KERNEL) \
|
| 151 |
+
int d = input.size(-1); \
|
| 152 |
+
int64_t num_tokens = input.numel() / d; \
|
| 153 |
+
dim3 grid(num_tokens); \
|
| 154 |
+
dim3 block(std::min(d, 1024)); \
|
| 155 |
+
const at::cuda::OptionalCUDAGuard device_guard(device_of(input)); \
|
| 156 |
+
const cudaStream_t stream = at::cuda::getCurrentCUDAStream(); \
|
| 157 |
+
VLLM_DISPATCH_FLOATING_TYPES(input.scalar_type(), "activation_kernel", [&] { \
|
| 158 |
+
vllm::activation_kernel<scalar_t, KERNEL<scalar_t>> \
|
| 159 |
+
<<<grid, block, 0, stream>>>(out.data_ptr<scalar_t>(), \
|
| 160 |
+
input.data_ptr<scalar_t>(), d); \
|
| 161 |
+
});
|
| 162 |
+
|
| 163 |
+
namespace vllm {
|
| 164 |
+
|
| 165 |
+
template <typename T>
|
| 166 |
+
__device__ __forceinline__ T gelu_new_kernel(const T& x) {
|
| 167 |
+
const float x3 = (float)(x * x * x);
|
| 168 |
+
const T t = (T)tanhf((T)(0.79788456f * (float)(x + (T)(0.044715f * x3))));
|
| 169 |
+
return ((T)0.5) * x * (((T)1.0) + t);
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
template <typename T>
|
| 173 |
+
__device__ __forceinline__ T gelu_fast_kernel(const T& x) {
|
| 174 |
+
const float f = (float)x;
|
| 175 |
+
const T t =
|
| 176 |
+
(T)tanhf(((T)(f * 0.79788456f)) * (((T)1.0) + (T)(0.044715f * f) * x));
|
| 177 |
+
return ((T)0.5) * x * (((T)1.0) + t);
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
template <typename T>
|
| 181 |
+
__device__ __forceinline__ T gelu_quick_kernel(const T& x) {
|
| 182 |
+
// x * sigmoid(1.702 * x)
|
| 183 |
+
return (T)(((float)x) / (1.0f + expf(-1.702f * (float)x)));
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
} // namespace vllm
|
| 187 |
+
|
| 188 |
+
void gelu_new(torch::Tensor& out, // [..., d]
|
| 189 |
+
torch::Tensor& input) // [..., d]
|
| 190 |
+
{
|
| 191 |
+
LAUNCH_ACTIVATION_KERNEL(vllm::gelu_new_kernel);
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
void gelu_fast(torch::Tensor& out, // [..., d]
|
| 195 |
+
torch::Tensor& input) // [..., d]
|
| 196 |
+
{
|
| 197 |
+
LAUNCH_ACTIVATION_KERNEL(vllm::gelu_fast_kernel);
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
void gelu_quick(torch::Tensor& out, // [..., d]
|
| 201 |
+
torch::Tensor& input) // [..., d]
|
| 202 |
+
{
|
| 203 |
+
LAUNCH_ACTIVATION_KERNEL(vllm::gelu_quick_kernel);
|
| 204 |
+
}
|
activation/cuda_compat.h
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
|
| 3 |
+
#ifdef USE_ROCM
|
| 4 |
+
#include <hip/hip_runtime.h>
|
| 5 |
+
#endif
|
| 6 |
+
|
| 7 |
+
#ifndef USE_ROCM
|
| 8 |
+
#define WARP_SIZE 32
|
| 9 |
+
#else
|
| 10 |
+
#define WARP_SIZE warpSize
|
| 11 |
+
#endif
|
| 12 |
+
|
| 13 |
+
#ifndef USE_ROCM
|
| 14 |
+
#define VLLM_LDG(arg) __ldg(arg)
|
| 15 |
+
#else
|
| 16 |
+
#define VLLM_LDG(arg) *(arg)
|
| 17 |
+
#endif
|
| 18 |
+
|
| 19 |
+
#ifndef USE_ROCM
|
| 20 |
+
#define VLLM_SHFL_XOR_SYNC(var, lane_mask) \
|
| 21 |
+
__shfl_xor_sync(uint32_t(-1), var, lane_mask)
|
| 22 |
+
#define VLLM_SHFL_XOR_SYNC_WIDTH(var, lane_mask, width) \
|
| 23 |
+
__shfl_xor_sync(uint32_t(-1), var, lane_mask, width)
|
| 24 |
+
#else
|
| 25 |
+
#define VLLM_SHFL_XOR_SYNC(var, lane_mask) __shfl_xor(var, lane_mask)
|
| 26 |
+
#define VLLM_SHFL_XOR_SYNC_WIDTH(var, lane_mask, width) \
|
| 27 |
+
__shfl_xor(var, lane_mask, width)
|
| 28 |
+
#endif
|
| 29 |
+
|
| 30 |
+
#ifndef USE_ROCM
|
| 31 |
+
#define VLLM_SHFL_SYNC(var, src_lane) __shfl_sync(uint32_t(-1), var, src_lane)
|
| 32 |
+
#else
|
| 33 |
+
#define VLLM_SHFL_SYNC(var, src_lane) __shfl(var, src_lane)
|
| 34 |
+
#endif
|
| 35 |
+
|
| 36 |
+
#ifndef USE_ROCM
|
| 37 |
+
#define VLLM_SHFL_DOWN_SYNC(var, lane_delta) \
|
| 38 |
+
__shfl_down_sync(uint32_t(-1), var, lane_delta)
|
| 39 |
+
#else
|
| 40 |
+
#define VLLM_SHFL_DOWN_SYNC(var, lane_delta) __shfl_down(var, lane_delta)
|
| 41 |
+
#endif
|
| 42 |
+
|
| 43 |
+
#ifndef USE_ROCM
|
| 44 |
+
#define VLLM_DevFuncAttribute_SET_MaxDynamicSharedMemorySize(FUNC, VAL) \
|
| 45 |
+
cudaFuncSetAttribute(FUNC, cudaFuncAttributeMaxDynamicSharedMemorySize, VAL)
|
| 46 |
+
#else
|
| 47 |
+
#define VLLM_DevFuncAttribute_SET_MaxDynamicSharedMemorySize(FUNC, VAL) \
|
| 48 |
+
hipFuncSetAttribute(FUNC, hipFuncAttributeMaxDynamicSharedMemorySize, VAL)
|
| 49 |
+
#endif
|
activation/dispatch_utils.h
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Adapted from
|
| 3 |
+
* https://github.com/pytorch/pytorch/blob/v2.0.1/aten/src/ATen/Dispatch.h
|
| 4 |
+
*/
|
| 5 |
+
#pragma once
|
| 6 |
+
|
| 7 |
+
#include <torch/all.h>
|
| 8 |
+
|
| 9 |
+
#define VLLM_DISPATCH_CASE_FLOATING_TYPES(...) \
|
| 10 |
+
AT_DISPATCH_CASE(at::ScalarType::Float, __VA_ARGS__) \
|
| 11 |
+
AT_DISPATCH_CASE(at::ScalarType::Half, __VA_ARGS__) \
|
| 12 |
+
AT_DISPATCH_CASE(at::ScalarType::BFloat16, __VA_ARGS__)
|
| 13 |
+
|
| 14 |
+
#define VLLM_DISPATCH_FLOATING_TYPES(TYPE, NAME, ...) \
|
| 15 |
+
AT_DISPATCH_SWITCH(TYPE, NAME, VLLM_DISPATCH_CASE_FLOATING_TYPES(__VA_ARGS__))
|
| 16 |
+
|
| 17 |
+
#define VLLM_DISPATCH_CASE_FLOATING_AND_BYTE_TYPES(...) \
|
| 18 |
+
AT_DISPATCH_CASE(at::ScalarType::Float, __VA_ARGS__) \
|
| 19 |
+
AT_DISPATCH_CASE(at::ScalarType::Half, __VA_ARGS__) \
|
| 20 |
+
AT_DISPATCH_CASE(at::ScalarType::BFloat16, __VA_ARGS__) \
|
| 21 |
+
AT_DISPATCH_CASE(at::ScalarType::Byte, __VA_ARGS__)
|
| 22 |
+
|
| 23 |
+
#define VLLM_DISPATCH_FLOATING_AND_BYTE_TYPES(TYPE, NAME, ...) \
|
| 24 |
+
AT_DISPATCH_SWITCH(TYPE, NAME, \
|
| 25 |
+
VLLM_DISPATCH_CASE_FLOATING_AND_BYTE_TYPES(__VA_ARGS__))
|
| 26 |
+
|
| 27 |
+
#define VLLM_DISPATCH_CASE_INTEGRAL_TYPES(...) \
|
| 28 |
+
AT_DISPATCH_CASE(at::ScalarType::Byte, __VA_ARGS__) \
|
| 29 |
+
AT_DISPATCH_CASE(at::ScalarType::Char, __VA_ARGS__) \
|
| 30 |
+
AT_DISPATCH_CASE(at::ScalarType::Short, __VA_ARGS__) \
|
| 31 |
+
AT_DISPATCH_CASE(at::ScalarType::Int, __VA_ARGS__) \
|
| 32 |
+
AT_DISPATCH_CASE(at::ScalarType::Long, __VA_ARGS__)
|
| 33 |
+
|
| 34 |
+
#define VLLM_DISPATCH_INTEGRAL_TYPES(TYPE, NAME, ...) \
|
| 35 |
+
AT_DISPATCH_SWITCH(TYPE, NAME, VLLM_DISPATCH_CASE_INTEGRAL_TYPES(__VA_ARGS__))
|
build.toml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[general]
|
| 2 |
+
name = "activation"
|
| 3 |
+
|
| 4 |
+
[torch]
|
| 5 |
+
src = [
|
| 6 |
+
"torch-ext/torch_binding.cpp",
|
| 7 |
+
"torch-ext/torch_binding.h"
|
| 8 |
+
]
|
| 9 |
+
|
| 10 |
+
[kernel.activation]
|
| 11 |
+
cuda-capabilities = [ "7.0", "7.2", "7.5", "8.0", "8.6", "8.7", "8.9", "9.0" ]
|
| 12 |
+
src = [
|
| 13 |
+
"activation/activation_kernels.cu",
|
| 14 |
+
"activation/cuda_compat.h",
|
| 15 |
+
"activation/dispatch_utils.h",
|
| 16 |
+
]
|
| 17 |
+
depends = [ "torch" ]
|
build/{torch28-cxx11-cu126-aarch64-linux → torch25-cxx11-cu118-x86_64-linux}/activation/__init__.py
RENAMED
|
@@ -1,8 +1,15 @@
|
|
| 1 |
import torch
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
|
@@ -10,11 +17,6 @@ def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
|
| 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
|
|
@@ -43,15 +45,3 @@ def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
|
|
| 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 |
-
]
|
|
|
|
| 1 |
import torch
|
| 2 |
|
| 3 |
+
try:
|
| 4 |
+
from ._ops import ops
|
| 5 |
+
except ImportError as e:
|
| 6 |
+
# Fallback for local development.
|
| 7 |
+
try:
|
| 8 |
+
import _activation
|
| 9 |
|
| 10 |
+
ops = torch.ops._activition
|
| 11 |
+
except ImportError:
|
| 12 |
+
raise e
|
| 13 |
|
| 14 |
|
| 15 |
def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
|
|
|
| 17 |
return out
|
| 18 |
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 21 |
ops.gelu_and_mul(out, x)
|
| 22 |
return out
|
|
|
|
| 45 |
def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 46 |
ops.gelu_quick(out, x)
|
| 47 |
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/{torch27-cxx11-cu118-x86_64-linux/activation/_activation_beeaae6.abi3.so → torch25-cxx11-cu118-x86_64-linux/activation/_activation_o63kkyjirmkf4.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:d50cdabfbed1df74e921ac34ff00bca0555977b14ef8082ddae7b1f30985a494
|
| 3 |
+
size 2370160
|
build/{torch27-cxx11-cu118-x86_64-linux → torch25-cxx11-cu118-x86_64-linux}/activation/_ops.py
RENAMED
|
@@ -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 _activation_o63kkyjirmkf4
|
| 3 |
+
ops = torch.ops._activation_o63kkyjirmkf4
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_activation_o63kkyjirmkf4::{op_name}"
|
build/{torch28-cxx11-cu128-aarch64-linux → torch25-cxx11-cu121-x86_64-linux}/activation/__init__.py
RENAMED
|
@@ -1,8 +1,15 @@
|
|
| 1 |
import torch
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
|
@@ -10,11 +17,6 @@ def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
|
| 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
|
|
@@ -43,15 +45,3 @@ def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
|
|
| 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 |
-
]
|
|
|
|
| 1 |
import torch
|
| 2 |
|
| 3 |
+
try:
|
| 4 |
+
from ._ops import ops
|
| 5 |
+
except ImportError as e:
|
| 6 |
+
# Fallback for local development.
|
| 7 |
+
try:
|
| 8 |
+
import _activation
|
| 9 |
|
| 10 |
+
ops = torch.ops._activition
|
| 11 |
+
except ImportError:
|
| 12 |
+
raise e
|
| 13 |
|
| 14 |
|
| 15 |
def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
|
|
|
| 17 |
return out
|
| 18 |
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 21 |
ops.gelu_and_mul(out, x)
|
| 22 |
return out
|
|
|
|
| 45 |
def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 46 |
ops.gelu_quick(out, x)
|
| 47 |
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/{torch27-cxx11-cu126-x86_64-linux/activation/_activation_beeaae6.abi3.so → torch25-cxx11-cu121-x86_64-linux/activation/_activation_vrl36m2ejer54.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:2bd0709ef09c8f0c18d1dc4a36c8096c59459bece61f5f5dbea95d1e73f54d44
|
| 3 |
+
size 2393264
|
build/{torch27-cxx11-cu126-x86_64-linux → torch25-cxx11-cu121-x86_64-linux}/activation/_ops.py
RENAMED
|
@@ -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 _activation_vrl36m2ejer54
|
| 3 |
+
ops = torch.ops._activation_vrl36m2ejer54
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_activation_vrl36m2ejer54::{op_name}"
|
build/{torch27-cxx11-cu128-aarch64-linux → torch25-cxx11-cu124-x86_64-linux}/activation/__init__.py
RENAMED
|
@@ -1,8 +1,15 @@
|
|
| 1 |
import torch
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
|
@@ -10,11 +17,6 @@ def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
|
| 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
|
|
@@ -30,20 +32,6 @@ def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0)
|
|
| 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
|
|
@@ -57,19 +45,3 @@ def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
|
|
| 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 |
-
]
|
|
|
|
| 1 |
import torch
|
| 2 |
|
| 3 |
+
try:
|
| 4 |
+
from ._ops import ops
|
| 5 |
+
except ImportError as e:
|
| 6 |
+
# Fallback for local development.
|
| 7 |
+
try:
|
| 8 |
+
import _activation
|
| 9 |
|
| 10 |
+
ops = torch.ops._activition
|
| 11 |
+
except ImportError:
|
| 12 |
+
raise e
|
| 13 |
|
| 14 |
|
| 15 |
def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
|
|
|
| 17 |
return out
|
| 18 |
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 21 |
ops.gelu_and_mul(out, x)
|
| 22 |
return out
|
|
|
|
| 32 |
return out
|
| 33 |
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 36 |
ops.gelu_fast(out, x)
|
| 37 |
return out
|
|
|
|
| 45 |
def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 46 |
ops.gelu_quick(out, x)
|
| 47 |
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/{torch27-cxx11-cu128-aarch64-linux/activation/_activation_320b408.abi3.so → torch25-cxx11-cu124-x86_64-linux/activation/_activation_va3moa75vw7c2.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:8353447f64e7d2df1a6a341d9c53bced53abef267f079923ae774170d0d57c53
|
| 3 |
+
size 2427936
|
build/{torch27-cxx11-cu128-aarch64-linux → torch25-cxx11-cu124-x86_64-linux}/activation/_ops.py
RENAMED
|
@@ -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 _activation_va3moa75vw7c2
|
| 3 |
+
ops = torch.ops._activation_va3moa75vw7c2
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_activation_va3moa75vw7c2::{op_name}"
|
build/{torch27-cxx11-cu128-x86_64-linux → torch25-cxx98-cu118-x86_64-linux}/activation/__init__.py
RENAMED
|
@@ -1,8 +1,15 @@
|
|
| 1 |
import torch
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
|
@@ -10,11 +17,6 @@ def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
|
| 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
|
|
@@ -30,20 +32,6 @@ def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0)
|
|
| 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
|
|
@@ -57,19 +45,3 @@ def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
|
|
| 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 |
-
]
|
|
|
|
| 1 |
import torch
|
| 2 |
|
| 3 |
+
try:
|
| 4 |
+
from ._ops import ops
|
| 5 |
+
except ImportError as e:
|
| 6 |
+
# Fallback for local development.
|
| 7 |
+
try:
|
| 8 |
+
import _activation
|
| 9 |
|
| 10 |
+
ops = torch.ops._activition
|
| 11 |
+
except ImportError:
|
| 12 |
+
raise e
|
| 13 |
|
| 14 |
|
| 15 |
def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
|
|
|
| 17 |
return out
|
| 18 |
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 21 |
ops.gelu_and_mul(out, x)
|
| 22 |
return out
|
|
|
|
| 32 |
return out
|
| 33 |
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 36 |
ops.gelu_fast(out, x)
|
| 37 |
return out
|
|
|
|
| 45 |
def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 46 |
ops.gelu_quick(out, x)
|
| 47 |
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build/{torch27-cxx11-cu128-x86_64-linux/activation/_activation_beeaae6.abi3.so → torch25-cxx98-cu118-x86_64-linux/activation/_activation_qr3gs3eckeig4.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:df184a6315118d787a1bd6b435cb45f1ca7828445a1f1c0e55c57645cfbba43a
|
| 3 |
+
size 2362600
|
build/{torch27-cxx11-cu128-x86_64-linux → torch25-cxx98-cu118-x86_64-linux}/activation/_ops.py
RENAMED
|
@@ -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 _activation_qr3gs3eckeig4
|
| 3 |
+
ops = torch.ops._activation_qr3gs3eckeig4
|
| 4 |
|
| 5 |
def add_op_namespace_prefix(op_name: str):
|
| 6 |
"""
|
| 7 |
Prefix op by namespace.
|
| 8 |
"""
|
| 9 |
+
return f"_activation_qr3gs3eckeig4::{op_name}"
|
build/torch25-cxx98-cu121-x86_64-linux/activation/__init__.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
|
| 3 |
+
try:
|
| 4 |
+
from ._ops import ops
|
| 5 |
+
except ImportError as e:
|
| 6 |
+
# Fallback for local development.
|
| 7 |
+
try:
|
| 8 |
+
import _activation
|
| 9 |
+
|
| 10 |
+
ops = torch.ops._activition
|
| 11 |
+
except ImportError:
|
| 12 |
+
raise e
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 16 |
+
ops.silu_and_mul(out, x)
|
| 17 |
+
return out
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 21 |
+
ops.gelu_and_mul(out, x)
|
| 22 |
+
return out
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def gelu_tanh_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 26 |
+
ops.gelu_tanh_and_mul(out, x)
|
| 27 |
+
return out
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0) -> None:
|
| 31 |
+
ops.fatrelu_and_mul(out, x, threshold)
|
| 32 |
+
return out
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 36 |
+
ops.gelu_fast(out, x)
|
| 37 |
+
return out
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 41 |
+
ops.gelu_new(out, x)
|
| 42 |
+
return out
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 46 |
+
ops.gelu_quick(out, x)
|
| 47 |
+
return out
|
build/torch25-cxx98-cu121-x86_64-linux/activation/_activation_p7gbzt25w3zg2.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ccb13cfc2e45cf483e8b9f77f1760f28b48bcf185508d51b32d45bc759c4e8bb
|
| 3 |
+
size 2385440
|
build/torch25-cxx98-cu121-x86_64-linux/activation/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _activation_p7gbzt25w3zg2
|
| 3 |
+
ops = torch.ops._activation_p7gbzt25w3zg2
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_activation_p7gbzt25w3zg2::{op_name}"
|
build/torch25-cxx98-cu124-x86_64-linux/activation/__init__.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
|
| 3 |
+
try:
|
| 4 |
+
from ._ops import ops
|
| 5 |
+
except ImportError as e:
|
| 6 |
+
# Fallback for local development.
|
| 7 |
+
try:
|
| 8 |
+
import _activation
|
| 9 |
+
|
| 10 |
+
ops = torch.ops._activition
|
| 11 |
+
except ImportError:
|
| 12 |
+
raise e
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 16 |
+
ops.silu_and_mul(out, x)
|
| 17 |
+
return out
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 21 |
+
ops.gelu_and_mul(out, x)
|
| 22 |
+
return out
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def gelu_tanh_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 26 |
+
ops.gelu_tanh_and_mul(out, x)
|
| 27 |
+
return out
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0) -> None:
|
| 31 |
+
ops.fatrelu_and_mul(out, x, threshold)
|
| 32 |
+
return out
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 36 |
+
ops.gelu_fast(out, x)
|
| 37 |
+
return out
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 41 |
+
ops.gelu_new(out, x)
|
| 42 |
+
return out
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 46 |
+
ops.gelu_quick(out, x)
|
| 47 |
+
return out
|
build/torch25-cxx98-cu124-x86_64-linux/activation/_activation_jg7yaigtn7wco.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4f8048853e8cb06e8574a9a9497800d2be438f7989d79f44dcf2e0ced38a75a9
|
| 3 |
+
size 2420192
|
build/torch25-cxx98-cu124-x86_64-linux/activation/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _activation_jg7yaigtn7wco
|
| 3 |
+
ops = torch.ops._activation_jg7yaigtn7wco
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_activation_jg7yaigtn7wco::{op_name}"
|
build/torch26-cxx11-cu118-x86_64-linux/activation/__init__.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
|
| 3 |
+
try:
|
| 4 |
+
from ._ops import ops
|
| 5 |
+
except ImportError as e:
|
| 6 |
+
# Fallback for local development.
|
| 7 |
+
try:
|
| 8 |
+
import _activation
|
| 9 |
+
|
| 10 |
+
ops = torch.ops._activition
|
| 11 |
+
except ImportError:
|
| 12 |
+
raise e
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 16 |
+
ops.silu_and_mul(out, x)
|
| 17 |
+
return out
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 21 |
+
ops.gelu_and_mul(out, x)
|
| 22 |
+
return out
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def gelu_tanh_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 26 |
+
ops.gelu_tanh_and_mul(out, x)
|
| 27 |
+
return out
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0) -> None:
|
| 31 |
+
ops.fatrelu_and_mul(out, x, threshold)
|
| 32 |
+
return out
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 36 |
+
ops.gelu_fast(out, x)
|
| 37 |
+
return out
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 41 |
+
ops.gelu_new(out, x)
|
| 42 |
+
return out
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 46 |
+
ops.gelu_quick(out, x)
|
| 47 |
+
return out
|
build/torch26-cxx11-cu118-x86_64-linux/activation/_activation_ncisyrun7guwk.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cde5439e78ba0e1aaa1937d798b214b46d38cbab8e4384b93a22239fed1a4dd4
|
| 3 |
+
size 2370264
|
build/torch26-cxx11-cu118-x86_64-linux/activation/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _activation_ncisyrun7guwk
|
| 3 |
+
ops = torch.ops._activation_ncisyrun7guwk
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_activation_ncisyrun7guwk::{op_name}"
|
build/torch26-cxx11-cu124-x86_64-linux/activation/__init__.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
|
| 3 |
+
try:
|
| 4 |
+
from ._ops import ops
|
| 5 |
+
except ImportError as e:
|
| 6 |
+
# Fallback for local development.
|
| 7 |
+
try:
|
| 8 |
+
import _activation
|
| 9 |
+
|
| 10 |
+
ops = torch.ops._activition
|
| 11 |
+
except ImportError:
|
| 12 |
+
raise e
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 16 |
+
ops.silu_and_mul(out, x)
|
| 17 |
+
return out
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 21 |
+
ops.gelu_and_mul(out, x)
|
| 22 |
+
return out
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def gelu_tanh_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 26 |
+
ops.gelu_tanh_and_mul(out, x)
|
| 27 |
+
return out
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0) -> None:
|
| 31 |
+
ops.fatrelu_and_mul(out, x, threshold)
|
| 32 |
+
return out
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 36 |
+
ops.gelu_fast(out, x)
|
| 37 |
+
return out
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 41 |
+
ops.gelu_new(out, x)
|
| 42 |
+
return out
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 46 |
+
ops.gelu_quick(out, x)
|
| 47 |
+
return out
|
build/torch26-cxx11-cu124-x86_64-linux/activation/_activation_ochhfvlnc3vyc.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f6bd20d411c51fc8729b15cab6a60c5c9185222474aa035489e1bff299d76682
|
| 3 |
+
size 2428040
|
build/torch26-cxx11-cu124-x86_64-linux/activation/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _activation_ochhfvlnc3vyc
|
| 3 |
+
ops = torch.ops._activation_ochhfvlnc3vyc
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_activation_ochhfvlnc3vyc::{op_name}"
|
build/torch26-cxx11-cu126-x86_64-linux/activation/__init__.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
|
| 3 |
+
try:
|
| 4 |
+
from ._ops import ops
|
| 5 |
+
except ImportError as e:
|
| 6 |
+
# Fallback for local development.
|
| 7 |
+
try:
|
| 8 |
+
import _activation
|
| 9 |
+
|
| 10 |
+
ops = torch.ops._activition
|
| 11 |
+
except ImportError:
|
| 12 |
+
raise e
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 16 |
+
ops.silu_and_mul(out, x)
|
| 17 |
+
return out
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 21 |
+
ops.gelu_and_mul(out, x)
|
| 22 |
+
return out
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def gelu_tanh_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 26 |
+
ops.gelu_tanh_and_mul(out, x)
|
| 27 |
+
return out
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0) -> None:
|
| 31 |
+
ops.fatrelu_and_mul(out, x, threshold)
|
| 32 |
+
return out
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 36 |
+
ops.gelu_fast(out, x)
|
| 37 |
+
return out
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 41 |
+
ops.gelu_new(out, x)
|
| 42 |
+
return out
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 46 |
+
ops.gelu_quick(out, x)
|
| 47 |
+
return out
|
build/torch26-cxx11-cu126-x86_64-linux/activation/_activation_u6vnqubnicksq.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:41c18b20c2bf8c49d2d3088a9bc1aad4293df0b57eafc9b141a9e8e595fe551a
|
| 3 |
+
size 2436672
|
build/torch26-cxx11-cu126-x86_64-linux/activation/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _activation_u6vnqubnicksq
|
| 3 |
+
ops = torch.ops._activation_u6vnqubnicksq
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_activation_u6vnqubnicksq::{op_name}"
|
build/torch26-cxx98-cu118-x86_64-linux/activation/__init__.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
|
| 3 |
+
try:
|
| 4 |
+
from ._ops import ops
|
| 5 |
+
except ImportError as e:
|
| 6 |
+
# Fallback for local development.
|
| 7 |
+
try:
|
| 8 |
+
import _activation
|
| 9 |
+
|
| 10 |
+
ops = torch.ops._activition
|
| 11 |
+
except ImportError:
|
| 12 |
+
raise e
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 16 |
+
ops.silu_and_mul(out, x)
|
| 17 |
+
return out
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 21 |
+
ops.gelu_and_mul(out, x)
|
| 22 |
+
return out
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def gelu_tanh_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 26 |
+
ops.gelu_tanh_and_mul(out, x)
|
| 27 |
+
return out
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0) -> None:
|
| 31 |
+
ops.fatrelu_and_mul(out, x, threshold)
|
| 32 |
+
return out
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 36 |
+
ops.gelu_fast(out, x)
|
| 37 |
+
return out
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 41 |
+
ops.gelu_new(out, x)
|
| 42 |
+
return out
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 46 |
+
ops.gelu_quick(out, x)
|
| 47 |
+
return out
|
build/torch26-cxx98-cu118-x86_64-linux/activation/_activation_2vn6ty3gfqfb6.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cfbcd5da358cd5cb7982d19c8880cf4db6f08b46622a7a953f755ad59e4e1492
|
| 3 |
+
size 2362752
|
build/torch26-cxx98-cu118-x86_64-linux/activation/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _activation_2vn6ty3gfqfb6
|
| 3 |
+
ops = torch.ops._activation_2vn6ty3gfqfb6
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_activation_2vn6ty3gfqfb6::{op_name}"
|
build/torch26-cxx98-cu124-x86_64-linux/activation/__init__.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
|
| 3 |
+
try:
|
| 4 |
+
from ._ops import ops
|
| 5 |
+
except ImportError as e:
|
| 6 |
+
# Fallback for local development.
|
| 7 |
+
try:
|
| 8 |
+
import _activation
|
| 9 |
+
|
| 10 |
+
ops = torch.ops._activition
|
| 11 |
+
except ImportError:
|
| 12 |
+
raise e
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 16 |
+
ops.silu_and_mul(out, x)
|
| 17 |
+
return out
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 21 |
+
ops.gelu_and_mul(out, x)
|
| 22 |
+
return out
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def gelu_tanh_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 26 |
+
ops.gelu_tanh_and_mul(out, x)
|
| 27 |
+
return out
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0) -> None:
|
| 31 |
+
ops.fatrelu_and_mul(out, x, threshold)
|
| 32 |
+
return out
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 36 |
+
ops.gelu_fast(out, x)
|
| 37 |
+
return out
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 41 |
+
ops.gelu_new(out, x)
|
| 42 |
+
return out
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 46 |
+
ops.gelu_quick(out, x)
|
| 47 |
+
return out
|
build/torch26-cxx98-cu124-x86_64-linux/activation/_activation_myvteedxdpqc6.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b1bc928823117c800904bcd3492bf1a0c65a32f6d8a842dc039f55e29831ab49
|
| 3 |
+
size 2420344
|
build/torch26-cxx98-cu124-x86_64-linux/activation/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _activation_myvteedxdpqc6
|
| 3 |
+
ops = torch.ops._activation_myvteedxdpqc6
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_activation_myvteedxdpqc6::{op_name}"
|
build/torch26-cxx98-cu126-x86_64-linux/activation/__init__.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
|
| 3 |
+
try:
|
| 4 |
+
from ._ops import ops
|
| 5 |
+
except ImportError as e:
|
| 6 |
+
# Fallback for local development.
|
| 7 |
+
try:
|
| 8 |
+
import _activation
|
| 9 |
+
|
| 10 |
+
ops = torch.ops._activition
|
| 11 |
+
except ImportError:
|
| 12 |
+
raise e
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def silu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 16 |
+
ops.silu_and_mul(out, x)
|
| 17 |
+
return out
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def gelu_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 21 |
+
ops.gelu_and_mul(out, x)
|
| 22 |
+
return out
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def gelu_tanh_and_mul(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 26 |
+
ops.gelu_tanh_and_mul(out, x)
|
| 27 |
+
return out
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def fatrelu_and_mul(out: torch.Tensor, x: torch.Tensor, threshold: float = 0.0) -> None:
|
| 31 |
+
ops.fatrelu_and_mul(out, x, threshold)
|
| 32 |
+
return out
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def gelu_fast(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 36 |
+
ops.gelu_fast(out, x)
|
| 37 |
+
return out
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def gelu_new(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 41 |
+
ops.gelu_new(out, x)
|
| 42 |
+
return out
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def gelu_quick(out: torch.Tensor, x: torch.Tensor) -> None:
|
| 46 |
+
ops.gelu_quick(out, x)
|
| 47 |
+
return out
|
build/torch26-cxx98-cu126-x86_64-linux/activation/_activation_rbswus6emrhm2.abi3.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:474727e434a9cd4ec984a6da7124992ead4ca0fefce9581d0fd503e36c065aed
|
| 3 |
+
size 2424888
|
build/torch26-cxx98-cu126-x86_64-linux/activation/_ops.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from . import _activation_rbswus6emrhm2
|
| 3 |
+
ops = torch.ops._activation_rbswus6emrhm2
|
| 4 |
+
|
| 5 |
+
def add_op_namespace_prefix(op_name: str):
|
| 6 |
+
"""
|
| 7 |
+
Prefix op by namespace.
|
| 8 |
+
"""
|
| 9 |
+
return f"_activation_rbswus6emrhm2::{op_name}"
|
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/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)
|
|
|