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
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def make_experience(
num_actions = 0

for inference_mini_batch_id in range(0, input_ids.size(0), self.inference_batch_size):
s, e = inference_mini_batch_id, (inference_mini_batch_id + 1) * self.inference_batch_size
s, e = inference_mini_batch_id, inference_mini_batch_id + self.inference_batch_size
if input_ids[s:e].size(0) == 0:
break
sequences = generate(self.actor, input_ids[s:e], self.tokenizer, **generate_kwargs)
Expand Down
2 changes: 1 addition & 1 deletion applications/ColossalChat/coati/trainer/dpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ def _criterion(outputs, inputs):
self.accumulative_meter.get("accuracy"),
global_step,
)
self.num_train_step += 1
self.accumulative_meter.reset()
self.num_train_step += 1

if self.save_dir is not None and self.num_train_step > 0 and self.num_train_step % self.save_interval == 0:
# save checkpoint
Expand Down
4 changes: 2 additions & 2 deletions applications/ColossalChat/coati/trainer/grpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ def _training_step(self, experience: Experience):
experience:
sequences: [batch_size, prompt_length + response_length] --- <PAD>...<PAD><PROMPT>...<PROMPT><RESPONSE>...<RESPONSE><PAD>...<PAD>
"""
self.num_train_step += 1
self.actor.train()
num_actions = experience.action_log_probs.size(1)
# policy loss
Expand Down Expand Up @@ -294,7 +293,7 @@ def _training_step(self, experience: Experience):
self.temperature_annealing_scheduler.step_forward()

# preparing logging model output and corresponding rewards.
if self.num_train_step % 10 == 1:
if self.num_train_step % 10 == 0:
response_text = self.experience_maker.tokenizer.batch_decode(
experience.sequences, skip_special_tokens=True
)
Expand Down Expand Up @@ -327,6 +326,7 @@ def _training_step(self, experience: Experience):
self.writer.add_scalar("approx_kl", self.accumulative_meter.get("kl"), global_step)
self.writer.add_scalar("advantages", self.accumulative_meter.get("advantages"), global_step)
self.accumulative_meter.reset()
self.num_train_step += 1

def _learn(self, update_step: int):
"""
Expand Down
2 changes: 1 addition & 1 deletion applications/ColossalChat/coati/trainer/kto.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def _train(self, epoch: int):
self.coordinator.print_on_master(
f"Saved checkpoint at epoch {epoch} step {self.save_interval} at folder {self.save_dir}"
)
self.num_train_step += 1
self.num_train_step += 1

step_bar.close()

Expand Down
2 changes: 1 addition & 1 deletion applications/ColossalChat/coati/trainer/orpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def _train(self, epoch: int):
self.coordinator.print_on_master(
f"Saved checkpoint at epoch {epoch} step {self.save_interval} at folder {self.save_dir}"
)
self.num_train_step += 1
self.num_train_step += 1

step_bar.close()

Expand Down
4 changes: 2 additions & 2 deletions applications/ColossalChat/coati/trainer/ppo.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ def _training_step(self, experience: Experience):
experience:
sequences: [batch_size, prompt_length + response_length] --- <PAD>...<PAD><PROMPT>...<PROMPT><RESPONSE>...<RESPONSE><PAD>...<PAD>
"""
self.num_train_step += 1
self.actor.train()
self.critic.train()
num_actions = experience.action_log_probs.size(1)
Expand Down Expand Up @@ -294,7 +293,7 @@ def _training_step(self, experience: Experience):
self.critic_scheduler.step()

# preparing logging model output and corresponding rewards.
if self.num_train_step % 10 == 1:
if self.num_train_step % 10 == 0:
response_text = self.experience_maker.tokenizer.batch_decode(
experience.sequences, skip_special_tokens=True
)
Expand Down Expand Up @@ -336,6 +335,7 @@ def _training_step(self, experience: Experience):
self.writer.add_scalar("value", self.accumulative_meter.get("value"), self.num_train_step)
self.writer.add_scalar("advantages", self.accumulative_meter.get("advantages"), self.num_train_step)
self.accumulative_meter.reset()
self.num_train_step += 1

def _learn(self, update_step: int):
"""
Expand Down
2 changes: 1 addition & 1 deletion applications/ColossalChat/coati/trainer/rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def _train(self, epoch):
self.coordinator.print_on_master(
f"Saved checkpoint at epoch {epoch} step {(i + 1)/self.accumulation_steps} at folder {self.save_dir}"
)
self.num_train_step += 1
self.num_train_step += 1
step_bar.close()

def _eval(self, epoch):
Expand Down
2 changes: 1 addition & 1 deletion applications/ColossalChat/coati/trainer/sft.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ def _train(self, epoch: int):
if self.writer:
self.writer.add_scalar("train/loss", self.accumulative_meter.get("loss"), global_step)
self.writer.add_scalar("train/lr", self.scheduler.get_last_lr()[0], global_step)
self.num_train_step += 1
self.accumulative_meter.reset()
step_bar.update()
self.num_train_step += 1

# Save checkpoint
if (
Expand Down