[Model Runner] Refactor execute_model for GPU async scheduling (#6176)

This commit is contained in:
sunxin
2026-01-28 14:19:33 +08:00
committed by GitHub
parent ce06c6dfb3
commit 27f8799f04
9 changed files with 188 additions and 62 deletions
+2 -7
View File
@@ -107,7 +107,7 @@ __global__ void update_inputs_kernel_v1(bool* not_need_stop,
}
void UpdateInputsV1(const paddle::Tensor& stop_flags,
const paddle::Tensor& not_need_stop, // only on cpu
const paddle::Tensor& not_need_stop, // on gpu
const paddle::Tensor& seq_lens_this_time,
const paddle::Tensor& seq_lens_encoder,
const paddle::Tensor& seq_lens_decoder,
@@ -137,9 +137,8 @@ void UpdateInputsV1(const paddle::Tensor& stop_flags,
const int now_bsz = seq_lens_this_time.shape()[0];
const int input_ids_stride = input_ids.shape()[1];
const int block_num_per_seq = block_tables.shape()[1];
auto not_need_stop_gpu = not_need_stop.copy_to(stop_flags.place(), false);
update_inputs_kernel_v1<1024><<<1, 1024, 0, cu_stream>>>(
const_cast<bool*>(not_need_stop_gpu.data<bool>()),
const_cast<bool*>(not_need_stop.data<bool>()),
const_cast<int*>(seq_lens_this_time.data<int>()),
const_cast<int*>(seq_lens_encoder.data<int>()),
const_cast<int*>(seq_lens_decoder.data<int>()),
@@ -157,10 +156,6 @@ void UpdateInputsV1(const paddle::Tensor& stop_flags,
block_num_per_seq,
block_size,
prefill_one_step_stop);
auto not_need_stop_cpu =
not_need_stop_gpu.copy_to(not_need_stop.place(), false);
bool* not_need_stop_data = const_cast<bool*>(not_need_stop.data<bool>());
not_need_stop_data[0] = not_need_stop_cpu.data<bool>()[0];
}
PD_BUILD_STATIC_OP(update_inputs_v1)