mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2026-04-23 00:17:25 +08:00
[XPU]MAX_BSZ aligns gpu settings and disable prefix cache in OCR VL (#5831)
This commit is contained in:
@@ -23,8 +23,8 @@
|
||||
#define PD_BUILD_STATIC_OP(name) PD_BUILD_OP(static_op_##name)
|
||||
#endif
|
||||
|
||||
#define MAX_BSZ 128
|
||||
#define K 5
|
||||
#define MAX_BSZ 512
|
||||
#define K 20
|
||||
|
||||
struct msgdata {
|
||||
long mtype;
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#define PD_BUILD_STATIC_OP(name) PD_BUILD_OP(static_op_##name)
|
||||
#endif
|
||||
|
||||
#define MAX_BSZ 128
|
||||
#define K 5
|
||||
#define MAX_BSZ 512
|
||||
#define K 20
|
||||
// #define SAVE_WITH_OUTPUT_DEBUG
|
||||
|
||||
struct msgdata {
|
||||
|
||||
@@ -17,19 +17,12 @@
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/msg.h>
|
||||
#include <sys/types.h>
|
||||
#include "msg_utils.h"
|
||||
#include "paddle/extension.h"
|
||||
|
||||
#define MAX_BSZ 256
|
||||
|
||||
// #define SAVE_WITH_OUTPUT_DEBUG
|
||||
struct msgdata {
|
||||
long mtype;
|
||||
int mtext[MAX_BSZ + 2]; // stop_flag, bsz, tokens
|
||||
};
|
||||
|
||||
// #define SAVE_WITH_OUTPUT_DEBUG
|
||||
void SaveOutMmsg(const paddle::Tensor &x,
|
||||
const paddle::Tensor ¬_need_stop,
|
||||
void SaveOutMmsg(const paddle::Tensor& x,
|
||||
const paddle::Tensor& not_need_stop,
|
||||
int64_t rank_id,
|
||||
int msg_queue_id,
|
||||
bool save_each_rank) {
|
||||
@@ -37,10 +30,10 @@ void SaveOutMmsg(const paddle::Tensor &x,
|
||||
return;
|
||||
}
|
||||
auto x_cpu = x.copy_to(paddle::CPUPlace(), false);
|
||||
int64_t *x_data = x_cpu.data<int64_t>();
|
||||
int64_t* x_data = x_cpu.data<int64_t>();
|
||||
static struct msgdata msg_sed;
|
||||
|
||||
if (const char *inference_msg_queue_id_env_p =
|
||||
if (const char* inference_msg_queue_id_env_p =
|
||||
std::getenv("INFERENCE_MSG_QUEUE_ID")) {
|
||||
std::string inference_msg_queue_id_env_str(inference_msg_queue_id_env_p);
|
||||
int inference_msg_queue_id_from_env =
|
||||
@@ -57,7 +50,7 @@ void SaveOutMmsg(const paddle::Tensor &x,
|
||||
#endif
|
||||
}
|
||||
int inference_msg_id_from_env = 1;
|
||||
if (const char *inference_msg_id_env_p = std::getenv("INFERENCE_MSG_ID")) {
|
||||
if (const char* inference_msg_id_env_p = std::getenv("INFERENCE_MSG_ID")) {
|
||||
std::string inference_msg_id_env_str(inference_msg_id_env_p);
|
||||
inference_msg_id_from_env = std::stoi(inference_msg_id_env_str);
|
||||
if (inference_msg_id_from_env == 2) {
|
||||
@@ -111,15 +104,15 @@ void SaveOutMmsg(const paddle::Tensor &x,
|
||||
return;
|
||||
}
|
||||
|
||||
void SaveOutMmsgStatic(const paddle::Tensor &x,
|
||||
const paddle::Tensor ¬_need_stop,
|
||||
void SaveOutMmsgStatic(const paddle::Tensor& x,
|
||||
const paddle::Tensor& not_need_stop,
|
||||
int64_t rank_id,
|
||||
bool save_each_rank) {
|
||||
SaveOutMmsg(x, not_need_stop, rank_id, 1, save_each_rank);
|
||||
}
|
||||
|
||||
void SaveOutMmsgDynamic(const paddle::Tensor &x,
|
||||
const paddle::Tensor ¬_need_stop,
|
||||
void SaveOutMmsgDynamic(const paddle::Tensor& x,
|
||||
const paddle::Tensor& not_need_stop,
|
||||
int64_t rank_id,
|
||||
int msg_queue_id,
|
||||
bool save_each_rank) {
|
||||
|
||||
@@ -564,6 +564,9 @@ class EngineArgs:
|
||||
|
||||
if "PaddleOCR" in get_model_architecture(self.model, self.model_config_name):
|
||||
envs.FD_ENABLE_MAX_PREFILL = 1
|
||||
# TODO XPU support PaddleOCR prefix caching
|
||||
if current_platform.is_xpu():
|
||||
self.enable_prefix_caching = False
|
||||
|
||||
if self.kvcache_storage_backend is not None:
|
||||
if not self.enable_prefix_caching:
|
||||
|
||||
@@ -50,12 +50,9 @@ RECOVERY_STOP_SIGNAL = -3
|
||||
MAX_DRAFT_TOKENS = 6
|
||||
SPECULATE_MAX_BSZ = 256
|
||||
|
||||
if current_platform.is_xpu():
|
||||
MAX_BSZ = 128
|
||||
K = 5
|
||||
else:
|
||||
MAX_BSZ = 512
|
||||
K = 20
|
||||
|
||||
MAX_BSZ = 512
|
||||
K = 20
|
||||
|
||||
|
||||
class TokenProcessor:
|
||||
|
||||
@@ -1031,6 +1031,11 @@ def initialize_fd_config(args, ranks: int = 1, local_rank: int = 0) -> FDConfig:
|
||||
architecture = fd_config.model_config.architectures[0]
|
||||
if "PaddleOCR" in architecture:
|
||||
envs.FD_ENABLE_MAX_PREFILL = 1
|
||||
# TODO XPU support PaddleOCR prefix caching
|
||||
if current_platform.is_xpu():
|
||||
fd_config.cache_config.enable_prefix_caching = False
|
||||
fd_config.cache_config.max_encoder_cache = 0
|
||||
|
||||
return fd_config
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user