Skip to content
Merged
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
481 changes: 481 additions & 0 deletions benchmarks/benchmark_stateless_executor.py

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion rl_engine/executors/deepspeed_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
RolloutStageResult,
TorchRLTrainingConfig,
TrainingStageResult,
objective_reference_logps,
)
from rl_engine.testing import (
compute_policy_ratio,
Expand Down Expand Up @@ -113,7 +114,7 @@ def train(self, rollout: RolloutStageResult) -> TrainingStageResult:
output_dtype=torch.float32,
)
old_logps = current_logps.detach() - 0.01
ref_logps = current_logps.detach() - 0.02
ref_logps = objective_reference_logps(current_logps, batch)
ratio = compute_policy_ratio(current_logps, old_logps, batch.completion_mask)
unclipped = ratio * batch.advantages.float()
clipped = torch.clamp(ratio, 0.8, 1.2) * batch.advantages.float()
Expand All @@ -133,6 +134,7 @@ def train(self, rollout: RolloutStageResult) -> TrainingStageResult:

finished_at = time.perf_counter()
published = self._next_published_weight_version(rollout.weight_version)
active_advantages = batch.advantages.float()[batch.completion_mask]
return TrainingStageResult(
iteration=rollout.iteration,
consumed_weight_version=rollout.weight_version,
Expand All @@ -145,6 +147,16 @@ def train(self, rollout: RolloutStageResult) -> TrainingStageResult:
"training_device": str(self.device),
"deepspeed_engine": type(self.engine).__name__,
"deepspeed_zero_stage": self.config.zero_stage,
"active_advantage_mean_global": (
float(active_advantages.mean().detach().cpu().item())
if active_advantages.numel()
else 0.0
),
"active_advantage_std_global": (
float(active_advantages.std(unbiased=False).detach().cpu().item())
if active_advantages.numel()
else 0.0
),
**payload_metrics,
},
started_at=started_at,
Expand Down
Loading
Loading