interplane.Get Omega
Read in your language

openaccel-lab

aien-dev/openaccel-lab

Brought by drakestapleton

branch main Branches Tags History

openaccel-lab / controls / dequant_int4_nosign / triton_kernel.py

19 lines · 658 bytes Raw Blame History
1# SPDX-License-Identifier: Apache-2.0
2# CONTROL dequant_int4_nosign: the nibble is not sign-extended.
3import triton
4import triton.language as tl
5
6
7@triton.jit
8def _dequant_int4(w, s, y, C, G, NB, BC: tl.constexpr):
9 r = tl.program_id(0)
10 c = tl.arange(0, BC)
11 live = c < C
12 b = tl.load(w + r * NB + c // 2, mask=live, other=0).to(tl.int32)
13 nib = tl.where((c % 2) == 1, b >> 4, b & 15)
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"]))