[ROCm] Work around DeepEP teardown SIGSEGV in MoE test harness (#51174)

Signed-off-by: Rohan138 <rohanpotdar138@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rohan Potdar
2026-08-05 14:44:42 -05:00
committed by GitHub
co-authored by Claude Opus 4.8
parent e6d67fddb4
commit c2d8009044
+12
View File
@@ -6,6 +6,7 @@ DeepEP test utilities
import dataclasses import dataclasses
import os import os
import sys
import traceback import traceback
from collections.abc import Callable from collections.abc import Callable
from typing import Concatenate from typing import Concatenate
@@ -15,6 +16,7 @@ from torch.distributed import ProcessGroup
from torch.multiprocessing import spawn # pyright: ignore[reportPrivateImportUsage] from torch.multiprocessing import spawn # pyright: ignore[reportPrivateImportUsage]
from typing_extensions import ParamSpec from typing_extensions import ParamSpec
from vllm.platforms import current_platform
from vllm.utils.import_utils import has_deep_ep, has_deep_ep_v2 from vllm.utils.import_utils import has_deep_ep, has_deep_ep_v2
from vllm.utils.network_utils import get_open_port from vllm.utils.network_utils import get_open_port
@@ -72,6 +74,7 @@ def _worker_parallel_launch(
barrier = torch.tensor([rank], device=device) barrier = torch.tensor([rank], device=device)
torch.distributed.all_reduce(barrier) torch.distributed.all_reduce(barrier)
exit_code = 0
try: try:
worker( worker(
ProcessGroupInfo( ProcessGroupInfo(
@@ -88,9 +91,18 @@ def _worker_parallel_launch(
except Exception as ex: except Exception as ex:
print(ex) print(ex)
traceback.print_exc() traceback.print_exc()
exit_code = 1
raise raise
finally: finally:
torch.distributed.destroy_process_group() torch.distributed.destroy_process_group()
if current_platform.is_rocm():
# Bypass a ROCm teardown use-after-free (SIGSEGV in HIP's atexit
# handler; fixed by https://github.com/ROCm/rocm-systems/pull/6942).
# Flush first since os._exit skips it, to keep a failing traceback.
# TODO (Rohan138): Remove after ROCm 10.0 lands
sys.stdout.flush()
sys.stderr.flush()
os._exit(exit_code)
def parallel_launch( def parallel_launch(