Skip to content
DeepForgeby svx
All problems

Degenerate Group Handling

Problem

Handle a GRPO group whose rewards may carry no signal.

Return [degenerate, advantages], where the group is degenerate when it has fewer than two entries or all rewards are equal; degenerate groups get zero advantages, otherwise the advantages are the population z-scores.

Hint

A group with zero reward variance contributes no gradient, so it should be skipped.

Test cases

case 1
in: [[1,1,1]]
expected: [true,[0,0,0]]
case 2
in: [[1,2,3]]
expected: [false,[-1.224744871391589,0,1.224744871391589]]
case 3
in: [[5]]
expected: [true,[0]]
case 4
in: [[]]
expected: [true,[]]
Starter codePython
import math
def degenerate_group(rewards):
    # Your code here
    pass

4 test cases · run your code against them in the editor