Clean buffers used for the CUDA graph when replaying the CUDA graph with the padded batch. In FastDeploy, almost all input tensors have a buffer. So, just keep the buffer clean when replaying the CUDA graph with the padded batch.
(self)
| 1181 | return True |
| 1182 | |
| 1183 | def padding_cudagraph_inputs(self) -> None: |
| 1184 | """ |
| 1185 | Clean buffers used for the CUDA graph when replaying the CUDA graph with the padded batch. |
| 1186 | In FastDeploy, almost all input tensors have a buffer. So, just keep the buffer clean when replaying the CUDA graph with the padded batch. |
| 1187 | """ |
| 1188 | # In init_attention_metadata, the decode buffer has already been cleared |
| 1189 | |
| 1190 | # To adapt to CUDA Graph, keep the forward pass at the maximum batch size. |
| 1191 | if self.forward_meta.step_use_cudagraph: |
| 1192 | self.forward_meta.seq_lens_this_time = self.model_inputs["seq_lens_this_time_buffer"] |
| 1193 | self.real_token_num = self.forward_meta.ids_remove_padding.shape[0] |
| 1194 | return |
| 1195 | |
| 1196 | def _empty_cache(self): |
| 1197 | if current_platform.is_cuda(): |
no outgoing calls