Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/grpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import torch
import triton
from dlblas.kernel.grpo_compute_loss_logits import GRPO_Loss_Optimized, grpo_compute_loss_torch
from dlblas.kernels.grpo_compute_loss_logits import GRPO_Loss_Optimized, grpo_compute_loss_torch

def run_benchmark():

Expand Down
6 changes: 4 additions & 2 deletions dlblas/kernels/grpo_compute_loss_logits.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def grpo_kernel(
HAS_DELTA: tl.constexpr, # 使用编译时常量来处理delta的有无
):

pid = tl.program_id(axis=0)
# 行偏移用 64 位:pid * V 在 int32 下会回绕,BL * V 超过 2^31 后越界
pid = tl.program_id(axis=0).to(tl.int64)
mask = tl.load(mask_ptr + pid)
if mask == 0:
tl.store(loss_i_ptr + pid, 0.0)
Expand Down Expand Up @@ -205,7 +206,8 @@ def grpo_bwd_kernel(
BLOCK_SIZE_V: tl.constexpr,
HAS_DELTA: tl.constexpr,
):
pid = tl.program_id(axis=0)
# 行偏移用 64 位:pid * V 在 int32 下会回绕,BL * V 超过 2^31 后越界
pid = tl.program_id(axis=0).to(tl.int64)
mask = tl.load(mask_ptr + pid)
if mask == 0:
grad_ptr = grad_new_logits_ptr + pid * V
Expand Down