Skip to content

Commit 33dea99

Browse files
committed
fix varlen ci test hang
1 parent 51c197c commit 33dea99

2 files changed

Lines changed: 18 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 \
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 \
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: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
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
@@ -606,6 +607,10 @@ class BitwiseParityTestBase(unittest.TestCase):
606607

607608
@classmethod
608609
def setUpClass(cls):
610+
watchdog_sec = os.environ.get("RL_TEST_WATCHDOG_SEC")
611+
if watchdog_sec:
612+
faulthandler.dump_traceback_later(int(watchdog_sec), exit=True)
613+
609614
world_size = (
610615
dist.get_world_size()
611616
if dist.is_initialized()
@@ -679,13 +684,19 @@ def setUpClass(cls):
679684

680685
@classmethod
681686
def tearDownClass(cls):
687+
if dist.is_initialized():
688+
dist.barrier()
682689
if hasattr(cls, "engine"):
683-
cls.engine.engine_core.shutdown()
690+
renderer = getattr(cls.engine, "renderer", None)
691+
if renderer is not None:
692+
renderer.shutdown()
684693
del cls.engine
685694
if hasattr(cls, "model"):
686695
del cls.model
687696
gc.collect()
688697
torch.cuda.empty_cache()
698+
if dist.is_initialized():
699+
dist.destroy_process_group()
689700

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

0 commit comments

Comments
 (0)