Skip to content

Commit 41d55e6

Browse files
committed
fix varlen ci test hang
1 parent 51c197c commit 41d55e6

2 files changed

Lines changed: 25 additions & 28 deletions

File tree

.github/workflows/integration_test_8gpu_rl.yaml

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -97,36 +97,15 @@ jobs:
9797
# but the CI docker image only has CUDA runtime, not the toolkit.
9898
uv pip install nvidia-cuda-nvcc
9999
100-
# RL Loss Guard runs FIRST, in a clean container, so a lingering port from
101-
# the E2E suite can't collide with the generator's distributed init
102-
# (EADDRINUSE). Deterministic loss regression check on the REAL Qwen3-0.6B
103-
# (--hf-assets-path=$MODEL_PATH): real weights -> varied rewards -> non-zero
104-
# advantage -> meaningful, full-precision losses (random init gives all
105-
# zeros). The golden is arch-specific; regenerate on A10G if it changes.
106-
LOSS_FILE="torchtitan/experiments/rl/tests/assets/losses/rl_grpo_cuda.txt"
107-
# Override to trainer TP=4 + 1 generator TP=4: the config's TP=2 OOMs with
108-
# batch-invariant on A10G; the golden is from TP=4.
109-
python torchtitan/experiments/rl/scripts/loss_compare.py \
110-
--hf-assets-path "$MODEL_PATH" \
111-
--dump-folder "$RUNNER_TEMP/artifacts-to-be-uploaded/rl_loss_guard" \
112-
--config rl_grpo_qwen3_0_6b_varlen_batch_invariant \
113-
--import-result "$LOSS_FILE" \
114-
--assert-equal \
115-
--options='--trainer.parallelism.tensor_parallel_degree 4 --generator.parallelism.tensor_parallel_degree 4 --num_generators 1'
116-
117100
# Bitwise trainer/generator parity tests (batch-invariant). Varlen and Flex
118101
# (both TP=2) run as separate torchrun invocations so each backend gets a
119102
# fresh process group and vLLM engine; nproc matches each config's
120103
# tensor_parallel_degree (the test builds ParallelDims from it).
121-
RL_TEST_DUMP_FOLDER="$RUNNER_TEMP/artifacts-to-be-uploaded" \
122-
HF_ASSETS_PATH="$MODEL_PATH" torchrun --nproc-per-node=2 -m pytest \
104+
PYTHONFAULTHANDLER=1 RL_TEST_WATCHDOG_SEC=540 \
105+
RL_TEST_DUMP_FOLDER="$RUNNER_TEMP/artifacts-to-be-uploaded" \
106+
HF_ASSETS_PATH="$MODEL_PATH" timeout -s ABRT 600 torchrun --nproc-per-node=2 -m pytest -s \
123107
torchtitan/experiments/rl/tests/test_bitwise_parity.py::TestBitwiseParityVarlen -v
124-
RL_TEST_DUMP_FOLDER="$RUNNER_TEMP/artifacts-to-be-uploaded" \
125-
HF_ASSETS_PATH="$MODEL_PATH" torchrun --nproc-per-node=2 -m pytest \
108+
PYTHONFAULTHANDLER=1 RL_TEST_WATCHDOG_SEC=540 \
109+
RL_TEST_DUMP_FOLDER="$RUNNER_TEMP/artifacts-to-be-uploaded" \
110+
HF_ASSETS_PATH="$MODEL_PATH" timeout -s ABRT 600 torchrun --nproc-per-node=2 -m pytest -s \
126111
torchtitan/experiments/rl/tests/test_bitwise_parity.py::TestBitwiseParityFlex -v
127-
128-
# Run E2E RL integration tests (up to 8 GPUs): includes the MoE TP=4 EP=4
129-
# random-init test and the batch-invariant debug tests (both need 8 GPUs).
130-
python -m torchtitan.experiments.rl.tests.integration_tests \
131-
$RUNNER_TEMP/artifacts-to-be-uploaded --ngpu 8 \
132-
--hf_assets_path "$MODEL_PATH"

torchtitan/experiments/rl/tests/test_bitwise_parity.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@
3030
torchtitan/experiments/rl/tests/test_bitwise_parity.py::TestBitwiseParityFlex -v
3131
"""
3232

33+
import faulthandler
3334
import gc
3435
import logging
3536
import os
3637
import shutil
38+
import signal
3739
import tempfile
3840
import unittest
3941

@@ -606,6 +608,16 @@ class BitwiseParityTestBase(unittest.TestCase):
606608

607609
@classmethod
608610
def setUpClass(cls):
611+
watchdog_sec = os.environ.get("RL_TEST_WATCHDOG_SEC")
612+
if watchdog_sec:
613+
faulthandler.enable()
614+
for sig in (signal.SIGTERM, signal.SIGABRT):
615+
try:
616+
faulthandler.register(sig, chain=True)
617+
except (AttributeError, ValueError, OSError):
618+
pass
619+
faulthandler.dump_traceback_later(int(watchdog_sec), exit=True)
620+
609621
world_size = (
610622
dist.get_world_size()
611623
if dist.is_initialized()
@@ -679,13 +691,19 @@ def setUpClass(cls):
679691

680692
@classmethod
681693
def tearDownClass(cls):
694+
if dist.is_initialized():
695+
dist.barrier()
682696
if hasattr(cls, "engine"):
683-
cls.engine.engine_core.shutdown()
697+
renderer = getattr(cls.engine, "renderer", None)
698+
if renderer is not None:
699+
renderer.shutdown()
684700
del cls.engine
685701
if hasattr(cls, "model"):
686702
del cls.model
687703
gc.collect()
688704
torch.cuda.empty_cache()
705+
if dist.is_initialized():
706+
dist.destroy_process_group()
689707

690708
def _assert_logprobs_equal(self, name, a, b, label_a="A", label_b="B"):
691709
"""Assert two logprob sequences are bitwise identical."""

0 commit comments

Comments
 (0)