Compare commits

...
Author SHA1 Message Date
56cdd2c579 feat: pre-download model weights in launcher (#2282)
Release / Push CUDA image to Docker (push) Canceled after 0s
* feat: pre-download model weights in launcher instead of using HF_HUB_OFFLINE

Remove hardcoded `HF_HUB_OFFLINE=1` from multi-node SLURM templates and
instead pre-download model weights via `snapshot_download` in the rl/sft
launchers before dispatching to local or SLURM execution. This ensures
weights are cached on the shared filesystem before training starts,
removing the need to manually pre-download models.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: pre-download model weights in launcher instead of using HF_HUB_OFFLINE

Remove hardcoded `HF_HUB_OFFLINE=1` from multi-node SLURM templates and
instead pre-download model weights via `snapshot_download` in the rl/sft
launchers before dispatching to local or SLURM execution. This ensures
weights are cached on the shared filesystem before training starts,
removing the need to manually pre-download models.

Also replace `format_time` with the verifiers-style two-unit display
(e.g. "1h 30m" instead of "1.50h").

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* refactor: move pre_download_model to trainer.model

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: log cache path when model is already downloaded

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: remove redundant cache log from pre_download_model

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: move pre_download_model import to module top

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: skip download and log cache path when model already cached

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Revert "feat: skip download and log cache path when model already cached"

This reverts commit 5b2bac9f2bb9e22ae898fe54f66f48357931dc40.

* chore: keep HF_HUB_OFFLINE=1 in SLURM templates

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 19:51:04 -07:00
4dcf86f0ea feat: set tool_call_parser default to 'auto' (#2285)
Release / Push CUDA image to Docker (push) Canceled after 0s
* feat: set tool_call_parser default to 'auto'

Changed the default value of tool_call_parser from None to 'auto' to enable automatic tool call parser detection from model name by default. This provides better out-of-the-box experience for users working with tool-calling models.

* test: add unit tests for inference metrics collector

Tests parsing, aggregation (sum/max/mean), counter rates, histogram
latency, counter reset handling, server failures, and wandb logging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Revert "test: add unit tests for inference metrics collector"

This reverts commit 48eb049144b51ec9a2562358b398c2be46bc8eca.

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 18:16:10 -07:00
5 changed files with 48 additions and 21 deletions
+1 -1
View File
@@ -85,7 +85,7 @@ class ModelConfig(BaseModelConfig):
description="The tool call parser to use. Passed to vLLM as `--tool-call-parser`. "
'Set to "auto" to infer from the model name.',
),
] = None
] = "auto"
reasoning_parser: Annotated[
str | None,
+4
View File
@@ -13,6 +13,7 @@ import pynvml
import tomli_w
from prime_rl.configs.rl import RLConfig
from prime_rl.trainer.model import pre_download_model
from prime_rl.utils.config import cli
from prime_rl.utils.logger import get_logger, setup_logger
from prime_rl.utils.pathing import (
@@ -557,6 +558,9 @@ def rl(config: RLConfig):
get_logger().info(f"Resuming from step {resume_step}, cleaning future rollouts and broadcasts")
clean_future_steps(config.output_dir, resume_step)
if not config.dry_run:
pre_download_model(config.trainer.model.name)
if config.slurm is not None:
rl_slurm(config)
else:
+4
View File
@@ -9,6 +9,7 @@ from threading import Event, Thread
import tomli_w
from prime_rl.configs.sft import SFTConfig
from prime_rl.trainer.model import pre_download_model
from prime_rl.utils.config import cli
from prime_rl.utils.logger import setup_logger
from prime_rl.utils.pathing import format_log_message, get_config_dir, get_log_dir, validate_output_dir
@@ -196,6 +197,9 @@ def sft(config: SFTConfig):
validate_output_dir(config.output_dir, resuming=resuming, clean=clean)
config.output_dir.mkdir(parents=True, exist_ok=True)
if not config.dry_run:
pre_download_model(config.model.name)
if config.slurm is not None:
sft_slurm(config)
else:
+14
View File
@@ -53,9 +53,23 @@ from prime_rl.trainer.weights import (
)
from prime_rl.trainer.world import get_world
from prime_rl.utils.logger import get_logger
from prime_rl.utils.utils import format_time
from prime_rl.utils.vlm import get_language_model, get_vision_encoder, is_vlm_architecture
def pre_download_model(model_name: str) -> None:
"""Pre-download model from HuggingFace Hub so all nodes have cached weights before training."""
if Path(model_name).exists():
get_logger().info(f"Model {model_name} found at local path, skipping download")
return
get_logger().info(f"Pre-downloading model {model_name}")
t0 = time.perf_counter()
path = snapshot_download(repo_id=model_name, repo_type="model")
get_logger().debug(
f"Finished pre-downloading model {model_name} to {path} in {format_time(time.perf_counter() - t0)}"
)
def _patch_qwen3_5_moe_conversion_mapping():
"""Fix Qwen3.5 MoE conversion mapping incorrectly applying qwen2_moe expert weight splitting.
+25 -20
View File
@@ -206,27 +206,32 @@ def to_row_format(dict_of_lists: dict[str, list[Any]]) -> list[dict[str, Any]]:
return [dict(zip(dict_of_lists.keys(), values)) for values in zip(*dict_of_lists.values())]
def format_time(time_in_seconds: float) -> str:
"""Format a time in seconds to a human-readable format."""
from datetime import timedelta
td = timedelta(seconds=time_in_seconds)
days = td.days
hours, remainder = divmod(td.seconds, 3600)
minutes, seconds = divmod(remainder, 60)
# Format based on magnitude
if days > 0:
total_hours = days * 24 + hours
return f"{total_hours + minutes / 60:.2f}h"
elif hours > 0:
return f"{hours + minutes / 60:.2f}h"
elif minutes > 0:
return f"{minutes + seconds / 60:.2f}m"
def format_time(time_s: float) -> str:
"""
Format a time in seconds to a human-readable format:
- >1d -> Xd Yh
- >1h -> Xh Ym
- >1m -> Xm Ys
- <1s -> Xms
- Else: Xs
"""
if time_s >= 86400:
d = time_s // 86400
h = (time_s % 86400) // 3600
return f"{d:.0f}d" + (f" {h:.0f}h" if h > 0 else "")
elif time_s >= 3600:
h = time_s // 3600
m = (time_s % 3600) // 60
return f"{h:.0f}h" + (f" {m:.0f}m" if m > 0 else "")
elif time_s >= 60:
m = time_s // 60
s = (time_s % 60) // 1
return f"{m:.0f}m" + (f" {s:.0f}s" if s > 0 else "")
elif time_s < 1:
ms = time_s * 1e3
return f"{ms:.0f}ms"
else:
# Include microseconds for sub-second precision
total_seconds = seconds + td.microseconds / 1_000_000
return f"{total_seconds:.2f}s"
return f"{time_s:.0f}s"
def format_num(num: float | int, precision: int = 2) -> str: