(batch_size)
| 632 | # if OOM, then halves batch_size and tries again |
| 633 | @find_executable_batch_size(starting_batch_size=self.max_batch_size) |
| 634 | def forward_batch(batch_size): |
| 635 | if self.AUTO_MODEL_CLASS == transformers.AutoModelForSeq2SeqLM: |
| 636 | length = max(max_context_enc, max_cont_enc) |
| 637 | batched_conts = torch.ones( |
| 638 | (batch_size, length), device=self.device |
| 639 | ).long() |
| 640 | test_batch = torch.ones((batch_size, length), device=self.device).long() |
| 641 | call_kwargs = { |
| 642 | "attn_mask": test_batch, |
| 643 | "labels": batched_conts, |
| 644 | } |
| 645 | else: |
| 646 | call_kwargs = {} |
| 647 | test_batch = torch.ones( |
| 648 | (batch_size, max_length), device=self.device |
| 649 | ).long() |
| 650 | for _ in range(5): |
| 651 | out = F.log_softmax(self._model_call(test_batch, **call_kwargs), dim=-1) # noqa: F841 |
| 652 | |
| 653 | return batch_size |
| 654 | |
| 655 | try: |
| 656 | batch_size = forward_batch() |
nothing calls this directly
no test coverage detected