MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / reset_share_inputs

Method reset_share_inputs

fastdeploy/worker/input_batch.py:496–656  ·  view source on GitHub ↗

Reset all paddle tensors to their initial state. This method clears the content of the shared input buffers while preserving their shapes and data types.

(self)

Source from the content-addressed store, hash-verified

494 return batch_id
495
496 def reset_share_inputs(self):
497 """
498 Reset all paddle tensors to their initial state.
499 This method clears the content of the shared input buffers while preserving
500 their shapes and data types.
501 """
502 try:
503 logger.info("Resetting share_inputs to initial state...")
504 from fastdeploy.utils import fill_paddle_tensor
505
506 # Reset all paddle tensors to their initial fill values
507 max_num_seqs = self.scheduler_config.max_num_seqs
508
509 # Reset basic tensors to their default values
510 fill_paddle_tensor(self, "pre_ids", -1)
511 fill_paddle_tensor(self, "input_ids", self.model_config.pad_token_id)
512 fill_paddle_tensor(self, "prompt_ids", self.model_config.pad_token_id)
513 fill_paddle_tensor(self, "eos_token_id", 0)
514 fill_paddle_tensor(self, "top_p", self.model_config.top_p)
515 fill_paddle_tensor(self, "top_k", 0)
516 fill_paddle_tensor(self, "min_p", 0.0)
517 fill_paddle_tensor(self, "temperature", self.model_config.temperature)
518 fill_paddle_tensor(self, "penalty_score", self.model_config.penalty_score)
519 fill_paddle_tensor(self, "frequency_score", self.model_config.frequency_score)
520 fill_paddle_tensor(self, "presence_score", self.model_config.presence_score)
521 fill_paddle_tensor(self, "temp_scaled_logprobs", False)
522 fill_paddle_tensor(self, "top_p_normalized_logprobs", False)
523
524 # Reset list variables (not paddle tensors)
525 self.top_k_list = [0] * max_num_seqs
526 self.min_p_list = [0.0] * max_num_seqs
527
528 fill_paddle_tensor(self, "min_dec_len", self.model_config.min_length)
529 fill_paddle_tensor(self, "max_dec_len", self.model_config.max_model_len)
530
531 # Reset sequence length related buffers
532 fill_paddle_tensor(self, "seq_lens_this_time_buffer", 0)
533 if self.enable_expert_parallel:
534 fill_paddle_tensor(self, "seq_lens_this_time", 0)
535 fill_paddle_tensor(self, "seq_lens_encoder", 0)
536 fill_paddle_tensor(self, "seq_lens_decoder", 0)
537 fill_paddle_tensor(self, "step_seq_lens_encoder", 0)
538 fill_paddle_tensor(self, "step_seq_lens_decoder", 0)
539 fill_paddle_tensor(self, "prompt_lens", 0)
540 fill_paddle_tensor(self, "step_idx", 0)
541 # fill_paddle_tensor(self, "not_need_stop", False)
542 fill_paddle_tensor(self, "not_need_stop_device", False)
543 fill_paddle_tensor(self, "sampled_token_ids", -1)
544 fill_paddle_tensor(self, "stop_flags", True)
545
546 fill_paddle_tensor(self, "bad_tokens", -1)
547 fill_paddle_tensor(self, "bad_tokens_len", 1)
548 fill_paddle_tensor(self, "next_tokens", -1)
549 fill_paddle_tensor(self, "is_block_step", False)
550 fill_paddle_tensor(self, "is_chunk_step", False)
551 fill_paddle_tensor(self, "encoder_block_lens", 0)
552 fill_paddle_tensor(self, "step_block_list", -1)
553 fill_paddle_tensor(self, "step_lens", 0)

Callers 2

update_parametersMethod · 0.80
wakeupMethod · 0.80

Calls 4

fill_paddle_tensorFunction · 0.90
get_ropeFunction · 0.90
infoMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected