Instructions to use ik6626/Qwen3.8-27B-HIP-kernel-RL with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use ik6626/Qwen3.8-27B-HIP-kernel-RL with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.8-27B") model = PeftModel.from_pretrained(base_model, "ik6626/Qwen3.8-27B-HIP-kernel-RL") - Notebooks
- Google Colab
- Kaggle
Download example/kernel.hip from ik6626/Qwen3.8-27B-HIP-kernel-RL: direct link, hf CLI and curl.
- Browser
- Download file 1.7 kB
-
https://huggingface.co/ik6626/Qwen3.8-27B-HIP-kernel-RL/resolve/main/example/kernel.hip
- Command line
-
hf download hf://ik6626/Qwen3.8-27B-HIP-kernel-RL/example/kernel.hip
-
curl -L -o kernel.hip https://huggingface.co/ik6626/Qwen3.8-27B-HIP-kernel-RL/resolve/main/example/kernel.hip
1.7 kB
| __global__ void fused_mse_eq_kernel(const float* __restrict__ x, | |
| const float* __restrict__ target, | |
| float* __restrict__ output, | |
| int n) { | |
| __shared__ float sdata[BLOCK_SIZE]; | |
| int tid = threadIdx.x; | |
| int global_id = blockIdx.x * blockDim.x + threadIdx.x; | |
| int stride = gridDim.x * blockDim.x; | |
| float local_sum = 0.0f; | |
| for (int i = global_id; i < n; i += stride) { | |
| float eq_val = (x[i] == target[i]) ? 1.0f : 0.0f; | |
| float diff = eq_val - target[i]; | |
| local_sum += diff * diff; | |
| } | |
| sdata[tid] = local_sum; | |
| __syncthreads(); | |
| for (int s = BLOCK_SIZE / 2; s > 0; s >>= 1) { | |
| if (tid < s) { | |
| sdata[tid] += sdata[tid + s]; | |
| } | |
| __syncthreads(); | |
| } | |
| if (tid == 0) { | |
| atomicAdd(output, sdata[0]); | |
| } | |
| } | |
| torch::Tensor forward(torch::Tensor x, torch::Tensor target) { | |
| auto stream = at::cuda::getCurrentCUDAStream(); | |
| int n = x.numel(); | |
| auto output = torch::zeros({1}, x.options()); | |
| int num_blocks = (n + BLOCK_SIZE - 1) / BLOCK_SIZE; | |
| if (num_blocks > 4096) num_blocks = 4096; | |
| fused_mse_eq_kernel<<<num_blocks, BLOCK_SIZE, 0, stream>>>( | |
| x.data_ptr<float>(), | |
| target.data_ptr<float>(), | |
| output.data_ptr<float>(), | |
| n | |
| ); | |
| auto result = output / static_cast<double>(n); | |
| return result.squeeze(); | |
| } | |
| PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { | |
| m.def("forward", &forward, "Fused MSE of element-wise equality"); | |
| } | |