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
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
"""Test-internal compact-rollout helpers used by ``test_qwen2.5_0.5B_fanout_short.py``.

The underscore prefix marks this as test infrastructure — it is not part
of the user-facing slime API and is not re-exported anywhere. It lives
in ``slime/`` only so the test can reference it by a dotted module path
(``--custom-generate-function-path`` / ``--custom-reward-post-process-path``
resolve a string via ``importlib.import_module``, which can't handle the
dots in the e2e test's filename).
"""Compact-rollout helpers for ``test_qwen2.5_0.5B_fanout_short.py``.

These helpers are imported by module path from the Ray job started by the E2E
test. They live on the test-only portion of ``PYTHONPATH`` because they are
test fixtures, not part of slime's public or internal runtime API.

Two helpers:

Expand Down
22 changes: 13 additions & 9 deletions tests/test_qwen2.5_0.5B_fanout_short.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
num_rollouts (not num_samples), keeping grad magnitude stable
independent of fan-out

The fan-out function itself lives in
``slime/rollout/_fanout_test_helpers.py`` — it has to be at a dot-free
module path so ``importlib.import_module`` can resolve the string
``--custom-generate-function-path`` flag (this filename has dots).
The fan-out functions live in ``tests/fanout_test_helpers.py``. The
dedicated helper module gives ``importlib.import_module`` a valid module
path even though this E2E test's filename itself contains dots.

Test choices
------------
Expand All @@ -47,6 +46,7 @@
MODEL_NAME = "Qwen2.5-0.5B-Instruct"
MODEL_TYPE = "qwen2.5-0.5B"
NUM_GPUS = 4
TESTS_DIR = os.path.dirname(os.path.abspath(__file__))

# Counter file used by the compact_generate helper. We pass its path
# through to the Ray-submitted job via an env var so all worker
Expand Down Expand Up @@ -99,7 +99,7 @@ def execute():
"--rollout-temperature 0.8 "
"--global-batch-size 4 "
"--balance-data "
"--custom-generate-function-path slime.rollout._fanout_test_helpers.compact_generate "
"--custom-generate-function-path fanout_test_helpers.compact_generate "
# GRPO normalization needs per-prompt grouping. The default
# ``_post_process_rewards`` (slime/ray/rollout.py:618) reshapes
# by ``n_samples_per_prompt`` and falls back to "one big group"
Expand All @@ -109,7 +109,7 @@ def execute():
# compact_generate preserves it across siblings) so each prompt's
# siblings normalize against each other, matching the GRPO
# semantics the default targets in the uniform case.
"--custom-reward-post-process-path slime.rollout._fanout_test_helpers.grpo_normalize_by_group_index "
"--custom-reward-post-process-path fanout_test_helpers.grpo_normalize_by_group_index "
)

perf_args = (
Expand Down Expand Up @@ -186,9 +186,13 @@ def execute():
train_args=train_args,
num_gpus_per_node=NUM_GPUS,
megatron_model_type=MODEL_TYPE,
# Make the counter path visible inside the Ray-submitted job
# (helper picks it up via os.environ).
extra_env_vars={"SLIME_FANOUT_TEST_COUNTER_FILE": FANOUT_COUNTER_FILE},
extra_env_vars={
# Make the helper importable by both the Ray driver and workers
# without installing test modules as part of the slime package.
"PYTHONPATH": f"{TESTS_DIR}:{U.repo_base_dir}:/root/Megatron-LM/",
# The helper picks up the shared counter path via os.environ.
"SLIME_FANOUT_TEST_COUNTER_FILE": FANOUT_COUNTER_FILE,
},
)

# Post-train assertion: compact_generate must have been called exactly
Expand Down
Loading