Prechádzať zdrojové kódy

[ILUVATAR_GPU] Support for iluvatar_gpu (#4565)

tianyuzhou668 1 mesiac pred
rodič
commit
2da1e99fab

+ 6 - 0
paddlex/inference/models/common/static_infer.py

@@ -445,6 +445,12 @@ class PaddleInfer(StaticInfer):
                     # Delete unsupported passes in dcu
                     config.delete_pass("conv2d_add_act_fuse_pass")
                     config.delete_pass("conv2d_add_fuse_pass")
+            elif self._option.device_type == "iluvatar_gpu":
+                config.enable_custom_device("iluvatar_gpu", int(self._option.device_id))
+                if hasattr(config, "enable_new_ir"):
+                    config.enable_new_ir(self._option.enable_new_ir)
+                if hasattr(config, "enable_new_executor"):
+                    config.enable_new_executor()
             else:
                 assert self._option.device_type == "cpu"
                 config.disable_gpu()

+ 5 - 3
paddlex/inference/models/common/vlm/fusion_ops.py

@@ -49,6 +49,8 @@ def get_env_device():
         return "gcu"
     elif "intel_hpu" in paddle.device.get_all_custom_device_type():
         return "intel_hpu"
+    elif "iluvatar_gpu" in paddle.device.get_all_custom_device_type():
+        return "iluvatar_gpu"
     elif paddle.is_compiled_with_rocm():
         return "rocm"
     elif paddle.is_compiled_with_xpu():
@@ -61,7 +63,7 @@ try:
 except ImportError:
     fused_rotary_position_embedding = None
 try:
-    if get_env_device() in ["npu", "mlu", "gcu"]:
+    if get_env_device() in ["npu", "mlu", "gcu", "iluvatar_gpu"]:
         from paddle.base import core
 
         for lib in os.listdir(os.getenv("CUSTOM_DEVICE_ROOT")):
@@ -84,7 +86,7 @@ def fusion_rope(
     rotary_emb,
     context_parallel_degree=-1,
 ):
-    if get_env_device() not in ["gcu", "intel_hpu"]:
+    if get_env_device() not in ["gcu", "intel_hpu", "iluvatar_gpu"]:
         assert past_key_value is None, "fuse rotary not support cache kv for now"
     batch_size, seq_length, num_heads, head_dim = query_states.shape
     _, kv_seq_len, num_key_value_heads, _ = key_states.shape
@@ -93,7 +95,7 @@ def fusion_rope(
             get_env_device() == "gpu"
         ), "context parallel only support cuda device for now"
         kv_seq_len *= context_parallel_degree
-    if get_env_device() not in ["gcu", "intel_hpu"]:
+    if get_env_device() not in ["gcu", "intel_hpu", "iluvatar_gpu"]:
         cos, sin = rotary_emb(value_states, seq_len=kv_seq_len)
     if get_env_device() == "npu":
         query_states = core.eager._run_custom_op("fused_rope", query_states, cos, sin)[

+ 1 - 1
paddlex/inference/utils/pp_option.py

@@ -54,7 +54,7 @@ class PaddlePredictorOption(object):
         "mkldnn",
         "mkldnn_bf16",
     )
-    SUPPORT_DEVICE = ("gpu", "cpu", "npu", "xpu", "mlu", "dcu", "gcu")
+    SUPPORT_DEVICE = ("gpu", "cpu", "npu", "xpu", "mlu", "dcu", "gcu", "iluvatar_gpu")
 
     def __init__(self, **kwargs):
         super().__init__()

+ 2 - 0
paddlex/repo_apis/PaddleOCR_api/text_rec/config.py

@@ -249,6 +249,7 @@ class TextRecConfig(BaseConfig):
             "Global.use_npu": False,
             "Global.use_mlu": False,
             "Global.use_gcu": False,
+            "Global.use_iluvatar_gpu": False,
         }
 
         device_cfg = {
@@ -258,6 +259,7 @@ class TextRecConfig(BaseConfig):
             "mlu": {"Global.use_mlu": True},
             "npu": {"Global.use_npu": True},
             "gcu": {"Global.use_gcu": True},
+            "iluvatar_gpu": {"Global.use_iluvatar_gpu": True},
         }
         default_cfg.update(device_cfg[device])
         self.update(default_cfg)

+ 1 - 1
paddlex/utils/device.py

@@ -25,7 +25,7 @@ from .custom_device_list import (
 )
 from .flags import DISABLE_DEV_MODEL_WL
 
-SUPPORTED_DEVICE_TYPE = ["cpu", "gpu", "xpu", "npu", "mlu", "gcu", "dcu"]
+SUPPORTED_DEVICE_TYPE = ["cpu", "gpu", "xpu", "npu", "mlu", "gcu", "dcu", "iluvatar_gpu"]
 
 
 def constr_device(device_type, device_ids):