Skip to content

[FEAT][kernels]: implement fused GRPO loss with in-place group reward normalization #46

Closed

Description

@Flink-ddd

Description:

Context:

For GRPO, computing the advantage requires calculating the mean and standard deviation of rewards within a specific generation group (responses corresponding to the same prompt) and then computing the policy gradient loss. Doing this in standard PyTorch involves excessive broadcasting, expanding, and memory allocation.

Tasks:

  1. Implement a fused CUDA/Triton kernel (grpo_loss.py) that accepts flat sequences, group boundary indices, and raw rewards.
  2. Perform group-wise reward normalization mean/std entirely within Shared Memory or fast registers without materializing intermediate broadcasted tensors.
  3. Compute the clipped surrogate objective and the KL penalty in the same kernel pass.
  4. Return the final scalar loss and the backward gradient for the policy logits.

Activity

  1. added
    component: kernels
    component: alignment
    type: performance
    on May 31, 2026
  2. KJLdefeated commented on Jun 8, 2026

    @KJLdefeated
    Collaborator

    I am interested in this issue and have idea about how to do it. Can I try to resolve this?

  3. Flink-ddd commented on Jun 8, 2026

    @Flink-ddd
    CollaboratorAuthor

    sure, Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

component: alignmentcomponent: kernelstype: performance

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions