Instructions to use replicate/aiter-kernels with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Kernels
How to use replicate/aiter-kernels with Kernels:
# !pip install kernels from kernels import get_kernel # a version (or an explicit revision) is required; see the "Files and versions" tab for the available ones kernel = get_kernel("replicate/aiter-kernels", version=1) - Notebooks
- Google Colab
- Kaggle
Download build/torch-rocm/utils/moe_common.py from replicate/aiter-kernels: direct link, hf CLI and curl.
- Browser
- Download file 640 Bytes
-
https://huggingface.co/replicate/aiter-kernels/resolve/main/build/torch-rocm/utils/moe_common.py
- Command line
-
hf download hf://replicate/aiter-kernels/build/torch-rocm/utils/moe_common.py
-
curl -L -o moe_common.py https://huggingface.co/replicate/aiter-kernels/resolve/main/build/torch-rocm/utils/moe_common.py
640 Bytes
| import triton | |
| import triton.language as tl | |
| import torch | |
| def torch_silu_and_mul_ref(input): | |
| """ | |
| Performs the SiLU activation on the first half of the input tensor and | |
| multiplies it element-wise with the second half. | |
| Args: | |
| input (torch.Tensor): Input tensor of shape [..., 2 * d]. | |
| param (float): Parameter for the SiLU activation function. | |
| Returns: | |
| torch.Tensor: Output tensor of shape [..., d]. | |
| """ | |
| dtype = input.dtype | |
| d = input.size(-1) // 2 | |
| A, B = input[:, :d], input[:, d:] | |
| silu_A = A / (1.0 + torch.exp(-A.float())) | |
| output = silu_A * B | |
| return output.to(dtype) | |