[Metax] adapt DeepSeek (#4498)

This commit is contained in:
xiaozude
2025-10-24 10:14:53 +08:00
committed by GitHub
parent 8718fa34b2
commit f7069b8057
19 changed files with 1538 additions and 324 deletions

View File

@@ -43,12 +43,12 @@ class DefaultModelLoader(BaseModelLoader):
def clean_memory_fragments(self, state_dict: dict) -> None:
"""clean_memory_fragments"""
if current_platform.is_cuda():
if current_platform.is_cuda() or current_platform.is_maca():
if state_dict:
for k, v in state_dict.items():
if isinstance(v, paddle.Tensor):
v.value().get_tensor()._clear()
paddle.device.cuda.empty_cache()
paddle.device.empty_cache()
paddle.device.synchronize()
@measure_time()