interplane.Get Omega
Read in your language

openaccel-lab

aien-dev/openaccel-lab

Brought by drakestapleton

branch main Branches Tags History

openaccel-lab / workloads / dequant_int4 / triton_kernel.py

19 lines · 638 bytes Raw Blame History
1# SPDX-License-Identifier: Apache-2.0
2import triton
3import triton.language as tl
4
5
6@triton.jit
7def _dequant_int4(w, s, y, C, G, NB, BC: tl.constexpr):
8 r = tl.program_id(0)
9 c = tl.arange(0, BC)
10 live = c < C
11 b = tl.load(w + r * NB + c // 2, mask=live, other=0).to(tl.int32)
12 nib = tl.where((c % 2) == 1, b >> 4, b & 15)
13 nib = tl.where(nib >= 8, nib - 16, nib)
14 sc = tl.load(s + r * G + c // 32, mask=live, other=0.0)
15 tl.store(y + r * C + c, nib.to(tl.float32) * sc, mask=live)
16
17
18def launch(p, t):
19 _dequant_int4[(p["R"],)](t["w"], t["s"], t["y"], p["C"], p["G"], p["NB"], BC=triton.next_power_of_2(p["C"]))