pub struct GroupRelativeEstimator;Expand description
Group-Relative Policy Optimisation advantage estimator.
Normalises rewards within each group: z = (r - mean) / std.
Returns zeros when std < 1e-8 (constant-reward group).
This is the canonical GRPO implementation matching the math in the original
rlox-core/src/llm/ops.rs — extracted here so rlox-sandbox can depend on
this slim crate instead of all of rlox-core.
Trait Implementations§
Source§impl AdvantageEstimator for GroupRelativeEstimator
impl AdvantageEstimator for GroupRelativeEstimator
Source§fn compute(
&self,
rewards: &[f32],
group_size: usize,
) -> Result<Vec<f32>, RlOpsError>
fn compute( &self, rewards: &[f32], group_size: usize, ) -> Result<Vec<f32>, RlOpsError>
Compute per-rollout z-score normalised advantages.
rewards must be a flat slice of length n_groups * group_size.
Groups are contiguous: rewards[0..group_size] is group 0, etc.
Uses rayon parallel dispatch when rewards.len() >= 4096 elements.
Auto Trait Implementations§
impl Freeze for GroupRelativeEstimator
impl RefUnwindSafe for GroupRelativeEstimator
impl Send for GroupRelativeEstimator
impl Sync for GroupRelativeEstimator
impl Unpin for GroupRelativeEstimator
impl UnsafeUnpin for GroupRelativeEstimator
impl UnwindSafe for GroupRelativeEstimator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more