Run this model with HF Jobs
Run replicate/aiter-kernels on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/replicate/aiter-kernels. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/replicate/aiter-kernels on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
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/_triton_kernels/common/splitk_reduce.py from replicate/aiter-kernels: direct link, hf CLI and curl.
- Browser
- Download file 2.41 kB
-
https://huggingface.co/replicate/aiter-kernels/resolve/main/build/torch-rocm/_triton_kernels/common/splitk_reduce.py
- Command line
-
hf download hf://replicate/aiter-kernels/build/torch-rocm/_triton_kernels/common/splitk_reduce.py
-
curl -L -o splitk_reduce.py https://huggingface.co/replicate/aiter-kernels/resolve/main/build/torch-rocm/_triton_kernels/common/splitk_reduce.py
2.41 kB
| import triton | |
| import triton.language as tl | |
| from ...utils._triton.kernel_repr import make_kernel_repr | |
| _gemm_splitk_reduce_repr = make_kernel_repr( | |
| "_gemm_splitk_reduce_kernel", | |
| [ | |
| "BLOCK_SIZE_M", | |
| "BLOCK_SIZE_N", | |
| "ACTUAL_KSPLIT", | |
| "MAX_KSPLIT", | |
| "ADD_BIAS", | |
| "activation", | |
| "use_activation", | |
| ], | |
| name_key="KERNEL_NAME", | |
| ) | |
| def _gemm_splitk_reduce_kernel( | |
| c_in_ptr, | |
| c_out_ptr, | |
| bias_ptr, | |
| M, | |
| N, | |
| stride_c_in_k, | |
| stride_c_in_m, | |
| stride_c_in_n, | |
| stride_c_out_m, | |
| stride_c_out_n, | |
| BLOCK_SIZE_M: tl.constexpr, | |
| BLOCK_SIZE_N: tl.constexpr, | |
| ACTUAL_KSPLIT: tl.constexpr, | |
| MAX_KSPLIT: tl.constexpr, | |
| ADD_BIAS: tl.constexpr, | |
| activation: tl.constexpr, | |
| use_activation: tl.constexpr, | |
| KERNEL_NAME: tl.constexpr = "_gemm_splitk_reduce_kernel", | |
| ): | |
| tl.assume(stride_c_in_k > 0) | |
| tl.assume(stride_c_in_m > 0) | |
| tl.assume(stride_c_in_n > 0) | |
| tl.assume(stride_c_out_m > 0) | |
| tl.assume(stride_c_out_n > 0) | |
| pid_m = tl.program_id(axis=0) | |
| pid_n = tl.program_id(axis=1) | |
| # Tell the AMD backend pid * stride stays non-negative so it can lower | |
| # the loads/stores to buffer ops instead of generic global ops. | |
| tl.assume(pid_m >= 0) | |
| tl.assume(pid_n >= 0) | |
| offs_m = (pid_m * BLOCK_SIZE_M + tl.arange(0, BLOCK_SIZE_M)) % M | |
| offs_n = (pid_n * BLOCK_SIZE_N + tl.arange(0, BLOCK_SIZE_N)) % N | |
| offs_k = tl.arange(0, MAX_KSPLIT) | |
| c_in_ptrs = ( | |
| c_in_ptr | |
| + (offs_k[:, None, None] * stride_c_in_k) | |
| + (offs_m[None, :, None] * stride_c_in_m) | |
| + (offs_n[None, None, :] * stride_c_in_n) | |
| ) | |
| if ACTUAL_KSPLIT == MAX_KSPLIT: | |
| c = tl.load(c_in_ptrs) | |
| else: | |
| c = tl.load(c_in_ptrs, mask=offs_k[:, None, None] < ACTUAL_KSPLIT, other=0.0) | |
| c = tl.sum(c, axis=0) | |
| if ADD_BIAS: | |
| acc_dtype = tl.float32 if c_in_ptr.type.element_ty != tl.int8 else tl.int32 | |
| bias = tl.load(bias_ptr + offs_n).to(dtype=acc_dtype) | |
| bias = tl.broadcast_to(bias[None, :], (BLOCK_SIZE_M, BLOCK_SIZE_N)) | |
| c += bias | |
| if use_activation: | |
| c = activation(c) | |
| c = c.to(c_out_ptr.type.element_ty) | |
| c_out_ptrs = ( | |
| c_out_ptr | |
| + (offs_m[:, None] * stride_c_out_m) | |
| + (offs_n[None, :] * stride_c_out_n) | |
| ) | |
| tl.store(c_out_ptrs, c) | |