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

Method start_request

fastdeploy/spec_decode/suffix.py:83–108  ·  view source on GitHub ↗

Start a new request in the suffix cache. Args: req_id: Request identifier prompt_token_ids: List of prompt token IDs

(self, idx: int, req_id: str, prompt_token_ids: list[int])

Source from the content-addressed store, hash-verified

81 self.idx_to_req_id[idx] = req_id
82
83 def start_request(self, idx: int, req_id: str, prompt_token_ids: list[int]):
84 """
85 Start a new request in the suffix cache.
86
87 Args:
88 req_id: Request identifier
89 prompt_token_ids: List of prompt token IDs
90 """
91 if req_id in self.suffix_cache.active_requests:
92 # Request already active, skip
93 return
94
95 prompt_array = np.array(prompt_token_ids, dtype=np.int32)
96 if not prompt_array.flags["CONTIGUOUS"]:
97 prompt_array = np.ascontiguousarray(prompt_array)
98
99 self.context_tokens[idx, :] = -1
100 self.context_tokens[idx, : len(prompt_token_ids)] = prompt_array
101 self._update_request_mapping(idx, req_id)
102 if req_id not in self.suffix_cache.active_requests:
103 if req_id in self.suffix_cache.cached_requests:
104 # Reset the suffix cache for current req_id
105 self.suffix_cache.evict_cached_response(req_id)
106 spec_logger.debug(f"[SuffixDecoding] Reset suffix cache for request {req_id}.")
107 self.suffix_cache.start_request(req_id, prompt_array)
108 spec_logger.debug(f"[SuffixDecoding] Start request {req_id}.")
109
110 def stop_request(self, req_id: str):
111 """

Callers 4

test_proposeMethod · 0.95
insert_tasks_v1Method · 0.80
insert_prefill_inputsMethod · 0.80

Calls 2

debugMethod · 0.80

Tested by 2

test_proposeMethod · 0.76