mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2026-05-07 16:08:58 +08:00
[BugFix] PD reorder fix and add ut (#6375)
This commit is contained in:
@@ -36,6 +36,7 @@ if TYPE_CHECKING:
|
||||
|
||||
import numpy as np
|
||||
|
||||
from fastdeploy import envs
|
||||
from fastdeploy.config import FDConfig
|
||||
from fastdeploy.model_executor.layers.attention.attention import Attention
|
||||
from fastdeploy.model_executor.layers.attention.base_attention_backend import (
|
||||
@@ -115,6 +116,7 @@ class AppendAttentionBackend(AttentionBackend):
|
||||
|
||||
__infer_dynamic_dims_fields__ = ["attention_metadata"]
|
||||
attention_metadata: AppendAttentionMetadata
|
||||
enable_ids_reorder: bool = envs.FD_PD_REORDER
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
||||
@@ -436,21 +436,27 @@ def save_output_normal(
|
||||
)
|
||||
async_output_queue.put(output)
|
||||
else:
|
||||
recover_share_inputs_map = recover_batch_index_for_output(
|
||||
share_inputs,
|
||||
model_output.index_to_batch_id,
|
||||
model_output.enable_pd_reorder,
|
||||
["last_preempted_idx"],
|
||||
)
|
||||
if sampler_output.logprobs_tensors is None:
|
||||
recover_share_inputs_map = recover_batch_index_for_output(
|
||||
share_inputs,
|
||||
model_output.index_to_batch_id,
|
||||
model_output.enable_pd_reorder,
|
||||
["last_preempted_idx", "sampled_token_ids"],
|
||||
)
|
||||
save_output(
|
||||
share_inputs["sampled_token_ids"],
|
||||
recover_share_inputs_map["sampled_token_ids"],
|
||||
model_output.not_need_stop,
|
||||
recover_share_inputs_map["last_preempted_idx"],
|
||||
model_output.mp_rank,
|
||||
save_each_rank,
|
||||
)
|
||||
else:
|
||||
recover_share_inputs_map = recover_batch_index_for_output(
|
||||
share_inputs,
|
||||
model_output.index_to_batch_id,
|
||||
model_output.enable_pd_reorder,
|
||||
["last_preempted_idx"],
|
||||
)
|
||||
recover_batch_index_for_sampler_output(
|
||||
sampler_output, model_output.index_to_batch_id, model_output.enable_pd_reorder
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user