Skip to content

Commit af240fc

Browse files
Merge pull request #274 from mananroongta/manan/agent_ppo_trainer
Fix : Prevent KeyError in _pad_dataproto_to_world_size
2 parents bd57a54 + d03af69 commit af240fc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

rllm/trainer/verl/agent_ppo_trainer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,8 +1040,10 @@ def _pad_dataproto_to_world_size(self, batch):
10401040
# for the padded dataproto, make the traj mask to 0. is_last_step also False
10411041
for i in range(pad_size):
10421042
idx = original_batch_size + i
1043-
batch.non_tensor_batch["is_last_step"][idx] = False
1044-
batch.non_tensor_batch["is_pad_step"][idx] = True
1043+
if "is_last_step" in batch.non_tensor_batch:
1044+
batch.non_tensor_batch["is_last_step"][idx] = False
1045+
if "is_pad_step" in batch.non_tensor_batch:
1046+
batch.non_tensor_batch["is_pad_step"][idx] = True
10451047

10461048
return batch
10471049

0 commit comments

Comments
 (0)