LMFuser 0.1.0__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: LMFuser
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: The LMFuser training framework.
5
5
  Project-URL: Homepage, https://github.com/TYTTYTTYT/LMFuser
6
6
  Project-URL: Documentation, https://github.com/TYTTYTTYT/LMFuser
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "LMFuser"
7
- version = "0.1.0"
7
+ version = "0.1.2"
8
8
  requires-python = ">= 3.11"
9
9
  description = "The LMFuser training framework."
10
10
  readme = "README.md"
@@ -516,6 +516,7 @@ class DDPRunner(Runner[DDPRunnerConfig]):
516
516
  # calculate loss
517
517
  running_loss: float = 0.0
518
518
  batch_datas: defaultdict[Hashable, List[float]] = defaultdict(list)
519
+ subbatch_result_lst: list[Batch] = []
519
520
  for acc_idx in range(self.config._num_acc_steps):
520
521
  with ExitStack() as stack:
521
522
  # check whether to use amp
@@ -554,6 +555,8 @@ class DDPRunner(Runner[DDPRunnerConfig]):
554
555
  raise KeyError('no loss returned from the batch')
555
556
  assert isinstance(subbatch_result, dict)
556
557
  loss = subbatch_result['loss']
558
+ del subbatch_result['loss']
559
+ subbatch_result_lst.append(subbatch_result) # type: ignore
557
560
  assert isinstance(loss, Tensor)
558
561
  loss = loss / self.config._num_acc_steps
559
562
  running_loss += loss.item()
@@ -625,7 +628,19 @@ class DDPRunner(Runner[DDPRunnerConfig]):
625
628
  {f'{task.__class__.__name__}/train/learning_rate': current_lr}
626
629
  )
627
630
  self.scheduler.step()
628
- torch.distributed.barrier() if get_world_size() > 1 else ...
631
+
632
+ other_step_results = defaultdict(list)
633
+ for r in subbatch_result_lst:
634
+ for k, v in r.items():
635
+ if isinstance(v, (float, int)):
636
+ other_step_results[k].append(float(v))
637
+ all_other_step_results = batch_all_gather(other_step_results)
638
+ for k, v in all_other_step_results.items():
639
+ try:
640
+ avg = sum(v) / len(v)
641
+ except:
642
+ continue
643
+ self.step_log({f'{task.__class__.__name__}/train/{k}': avg})
629
644
 
630
645
  save_step_freq = self.config.save_step_freq.value()
631
646
  assert save_step_freq is not None
@@ -646,6 +661,7 @@ class DDPRunner(Runner[DDPRunnerConfig]):
646
661
  self.step += 1
647
662
 
648
663
  def train(self, *args: Any, **kwargs: Any) -> None:
664
+ self.eval() # evaluate first
649
665
  self._prepare_train()
650
666
 
651
667
  self._last_epoch = self.epoch
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes