MCPcopy
hub / github.com/ModelTC/LightLLM / init

Method init

lightllm/server/core/objs/req.py:117–162  ·  view source on GitHub ↗
(
        self,
        request_id: int,
        prompt_ids: List[int],
        sample_param: Union[dict, SamplingParams],
        tokenizer: Any,
        chunked_prefill_size: int = 0,
    )

Source from the content-addressed store, hash-verified

115 )
116
117 def init(
118 self,
119 request_id: int,
120 prompt_ids: List[int],
121 sample_param: Union[dict, SamplingParams],
122 tokenizer: Any,
123 chunked_prefill_size: int = 0,
124 ):
125 # 只是为了有更好的编码辅助类型提示
126 self.index_in_shm_mem: int = self.index_in_shm_mem
127 self.ref_count: int = self.ref_count
128
129 self.request_id = request_id
130 self.group_req_id = convert_sub_id_to_group_id(request_id)
131 self.is_paused = False
132 self.finish_status = FinishStatus()
133 self.is_aborted = False
134 self.shm_infer_released = False
135 self.shm_cur_kv_len = 0
136 self.shm_cur_output_len = 0
137 self.candetoken_out_len = 0
138 self.prompt_cache_len = 0
139 self.finish_token_index = -1
140 self.can_released_mark = False
141 self.reward_score = math.nan
142 self.cumlogprob = 0.0
143 if isinstance(sample_param, SamplingParams):
144 self.sample_params = sample_param
145 else:
146 self.sample_params = SamplingParams()
147 self.sample_params.init(tokenizer=tokenizer, **sample_param)
148 self.prefix_token_ids = PrefixTokenIdsStruct()
149
150 self.out_tokens_queue = CircularQueue()
151 self.input_len = len(prompt_ids)
152 self.alloc_shm_numpy_len = self.input_len + self.sample_params.max_new_tokens + 1024 # + 1024 for safe
153 self.create_logprobs_shm_array()
154 self.create_prompt_ids_shm_array()
155 self.chunked_prefill_size = chunked_prefill_size
156 self.shm_prompt_ids.arr[0 : len(prompt_ids)] = prompt_ids
157 self.mtp_accepted_token_num = 0
158 self._mtp_step = get_env_start_args().mtp_step
159 self.stop_str_matched = False
160 self.stop_str_matched_token_index = -1
161
162 self.post_init()
163
164 def post_init(self):
165 # 子类继承进行一些额外的初始化操作

Callers 4

reqFunction · 0.95
vllm_utils.pyFile · 0.45
generateMethod · 0.45

Calls 9

post_initMethod · 0.95
get_env_start_argsFunction · 0.90
FinishStatusClass · 0.85
CircularQueueClass · 0.85
SamplingParamsClass · 0.70

Tested by 2

reqFunction · 0.76