Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 55 additions & 5 deletions tests/ci/gpu_lock_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import fcntl
import os
import random
import signal
import subprocess
import sys
import time

Expand All @@ -25,14 +27,64 @@ def main():
os.environ[args.target_env_name] = dev_list
print(f"[gpu_lock_exec] Acquired GPUs: {dev_list}", flush=True)

_os_execvp(args)
try:
exit_code = _run_command(args)
finally:
for fd_lock in fd_locks:
fd_lock.close()
sys.exit(exit_code)


def _os_execvp(args):
def _run_command(args):
cmd = args.cmd
if cmd[0] == "--":
cmd = cmd[1:]
os.execvp(cmd[0], cmd)

child = subprocess.Popen(cmd, start_new_session=True)

def terminate_child(signum, _frame):
if child.poll() is None:
child.terminate()
try:
child.wait(timeout=5)
sys.exit(128 + signum)
except subprocess.TimeoutExpired:
pass

try:
os.killpg(child.pid, signum)
except ProcessLookupError:
pass
try:
child.wait(timeout=5)
except subprocess.TimeoutExpired:
try:
os.killpg(child.pid, signal.SIGKILL)
except ProcessLookupError:
pass
child.wait()
sys.exit(128 + signum)

previous_handlers = {}
for signum in (signal.SIGINT, signal.SIGTERM, signal.SIGHUP):
previous_handlers[signum] = signal.getsignal(signum)
signal.signal(signum, terminate_child)

try:
while True:
returncode = child.poll()
if returncode is not None:
return _normalize_returncode(returncode)
time.sleep(1)
finally:
for signum, handler in previous_handlers.items():
signal.signal(signum, handler)


def _normalize_returncode(returncode: int) -> int:
if returncode < 0:
return 128 - returncode
return returncode


def _parse_args():
Expand Down Expand Up @@ -155,8 +207,6 @@ def __init__(self, path_pattern, gpu_id: int):
def open(self):
assert self.fd is None
self.fd = open(self.path, "a+")
# try to avoid lock disappear when execvp
os.set_inheritable(self.fd.fileno(), True)

def lock(self):
assert self.fd is not None
Expand Down
2 changes: 1 addition & 1 deletion tests/test_glm4.7_30B_A3B_pd_mooncake.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def execute():
"--recompute-method uniform "
"--recompute-num-layers 1 "
"--use-dynamic-batch-size "
"--max-tokens-per-gpu 2048 "
"--max-tokens-per-gpu 8192 "
)
vllm_args = (
"--rollout-num-gpus 8 "
Expand Down
2 changes: 1 addition & 1 deletion tests/test_metric_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
)


@pytest.fixture
NUM_GPUS = 0


@pytest.fixture
def mock_dp_with_cp_group(monkeypatch):
"""A sentinel "process group" object plus a no-op ``dist.all_reduce``.

Expand Down
5 changes: 2 additions & 3 deletions tests/test_moonlight_16B_A3B.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import vime.utils.external_utils.command_utils as U

ENABLE_EVAL = bool(int(os.environ.get("VIME_TEST_ENABLE_EVAL", "1")))
TIGHT_HOST_MEMORY = bool(int(os.environ.get("VIME_TEST_TIGHT_HOST_MEMORY", "1")))

MODEL_NAME = "Moonlight-16B-A3B-Instruct"
MODEL_TYPE = "moonlight"
Expand Down Expand Up @@ -57,12 +56,12 @@ def execute():
"--recompute-method uniform "
"--recompute-num-layers 1 "
"--use-dynamic-batch-size "
f"--max-tokens-per-gpu {2048 if TIGHT_HOST_MEMORY else 2048} "
"--max-tokens-per-gpu 8192 "
)

grpo_args = (
"--advantage-estimator gspo "
f"{'' if TIGHT_HOST_MEMORY else '--use-kl-loss '}"
"--use-kl-loss "
"--kl-loss-coef 0.00 "
"--kl-loss-type low_var_kl "
"--kl-coef 0.00 "
Expand Down
5 changes: 2 additions & 3 deletions tests/test_moonlight_16B_A3B_r3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import vime.utils.external_utils.command_utils as U

ENABLE_EVAL = bool(int(os.environ.get("VIME_TEST_ENABLE_EVAL", "1")))
TIGHT_HOST_MEMORY = bool(int(os.environ.get("VIME_TEST_TIGHT_HOST_MEMORY", "1")))

MODEL_NAME = "Moonlight-16B-A3B-Instruct"
MODEL_TYPE = "moonlight"
Expand Down Expand Up @@ -57,12 +56,12 @@ def execute():
"--recompute-method uniform "
"--recompute-num-layers 1 "
"--use-dynamic-batch-size "
f"--max-tokens-per-gpu {2048 if TIGHT_HOST_MEMORY else 2048} "
"--max-tokens-per-gpu 8192 "
)

grpo_args = (
"--advantage-estimator gspo "
f"{'' if TIGHT_HOST_MEMORY else '--use-kl-loss '}"
"--use-kl-loss "
"--kl-loss-coef 0.00 "
"--kl-loss-type low_var_kl "
"--kl-coef 0.00 "
Expand Down
1 change: 0 additions & 1 deletion tests/test_qwen2.5_0.5B_async_short.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import vime.utils.external_utils.command_utils as U


MODEL_NAME = "Qwen2.5-0.5B-Instruct"
MODEL_TYPE = "qwen2.5-0.5B"
NUM_GPUS = 4
Expand Down
4 changes: 1 addition & 3 deletions tests/test_qwen2.5_0.5B_debug_rollout_then_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ def execute_rollout_only(debug_data_dir: str):
"""Phase 1: rollout-only, save data."""

vllm_args = (
"--rollout-num-gpus-per-engine 1 "
"--vllm-gpu-memory-utilization 0.7 "
"--vllm-max-cudagraph-capture-size 16 "
"--rollout-num-gpus-per-engine 1 " "--vllm-gpu-memory-utilization 0.7 " "--vllm-max-cudagraph-capture-size 16 "
)

phase1_args = (
Expand Down
10 changes: 4 additions & 6 deletions tests/test_qwen2.5_0.5B_fanout_short.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ def prepare():
def execute():
ckpt_args = f"--hf-checkpoint /root/models/{MODEL_NAME}/ " f"--ref-load /root/models/{MODEL_NAME}/ "

# Shape: rollout_batch_size=8 prompts, n_samples_per_prompt=1 (all
# Shape: rollout_batch_size=4 prompts, n_samples_per_prompt=1 (all
# fan-out is owned by compact_generate; this knob stays at 1 so a
# regression that confuses sample count vs rollout count surfaces),
# global_batch_size=4 → 2 training steps per rollout, num_rollout=3
# → 6 total training steps.
# global_batch_size=4 → 1 training step per rollout, num_rollout=2
# → 2 total training steps.
#
# NB no ``--group-rm``: when custom_generate returns ``list[Sample]``
# the per-sample rm path inside ``generate_and_rm`` (vllm_rollout.py)
Expand Down Expand Up @@ -144,9 +144,7 @@ def execute():
)

vllm_args = (
"--rollout-num-gpus-per-engine 1 "
"--vllm-gpu-memory-utilization 0.7 "
"--vllm-max-cudagraph-capture-size 8 "
"--rollout-num-gpus-per-engine 1 " "--vllm-gpu-memory-utilization 0.7 " "--vllm-max-cudagraph-capture-size 8 "
)

ci_args = "--ci-test "
Expand Down
2 changes: 1 addition & 1 deletion tests/test_qwen2.5_0.5B_fully_async_short.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def execute():
"--expert-model-parallel-size 1 "
"--expert-tensor-parallel-size 1 "
"--use-dynamic-batch-size "
"--max-tokens-per-gpu 9216 "
"--max-tokens-per-gpu 4096 "
)

grpo_args = (
Expand Down
1 change: 0 additions & 1 deletion tests/test_qwen2.5_0.5B_opd_vllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import vime.utils.external_utils.command_utils as U


MODEL_NAME = "Qwen2.5-0.5B-Instruct"
MODEL_TYPE = "qwen2.5-0.5B"
NUM_GPUS = 8
Expand Down
3 changes: 1 addition & 2 deletions tests/test_qwen2.5_0.5B_ppo_critic_only_short.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import vime.utils.external_utils.command_utils as U


MODEL_NAME = "Qwen2.5-0.5B-Instruct"
MODEL_TYPE = "qwen2.5-0.5B"
NUM_GPUS = 4
Expand Down Expand Up @@ -68,7 +67,7 @@ def execute():
"--kl-coef 0.00 "
"--entropy-coef 0.00 "
"--eps-clip 4e-4 "
"--num-critic-only-steps 3 "
"--num-critic-only-steps 2 "
"--normalize-advantages "
)

Expand Down
5 changes: 1 addition & 4 deletions tests/test_qwen2.5_0.5B_short.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import vime.utils.external_utils.command_utils as U


MODEL_NAME = "Qwen2.5-0.5B-Instruct"
MODEL_TYPE = "qwen2.5-0.5B"
NUM_GPUS = 4
Expand Down Expand Up @@ -63,9 +62,7 @@ def execute():
)

vllm_args = (
"--rollout-num-gpus-per-engine 1 "
"--vllm-gpu-memory-utilization 0.7 "
"--vllm-max-cudagraph-capture-size 16 "
"--rollout-num-gpus-per-engine 1 " "--vllm-gpu-memory-utilization 0.7 " "--vllm-max-cudagraph-capture-size 16 "
)

ci_args = "--ci-test "
Expand Down
3 changes: 1 addition & 2 deletions tests/test_qwen2.5_0.5B_vllm_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import vime.utils.external_utils.command_utils as U


MODEL_NAME = "Qwen2.5-0.5B-Instruct"
MODEL_TYPE = "qwen2.5-0.5B"
NUM_GPUS = 8
Expand Down Expand Up @@ -54,7 +53,7 @@ def execute():
"--n-samples-per-prompt 4 "
"--rollout-max-response-len 1024 "
"--rollout-temperature 0.8 "
"--over-sampling-batch-size 16 "
"--over-sampling-batch-size 8 "
"--dynamic-sampling-filter-path vime.rollout.filter_hub.dynamic_sampling_filters.check_reward_nonzero_std "
"--global-batch-size 16 "
)
Expand Down
3 changes: 1 addition & 2 deletions tests/test_qwen2.5_0.5B_vllm_config_distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import vime.utils.external_utils.command_utils as U


MODEL_NAME = "Qwen2.5-0.5B-Instruct"
MODEL_TYPE = "qwen2.5-0.5B"
NUM_GPUS = 8
Expand Down Expand Up @@ -55,7 +54,7 @@ def execute():
"--n-samples-per-prompt 4 "
"--rollout-max-response-len 1024 "
"--rollout-temperature 0.8 "
"--over-sampling-batch-size 16 "
"--over-sampling-batch-size 8 "
"--dynamic-sampling-filter-path vime.rollout.filter_hub.dynamic_sampling_filters.check_reward_nonzero_std "
"--global-batch-size 16 "
)
Expand Down
7 changes: 2 additions & 5 deletions tests/test_qwen3.5_0.8B_gsm8k_async_short.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import vime.utils.external_utils.command_utils as U



MODEL_NAME = "Qwen3.5-0.8B"
MODEL_TYPE = "qwen3.5-0.8B"
NUM_GPUS = 4
Expand Down Expand Up @@ -37,7 +36,7 @@ def execute():
"--n-samples-per-prompt 4 "
"--rollout-max-response-len 1024 "
"--rollout-temperature 0.8 "
"--over-sampling-batch-size 16 "
"--over-sampling-batch-size 8 "
"--dynamic-sampling-filter-path vime.rollout.filter_hub.dynamic_sampling_filters.check_reward_nonzero_std "
"--global-batch-size 16 "
)
Expand Down Expand Up @@ -81,9 +80,7 @@ def execute():
)

vllm_args = (
"--rollout-num-gpus-per-engine 1 "
"--vllm-gpu-memory-utilization 0.65 "
"--vllm-max-cudagraph-capture-size 64"
"--rollout-num-gpus-per-engine 1 " "--vllm-gpu-memory-utilization 0.65 " "--vllm-max-cudagraph-capture-size 64"
)

ci_args = "--ci-test "
Expand Down
7 changes: 2 additions & 5 deletions tests/test_qwen3.5_0.8B_gsm8k_short.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import vime.utils.external_utils.command_utils as U



MODEL_NAME = "Qwen3.5-0.8B"
MODEL_TYPE = "qwen3.5-0.8B"
NUM_GPUS = 4
Expand Down Expand Up @@ -37,7 +36,7 @@ def execute():
"--n-samples-per-prompt 4 "
"--rollout-max-response-len 1024 "
"--rollout-temperature 0.8 "
"--over-sampling-batch-size 16 "
"--over-sampling-batch-size 8 "
"--dynamic-sampling-filter-path vime.rollout.filter_hub.dynamic_sampling_filters.check_reward_nonzero_std "
"--global-batch-size 16 "
)
Expand Down Expand Up @@ -81,9 +80,7 @@ def execute():
)

vllm_args = (
"--rollout-num-gpus-per-engine 1 "
"--vllm-gpu-memory-utilization 0.7 "
"--vllm-max-cudagraph-capture-size 64"
"--rollout-num-gpus-per-engine 1 " "--vllm-gpu-memory-utilization 0.7 " "--vllm-max-cudagraph-capture-size 64"
)

ci_args = "--ci-test "
Expand Down
3 changes: 1 addition & 2 deletions tests/test_qwen3_0.6B_parallel_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


ENABLE_EVAL = bool(int(os.environ.get("VIME_TEST_ENABLE_EVAL", "1")))
TIGHT_HOST_MEMORY = bool(int(os.environ.get("VIME_TEST_TIGHT_HOST_MEMORY", "1")))

MODEL_NAME = "Qwen3-0.6B"
MODEL_TYPE = "qwen3-0.6B"
Expand Down Expand Up @@ -33,7 +32,7 @@ def execute():
"--rm-type deepscaler "
"--num-rollout 1 "
"--rollout-batch-size 4 "
"--n-samples-per-prompt 8 "
"--n-samples-per-prompt 4 "
"--rollout-max-response-len 8192 "
"--rollout-temperature 0.8 "
"--global-batch-size 16 "
Expand Down
5 changes: 2 additions & 3 deletions tests/test_qwen3_30B_A3B.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


ENABLE_EVAL = bool(int(os.environ.get("VIME_TEST_ENABLE_EVAL", "1")))
TIGHT_HOST_MEMORY = bool(int(os.environ.get("VIME_TEST_TIGHT_HOST_MEMORY", "1")))
USE_DEEPEP = bool(int(os.environ.get("VIME_TEST_USE_DEEPEP", "1")))
USE_FP8_ROLLOUT = bool(int(os.environ.get("VIME_TEST_USE_FP8_ROLLOUT", "1")))

Expand Down Expand Up @@ -64,12 +63,12 @@ def execute():
"--recompute-method uniform "
"--recompute-num-layers 1 "
"--use-dynamic-batch-size "
f"--max-tokens-per-gpu {2048 if TIGHT_HOST_MEMORY else 16384} "
"--max-tokens-per-gpu 16384 "
)

grpo_args = (
"--advantage-estimator gspo "
f"{'' if TIGHT_HOST_MEMORY else '--use-kl-loss '}"
"--use-kl-loss "
"--kl-loss-coef 0.00 "
"--kl-loss-type low_var_kl "
"--kl-coef 0.00 "
Expand Down
Loading
Loading