(self)
| 649 | return fn() |
| 650 | |
| 651 | def _iter_pad(self): |
| 652 | chunk_size = self.config.batch_size * self.config.seq_length |
| 653 | if self.config.use_data_sharded_loader: |
| 654 | local_batch_size = self.config.batch_size // self._node_info['dp_node_size'] |
| 655 | else: |
| 656 | local_batch_size = self.config.batch_size |
| 657 | last_time = 0.0 |
| 658 | buffer = [] |
| 659 | step_times = [] |
| 660 | start_time = time.time() |
| 661 | start_tokens = self._total_tokens |
| 662 | for tokens, loss_masks, vision_masks, keep, loc, index in self.parallel_example_iterator(): |
| 663 | if not keep: |
| 664 | continue |
| 665 | self._file_loc = loc |
| 666 | self._index = index |
| 667 | buffer.append((tokens, loss_masks, vision_masks)) |
| 668 | while len(buffer) >= local_batch_size: |
| 669 | self._total_tokens += chunk_size |
| 670 | step_times.append(time.time() - last_time) |
| 671 | last_time = time.time() |
| 672 | if len(step_times) > self.config.throughput_average_window_size: |
| 673 | step_times = step_times[-self.config.throughput_average_window_size:] |
| 674 | average_throughput = chunk_size / np.mean(step_times) |
| 675 | accumulated_throughput = ( |
| 676 | (self._total_tokens - start_tokens) / (time.time() - start_time) |
| 677 | ) |
| 678 | metrics = { |
| 679 | 'dataset_file_loc': loc, |
| 680 | 'dataset_example_index': index, |
| 681 | 'dataset_total_tokens': self._total_tokens, |
| 682 | 'dataset_accumulated_tps': accumulated_throughput, |
| 683 | 'dataset_average_tps': average_throughput, |
| 684 | } |
| 685 | |
| 686 | batch = { |
| 687 | 'input_tokens': np.full( |
| 688 | (local_batch_size, self.config.seq_length), |
| 689 | self._tokenizer.bos_token_id, |
| 690 | dtype=np.int32 |
| 691 | ), |
| 692 | 'target_tokens': np.full( |
| 693 | (local_batch_size, self.config.seq_length), |
| 694 | self._tokenizer.bos_token_id, |
| 695 | dtype=np.int32 |
| 696 | ), |
| 697 | 'loss_masks': np.zeros( |
| 698 | (local_batch_size, self.config.seq_length), |
| 699 | dtype=np.float32 |
| 700 | ), |
| 701 | 'input_vision_masks': np.zeros( |
| 702 | (local_batch_size, self.config.seq_length), |
| 703 | dtype=bool |
| 704 | ), |
| 705 | 'target_vision_masks': np.zeros( |
| 706 | (local_batch_size, self.config.seq_length), |
| 707 | dtype=bool |
| 708 | ) |
nothing calls this directly
no test coverage detected