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/rope/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 / rope / triton_kernel.py` 23 lines ยท 730 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 _rope(x, cs, sn, y, H, h, BLOCK: tl.constexpr): 8 th = tl.program_id(0) # t*H + j 9 t = th // H 10 i = tl.arange(0, BLOCK) 11 m = i < h 12 o = th * 2 * h + i 13 c = tl.load(cs + t * h + i, mask=m, other=0.0) 14 s = tl.load(sn + t * h + i, mask=m, other=0.0) 15 x1 = tl.load(x + o, mask=m, other=0.0) 16 x2 = tl.load(x + o + h, mask=m, other=0.0) 17 tl.store(y + o, x1 * c - x2 * s, mask=m) 18 tl.store(y + o + h, x1 * s + x2 * c, mask=m) 19 20 21 def launch(p, t): 22 _rope[(p["T"] * p["H"],)](t["x"], t["cos"], t["sin"], t["y"], p["H"], p["h"], 23 BLOCK=triton.next_power_of_2(p["h"]))