Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/openaccel-lab/blob/main/workloads/dequant_int4/triton_kernel.py # openaccel-lab aien-dev/openaccel-lab Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers 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 2 import triton 3 import triton.language as tl 4 5 6 @triton.jit 7 def _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 18 def 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"]))