(self, *inputs, **kwargs)
| 615 | return outputs |
| 616 | |
| 617 | def _generate(self, *inputs, **kwargs): |
| 618 | # Reset KV-cache at the beginning of generate |
| 619 | if hasattr(self.module, 'reset_cache'): |
| 620 | self.module.reset_cache() |
| 621 | num_beams = 1 |
| 622 | if "generation_config" in kwargs: |
| 623 | gen_config = kwargs["generation_config"] |
| 624 | num_beams = getattr(gen_config, "num_beams", 1) |
| 625 | if "num_beams" in kwargs: |
| 626 | num_beams = kwargs["num_beams"] |
| 627 | |
| 628 | if num_beams > 1: |
| 629 | raise NotImplementedError("DeepSpeed does not support `num_beams` > 1, if this is important to you please " |
| 630 | "add your request to: https://github.com/deepspeedai/DeepSpeed/issues/2506") |
| 631 | |
| 632 | if ("input_ids" in kwargs) and (kwargs["input_ids"].dim() == 2): |
| 633 | for input_tensor in kwargs["input_ids"]: |
| 634 | tensor_length = input_tensor.shape[-1] |
| 635 | if tensor_length > self._config.max_out_tokens: |
| 636 | raise RuntimeError( |
| 637 | f"Input with size {tensor_length} exceeds maximum length of {self._config.max_out_tokens}. Please increase max_tokens in the DeepSpeed Inference Config." |
| 638 | ) |
| 639 | |
| 640 | return self.module.generate(*inputs, **kwargs) |
| 641 | |
| 642 | def compile(self, backend=get_accelerator().get_compile_backend(), compile_kwargs={}) -> None: |
| 643 | """ |
no test coverage detected