[CPU] fix all_reduce and all_gather (#6770)

Co-authored-by: blzheng <beilei.zheng@intel.com>
This commit is contained in:
Chunyuan WU
2025-07-03 13:39:45 +08:00
committed by GitHub
parent 36cc3ffdc7
commit 8f844db699
3 changed files with 33 additions and 4 deletions

View File

@@ -506,9 +506,13 @@ class ModelRunner:
if _is_cpu_amx_available:
# Bind OpenMP threads to CPU cores
torch.ops.sgl_kernel.init_cpu_threads_env(self.local_omp_cpuid)
# Set local size to hint SGLang to use shared memory based AllReduce
os.environ["LOCAL_SIZE"] = str(self.tp_size)
torch.ops.sgl_kernel.initialize(self.tp_size, self.tp_rank)
else:
logger.warning(
"init_cpu_threads_env is skipped since intel amx backend is not available"
"init_cpu_threads_env and shared memory based AllReduce is disabled since intel amx backend is not available"
)
# Only initialize the distributed environment on the target model worker.