[Triton] Migrate Triton kernels off tl.make_block_ptr for triton-main compat (#60502)

Signed-off-by: Nick Riasanovsky <njriasan@meta.com>
This commit is contained in:
Nick Riasanovsky
2026-10-12 11:38:43 -04:00
committed by GitHub
parent ffec221276
commit a686c8e1b7
16 changed files with 836 additions and 1515 deletions
@@ -165,15 +165,23 @@ def _inkling_rel_attention_kernel(
q_head_start = pid_kh * gqa_group_size
bt_row = block_table_ptr + pid_b * stride_bt_b
q_block_ptr = tl.make_block_ptr(
base=q_ptr + q_start * stride_q_t + q_head_start * stride_q_h,
shape=(q_len, gqa_group_size, head_dim),
strides=(stride_q_t, stride_q_h, stride_q_d),
offsets=(q_block, 0, 0),
block_shape=(BLOCK_Q, BLOCK_H, BLOCK_D),
order=(2, 1, 0),
o0 = q_block + tl.arange(0, BLOCK_Q)
o1 = tl.arange(0, BLOCK_H)
o2 = tl.arange(0, BLOCK_D)
m_q = (
(o0 < q_len)[:, None, None]
& (o1 < gqa_group_size)[None, :, None]
& (o2 < head_dim)[None, None, :]
)
q = tl.load(q_block_ptr, boundary_check=(0, 1, 2), padding_option="zero")
q_block_ptr = (
q_ptr
+ q_start * stride_q_t
+ q_head_start * stride_q_h
+ o0[:, None, None] * stride_q_t
+ o1[None, :, None] * stride_q_h
+ o2[None, None, :] * stride_q_d
)
q = tl.load(q_block_ptr, mask=m_q, other=0.0)
q = tl.reshape(q, (BLOCK_QH, BLOCK_D))
q_rows = q_block + tl.arange(0, BLOCK_Q)
@@ -265,18 +273,18 @@ def _inkling_rel_attention_kernel(
acc /= l_i[:, None]
acc = tl.reshape(acc, (BLOCK_Q, BLOCK_H, BLOCK_D))
out_block_ptr = tl.make_block_ptr(
base=out_ptr + q_start * stride_o_t + q_head_start * stride_o_h,
shape=(q_len, gqa_group_size, head_dim),
strides=(stride_o_t, stride_o_h, stride_o_d),
offsets=(q_block, 0, 0),
block_shape=(BLOCK_Q, BLOCK_H, BLOCK_D),
order=(2, 1, 0),
out_block_ptr = (
out_ptr
+ q_start * stride_o_t
+ q_head_start * stride_o_h
+ o0[:, None, None] * stride_o_t
+ o1[None, :, None] * stride_o_h
+ o2[None, None, :] * stride_o_d
)
tl.store(
out_block_ptr,
acc.to(out_ptr.dtype.element_ty),
boundary_check=(0, 1, 2),
mask=m_q,
)