Skip to content

Commit f6e858d

Browse files
committed
replace torch.cuda.synchronize() with current_platform.synchronize()
Signed-off-by: Kunshang Ji <kunshang.ji@intel.com>
1 parent b982476 commit f6e858d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

vllm/distributed/eplb/eplb_state.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from vllm.distributed.parallel_state import get_ep_group, get_node_count
3838
from vllm.logger import init_logger
3939
from vllm.model_executor.models.interfaces import MixtureOfExperts
40+
from vllm.platforms import current_platform
4041

4142
from .rebalance_algo import rebalance_experts
4243
from .rebalance_execute import rearrange_expert_weights_inplace
@@ -348,7 +349,7 @@ def rearrange(self,
348349
time_start = None
349350
is_main_rank = ep_rank == 0
350351
if is_main_rank:
351-
torch.cuda.synchronize()
352+
current_platform.synchronize()
352353
time_start = time.perf_counter()
353354
logger.info("Rearranging experts %s...",
354355
"(profile)" if is_profile else "")
@@ -423,7 +424,7 @@ def rearrange(self,
423424

424425
if is_main_rank:
425426
assert time_start is not None
426-
torch.cuda.synchronize()
427+
current_platform.synchronize()
427428
time_end = time.perf_counter()
428429
logger.info(
429430
"Rearranged experts%sin %.2f seconds.",

vllm/distributed/eplb/rebalance_execute.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
from torch.distributed import (P2POp, ProcessGroup, all_gather,
1414
batch_isend_irecv, get_global_rank)
1515

16+
from vllm.platforms import current_platform
17+
1618

1719
def idx_local_to_global(
1820
local_idx: int,
@@ -292,7 +294,7 @@ def rearrange_expert_weights_inplace(
292294
for layer in range(num_moe_layers):
293295
# NOTE(bowen): We need this synchronize to run, but I don't know why.
294296
# If you figure out the reason, please let me know -- thank you!
295-
torch.cuda.synchronize()
297+
current_platform.synchronize()
296298
shuffle_layer(
297299
num_local_physical_experts,
298300
ep_rank,

0 commit comments

Comments
 (0)