[Model Runner V2] Fix prompt logprobs calculation Sizes of tensors must match error (#42778)
Signed-off-by: yewentao256 <zhyanwentao@126.com>
This commit is contained in:
@@ -99,6 +99,7 @@ class PromptLogprobsWorker:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
req_is_prompt_chunked = is_prompt_chunked[i]
|
req_is_prompt_chunked = is_prompt_chunked[i]
|
||||||
|
req_num_prompt_logprobs = int(num_prompt_logprobs[i])
|
||||||
start_idx = query_start_loc_np[i]
|
start_idx = query_start_loc_np[i]
|
||||||
end_idx = query_start_loc_np[i + 1]
|
end_idx = query_start_loc_np[i + 1]
|
||||||
assert start_idx < end_idx, (
|
assert start_idx < end_idx, (
|
||||||
@@ -107,13 +108,18 @@ class PromptLogprobsWorker:
|
|||||||
if not req_is_prompt_chunked:
|
if not req_is_prompt_chunked:
|
||||||
end_idx -= 1
|
end_idx -= 1
|
||||||
|
|
||||||
|
width = (
|
||||||
|
prompt_logprobs.shape[1]
|
||||||
|
if req_num_prompt_logprobs == -1
|
||||||
|
else req_num_prompt_logprobs + 1
|
||||||
|
)
|
||||||
# no logprobs if start_idx >= end_idx
|
# no logprobs if start_idx >= end_idx
|
||||||
logprobs = (
|
logprobs = (
|
||||||
None
|
None
|
||||||
if start_idx >= end_idx
|
if start_idx >= end_idx
|
||||||
else LogprobsTensors(
|
else LogprobsTensors(
|
||||||
logprob_token_ids=prompt_token_ids[start_idx:end_idx],
|
logprob_token_ids=prompt_token_ids[start_idx:end_idx, :width],
|
||||||
logprobs=prompt_logprobs[start_idx:end_idx],
|
logprobs=prompt_logprobs[start_idx:end_idx, :width],
|
||||||
selected_token_ranks=prompt_ranks[start_idx:end_idx],
|
selected_token_ranks=prompt_ranks[start_idx:end_idx],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user