From a2b5b85e91dc0267278a68c580f8f95798f19436 Mon Sep 17 00:00:00 2001 From: Zilin Zhu Date: Fri, 20 Feb 2026 11:53:41 +0000 Subject: [PATCH 1/5] refactor: separate sglang argparse from megatron with two-phase parsing - Add sglang_parse_args() for independent sglang arg parsing (Phase 1) - Add megatron_parse_args() / fsdp_parse_args() with ignore_unknown_args (Phase 2) - Move backend-specific validation and defaults into respective backend modules - Unify naming: sglang_parse_args, megatron_parse_args, fsdp_parse_args - Pre-parse --train-backend, --debug-* flags in _pre_parse_mode() to avoid duplication - Remove dead code parse_args_train_backend() - Add test: test_qwen2.5_0.5B_debug_rollout_then_train.py (rollout-only then train-only) - Register new test in CI (run-ci-megatron, run-ci-image) --- .github/workflows/pr-test.yml | 4 +- .github/workflows/pr-test.yml.j2 | 2 + slime/backends/fsdp_utils/__init__.py | 4 +- slime/backends/fsdp_utils/arguments.py | 13 +- slime/backends/megatron_utils/arguments.py | 72 +++++++- slime/backends/sglang_utils/arguments.py | 28 +++ slime/utils/arguments.py | 172 +++++------------- ...t_qwen2.5_0.5B_debug_rollout_then_train.py | 148 +++++++++++++++ 8 files changed, 308 insertions(+), 135 deletions(-) create mode 100644 tests/test_qwen2.5_0.5B_debug_rollout_then_train.py diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index 177103b49c..bb9afcdc4d 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -142,7 +142,7 @@ jobs: strategy: fail-fast: false matrix: - info: [{"num_gpus": 8, "test_file": "test_quick_start_glm4_9B.py"}, {"num_gpus": 8, "test_file": "test_qwen3_30B_A3B.py", "use_deepep": "1", "use_fp8_rollout": "1"}, {"enable_eval": "0", "num_gpus": 8, "test_file": "test_qwen3_30B_A3B_r3.py", "use_deepep": "1", "use_fp8_rollout": "1"}, {"enable_eval": "0", "num_gpus": 8, "test_file": "test_qwen3_30B_A3B_r3.py"}, {"num_gpus": 8, "test_file": "test_qwen3_4B_ppo.py"}, {"num_gpus": 8, "test_file": "test_moonlight_16B_A3B.py"}, {"enable_eval": "0", "num_gpus": 8, "test_file": "test_moonlight_16B_A3B_r3.py"}, {"num_gpus": 8, "test_file": "test_mimo_7B_mtp_only_grad.py"}] + info: [{"num_gpus": 8, "test_file": "test_quick_start_glm4_9B.py"}, {"num_gpus": 8, "test_file": "test_qwen3_30B_A3B.py", "use_deepep": "1", "use_fp8_rollout": "1"}, {"enable_eval": "0", "num_gpus": 8, "test_file": "test_qwen3_30B_A3B_r3.py", "use_deepep": "1", "use_fp8_rollout": "1"}, {"enable_eval": "0", "num_gpus": 8, "test_file": "test_qwen3_30B_A3B_r3.py"}, {"num_gpus": 8, "test_file": "test_qwen3_4B_ppo.py"}, {"num_gpus": 8, "test_file": "test_moonlight_16B_A3B.py"}, {"enable_eval": "0", "num_gpus": 8, "test_file": "test_moonlight_16B_A3B_r3.py"}, {"num_gpus": 8, "test_file": "test_mimo_7B_mtp_only_grad.py"}, {"num_gpus": 8, "test_file": "test_qwen2.5_0.5B_debug_rollout_then_train.py"}] defaults: run: working-directory: ${{ github.workspace }} @@ -330,7 +330,7 @@ jobs: strategy: fail-fast: false matrix: - info: [{"num_gpus": 4, "test_file": "test_qwen2.5_0.5B_gsm8k_async_short.py"}, {"num_gpus": 4, "test_file": "test_qwen2.5_0.5B_gsm8k_short.py"}, {"num_gpus": 2, "test_file": "test_qwen3_0.6B_fsdp_colocated_2xGPU.py"}, {"num_gpus": 2, "test_file": "test_qwen3_4B_fsdp_true_on_policy.py"}, {"num_gpus": 8, "test_file": "test_qwen3_vl_4B_fsdp.py"}, {"num_gpus": 2, "test_file": "test_qwen3_0.6B_fsdp_distributed.py"}, {"num_gpus": 8, "test_file": "test_quick_start_glm4_9B.py"}, {"num_gpus": 8, "test_file": "test_qwen3_30B_A3B.py"}, {"num_gpus": 8, "test_file": "test_qwen3_4B_ppo.py"}, {"num_gpus": 8, "test_file": "test_moonlight_16B_A3B.py"}, {"num_gpus": 8, "test_file": "test_mimo_7B_mtp_only_grad.py"}, {"num_gpus": 8, "test_file": "test_qwen3_0.6B_parallel_check.py"}, {"num_gpus": 4, "test_file": "test_qwen3_0.6B_megatron_fsdp_align.py"}, {"num_gpus": 8, "test_file": "test_qwen3_4B_ckpt.py"}, {"num_gpus": 8, "test_file": "test_qwen3_4B_ckpt.py --async-save"}, {"num_gpus": 2, "test_file": "test_qwen2.5_0.5B_gsm8k.py"}, {"num_gpus": 2, "test_file": "test_qwen2.5_0.5B_gsm8k_async.py"}] + info: [{"num_gpus": 4, "test_file": "test_qwen2.5_0.5B_gsm8k_async_short.py"}, {"num_gpus": 4, "test_file": "test_qwen2.5_0.5B_gsm8k_short.py"}, {"num_gpus": 2, "test_file": "test_qwen3_0.6B_fsdp_colocated_2xGPU.py"}, {"num_gpus": 2, "test_file": "test_qwen3_4B_fsdp_true_on_policy.py"}, {"num_gpus": 8, "test_file": "test_qwen3_vl_4B_fsdp.py"}, {"num_gpus": 2, "test_file": "test_qwen3_0.6B_fsdp_distributed.py"}, {"num_gpus": 8, "test_file": "test_quick_start_glm4_9B.py"}, {"num_gpus": 8, "test_file": "test_qwen3_30B_A3B.py"}, {"num_gpus": 8, "test_file": "test_qwen3_4B_ppo.py"}, {"num_gpus": 8, "test_file": "test_moonlight_16B_A3B.py"}, {"num_gpus": 8, "test_file": "test_mimo_7B_mtp_only_grad.py"}, {"num_gpus": 8, "test_file": "test_qwen3_0.6B_parallel_check.py"}, {"num_gpus": 4, "test_file": "test_qwen3_0.6B_megatron_fsdp_align.py"}, {"num_gpus": 8, "test_file": "test_qwen3_4B_ckpt.py"}, {"num_gpus": 8, "test_file": "test_qwen3_4B_ckpt.py --async-save"}, {"num_gpus": 2, "test_file": "test_qwen2.5_0.5B_gsm8k.py"}, {"num_gpus": 2, "test_file": "test_qwen2.5_0.5B_gsm8k_async.py"}, {"num_gpus": 8, "test_file": "test_qwen2.5_0.5B_debug_rollout_then_train.py"}] defaults: run: working-directory: ${{ github.workspace }} diff --git a/.github/workflows/pr-test.yml.j2 b/.github/workflows/pr-test.yml.j2 index 93be071c1c..3d19432a95 100644 --- a/.github/workflows/pr-test.yml.j2 +++ b/.github/workflows/pr-test.yml.j2 @@ -26,6 +26,7 @@ {'test_file': 'test_moonlight_16B_A3B.py', 'num_gpus': 8}, {'test_file': 'test_moonlight_16B_A3B_r3.py', 'num_gpus': 8, 'enable_eval': '0'}, {'test_file': 'test_mimo_7B_mtp_only_grad.py', 'num_gpus': 8}, + {'test_file': 'test_qwen2.5_0.5B_debug_rollout_then_train.py', 'num_gpus': 8}, ], }, 'e2e-test-precision': { @@ -72,6 +73,7 @@ {'test_file': 'test_qwen3_4B_ckpt.py --async-save', 'num_gpus': 8}, {'test_file': 'test_qwen2.5_0.5B_gsm8k.py', 'num_gpus': 2}, {'test_file': 'test_qwen2.5_0.5B_gsm8k_async.py', 'num_gpus': 2}, + {'test_file': 'test_qwen2.5_0.5B_debug_rollout_then_train.py', 'num_gpus': 8}, ], }, } %> diff --git a/slime/backends/fsdp_utils/__init__.py b/slime/backends/fsdp_utils/__init__.py index 4b792eb770..ba17c4725f 100644 --- a/slime/backends/fsdp_utils/__init__.py +++ b/slime/backends/fsdp_utils/__init__.py @@ -1,8 +1,8 @@ import logging from .actor import FSDPTrainRayActor -from .arguments import load_fsdp_args +from .arguments import fsdp_parse_args -__all__ = ["load_fsdp_args", "FSDPTrainRayActor"] +__all__ = ["fsdp_parse_args", "FSDPTrainRayActor"] logging.getLogger().setLevel(logging.WARNING) diff --git a/slime/backends/fsdp_utils/arguments.py b/slime/backends/fsdp_utils/arguments.py index 0949b8eb65..fcb83b9726 100644 --- a/slime/backends/fsdp_utils/arguments.py +++ b/slime/backends/fsdp_utils/arguments.py @@ -59,7 +59,7 @@ class FSDPArgs: config: str | None = None -def parse_fsdp_cli(extra_args_provider=None): +def _parse_fsdp_cli(extra_args_provider=None, ignore_unknown_args=False): parser = argparse.ArgumentParser("FSDP SFT Training (slime)") parser.add_argument("--config", type=str, default=None, help="YAML config path") for f in dataclasses.fields(FSDPArgs): @@ -81,16 +81,21 @@ def parse_fsdp_cli(extra_args_provider=None): if extra_args_provider is not None: parser = extra_args_provider(parser) - args = parser.parse_args() + if ignore_unknown_args: + args, _ = parser.parse_known_args() + else: + args = parser.parse_args() return args -def load_fsdp_args(extra_args_provider=None): - args = parse_fsdp_cli(extra_args_provider) +def fsdp_parse_args(extra_args_provider=None, ignore_unknown_args=False): + args = _parse_fsdp_cli(extra_args_provider, ignore_unknown_args=ignore_unknown_args) if args.config: with open(args.config) as f: data = yaml.safe_load(f) or {} for k, v in data.items(): if not hasattr(args, k): setattr(args, k, v) + args.rank = 0 # Primary process rank for wandb initialization + args.world_size = args.actor_num_nodes * args.actor_num_gpus_per_node return args diff --git a/slime/backends/megatron_utils/arguments.py b/slime/backends/megatron_utils/arguments.py index 24496011b1..e8def6c281 100644 --- a/slime/backends/megatron_utils/arguments.py +++ b/slime/backends/megatron_utils/arguments.py @@ -1,14 +1,66 @@ import logging -from megatron.training.arguments import parse_args, validate_args +from megatron.training.arguments import parse_args as _megatron_parse_args +from megatron.training.arguments import validate_args as _megatron_validate_args from megatron.training.tokenizer.tokenizer import _vocab_size_with_padding +from transformers import AutoConfig -__all__ = ["validate_args", "parse_args", "set_default_megatron_args"] +__all__ = ["validate_args", "megatron_parse_args"] logger = logging.getLogger(__name__) -def set_default_megatron_args(args): +def validate_args(args): + """Run megatron's own validate_args plus slime-specific megatron validations.""" + _megatron_validate_args(args) + + # always use varlen + args.variable_seq_lengths = True + if getattr(args, "moe_token_dispatcher_type", None) == "allgather": + logger.info( + "--moe-token-dispatcher-type allgather does not support variable sequence length, " + "please use alltoall dispatcher instead." + ) + args.moe_token_dispatcher_type = "alltoall" + + if args.pipeline_model_parallel_size == 1: + assert args.decoder_first_pipeline_num_layers is None and args.decoder_last_pipeline_num_layers is None, ( + "decoder_first_pipeline_num_layers and decoder_last_pipeline_num_layers should be None when " + "pipeline_model_parallel_size is 1." + ) + + +def _hf_validate_args(args, hf_config): + def equal(x, y): + return x == y + + errors = [] + + # multimodal models have different config structure + if hasattr(hf_config, "text_config"): + hf_config = hf_config.text_config + + for hf_config_name, megatron_config_name, compare_fn in [ + ("hidden_size", "hidden_size", equal), + ("num_attention_heads", "num_attention_heads", equal), + ("num_hidden_layers", "num_layers", equal), + ("intermediate_size", "ffn_hidden_size", equal), + ("tie_word_embeddings", "untie_embeddings_and_output_weights", lambda x, y: not x == y), + ("rms_norm_eps", "norm_epsilon", equal), + ("rope_theta", "rotary_base", equal), + ]: + if hasattr(hf_config, hf_config_name): + if not compare_fn(getattr(hf_config, hf_config_name), getattr(args, megatron_config_name)): + errors.append( + f"{hf_config_name} in hf config {getattr(hf_config, hf_config_name)} is not equal to " + f"{megatron_config_name} {getattr(args, megatron_config_name)}, please check the config." + ) + + if len(errors) > 0: + raise AssertionError("hf_validate_args failed: " + "; ".join(errors)) + + +def _set_default_megatron_args(args): # always use zero optimizer args.use_distributed_optimizer = True # TODO: maybe change this after megatron has good fp8 support @@ -31,3 +83,17 @@ def set_default_megatron_args(args): args.tokenizer_model = args.hf_checkpoint args.tokenizer_type = "HuggingFaceTokenizer" return args + + +def megatron_parse_args(extra_args_provider): + """Parse megatron args, validate HF config, and set defaults.""" + args = _megatron_parse_args(extra_args_provider=extra_args_provider, ignore_unknown_args=True) + + if args.hf_checkpoint and not args.debug_rollout_only: + hf_config = AutoConfig.from_pretrained(args.hf_checkpoint, trust_remote_code=True) + _hf_validate_args(args, hf_config) + + args.rank = 0 + args.world_size = args.actor_num_nodes * args.actor_num_gpus_per_node + args = _set_default_megatron_args(args) + return args diff --git a/slime/backends/sglang_utils/arguments.py b/slime/backends/sglang_utils/arguments.py index 610224b507..37110fa01e 100644 --- a/slime/backends/sglang_utils/arguments.py +++ b/slime/backends/sglang_utils/arguments.py @@ -1,3 +1,5 @@ +import argparse + from sglang.srt.server_args import ServerArgs from slime.utils.http_utils import _wrap_ipv6 @@ -138,3 +140,29 @@ def validate_args(args): if getattr(args, "sglang_router_ip", None): args.sglang_router_ip = _wrap_ipv6(args.sglang_router_ip) + + +def sglang_parse_args(): + """ + Parse sglang server arguments independently using a separate ArgumentParser. + Uses parse_known_args() to only consume sglang-related arguments from sys.argv, + allowing the remaining arguments to be parsed by megatron/fsdp separately. + + Returns: + argparse.Namespace: Parsed sglang arguments (all attributes prefixed with sglang_). + """ + parser = argparse.ArgumentParser(add_help=False) + add_sglang_arguments(parser) + + # Compute default sglang_tensor_parallel_size from CLI args + temp_parser = argparse.ArgumentParser(add_help=False) + temp_parser.add_argument("--rollout-num-gpus-per-engine", type=int, default=1) + temp_parser.add_argument("--sglang-pp-size", type=int, default=1) + temp_parser.add_argument("--sglang-pipeline-parallel-size", type=int, default=1) + temp_args, _ = temp_parser.parse_known_args() + pp_size = temp_args.sglang_pp_size if temp_args.sglang_pp_size != 1 else temp_args.sglang_pipeline_parallel_size + sglang_tp_size = temp_args.rollout_num_gpus_per_engine // pp_size + parser.set_defaults(sglang_tensor_parallel_size=sglang_tp_size) + + args, _ = parser.parse_known_args() + return args diff --git a/slime/utils/arguments.py b/slime/utils/arguments.py index 1abc844e59..efc023c2bd 100644 --- a/slime/utils/arguments.py +++ b/slime/utils/arguments.py @@ -6,9 +6,8 @@ import yaml from sglang_router.launch_router import RouterArgs -from transformers import AutoConfig -from slime.backends.sglang_utils.arguments import add_sglang_arguments +from slime.backends.sglang_utils.arguments import sglang_parse_args from slime.backends.sglang_utils.arguments import validate_args as sglang_validate_args from slime.utils.eval_config import EvalDatasetConfig, build_eval_dataset_configs, ensure_dataset_list from slime.utils.logging_utils import configure_logger @@ -110,13 +109,7 @@ def add_cluster_arguments(parser): return parser def add_train_arguments(parser): - parser.add_argument( - "--train-backend", - type=str, - choices=["megatron", "fsdp"], - default="megatron", - help="The backend for training.", - ) + # --train-backend is parsed early in _pre_parse_mode() and merged later. parser.add_argument( "--qkv-format", type=str, @@ -1143,40 +1136,14 @@ def add_debug_arguments(parser): "The file will be saved to `save_debug_rollout_data.format(rollout_id)`." ), ) - parser.add_argument( - "--load-debug-rollout-data", - type=str, - default=None, - help=( - "Load the rollout data from this path for debugging. " - "The file will be loaded from `load_debug_rollout_data.format(rollout_id)`. " - "When this is enabled, slime will not instantiate sglang servers." - ), - ) + # --load-debug-rollout-data, --debug-rollout-only, --debug-train-only + # are parsed early in _pre_parse_mode() and merged later. parser.add_argument( "--load-debug-rollout-data-subsample", type=float, default=None, help="Subsample a portion of the debug rollout data for faster debugging.", ) - parser.add_argument( - "--debug-rollout-only", - action="store_true", - default=False, - help=( - "Whether to only run the rollout generation without training. " - "This is useful for debugging the rollout generation function." - ), - ) - parser.add_argument( - "--debug-train-only", - action="store_true", - default=False, - help=( - "Whether to only run the training without sglang servers. " - "This is useful for debugging the rollout generation function." - ), - ) parser.add_argument( "--save-debug-train-data", type=str, @@ -1434,19 +1401,6 @@ def add_ci_arguments(parser): ) return parser - def add_sglang_tp_size(): - temp_parser = argparse.ArgumentParser(add_help=False) - temp_parser.add_argument("--rollout-num-gpus-per-engine", type=int, default=1) - temp_parser.add_argument("--sglang-pp-size", type=int, default=1) - temp_parser.add_argument("--sglang-pipeline-parallel-size", type=int, default=1) - temp_args, _ = temp_parser.parse_known_args() - # Use sglang_pp_size if set (non-default), otherwise use sglang_pipeline_parallel_size - pp_size = ( - temp_args.sglang_pp_size if temp_args.sglang_pp_size != 1 else temp_args.sglang_pipeline_parallel_size - ) - sglang_tp_size = temp_args.rollout_num_gpus_per_engine // pp_size - return sglang_tp_size - # Add custom arguments in front to prevent overwritten some slime arguments. if add_custom_arguments is not None: parser = add_custom_arguments(parser) @@ -1463,7 +1417,6 @@ def add_sglang_tp_size(): parser = add_tensorboard_arguments(parser) parser = add_router_arguments(parser) parser = add_debug_arguments(parser) - parser = add_sglang_arguments(parser) parser = add_network_arguments(parser) parser = add_reward_model_arguments(parser) parser = add_rollout_buffer_arguments(parser) @@ -1480,78 +1433,79 @@ def add_sglang_tp_size(): ) reset_arg(parser, "--padded-vocab-size", type=int, default=None) - parser.set_defaults(sglang_tensor_parallel_size=add_sglang_tp_size()) return parser return add_slime_arguments +def _pre_parse_mode(): + """Pre-parse CLI to extract arguments that control parsing flow. + + These arguments are removed from add_slime_arguments to avoid + registering them twice. The returned namespace is merged into + the final ``args`` after Phase 2 parsing. + """ + temp_parser = argparse.ArgumentParser(add_help=False) + temp_parser.add_argument("--train-backend", type=str, choices=["megatron", "fsdp"], default="megatron") + temp_parser.add_argument("--debug-rollout-only", action="store_true", default=False) + temp_parser.add_argument("--debug-train-only", action="store_true", default=False) + temp_parser.add_argument("--load-debug-rollout-data", type=str, default=None) + temp_args, _ = temp_parser.parse_known_args() + return temp_args + + def parse_args(add_custom_arguments=None): # Users may call `parse_args` very early, thus we ensure logger is configured here configure_logger() add_slime_arguments = get_slime_extra_args_provider(add_custom_arguments) - backend = parse_args_train_backend() - if backend == "megatron": - from slime.backends.megatron_utils.arguments import parse_args as megatron_parse_args - from slime.backends.megatron_utils.arguments import set_default_megatron_args + pre = _pre_parse_mode() + skip_sglang = pre.debug_train_only or pre.load_debug_rollout_data is not None + + # Phase 1: Parse sglang args independently (separate parser, parse_known_args). + # Skipped when sglang servers are not needed. + sglang_ns = None + if not skip_sglang: + sglang_ns = sglang_parse_args() + + # Phase 2: Parse megatron/fsdp + slime args. + # Uses ignore_unknown_args=True so that --sglang-* and pre-parsed CLI flags + # are silently ignored by the megatron/fsdp parser. + if pre.train_backend == "megatron": + from slime.backends.megatron_utils.arguments import megatron_parse_args from slime.backends.megatron_utils.arguments import validate_args as megatron_validate_args args = megatron_parse_args(extra_args_provider=add_slime_arguments) - if args.hf_checkpoint and not args.debug_rollout_only: - hf_config = AutoConfig.from_pretrained(args.hf_checkpoint, trust_remote_code=True) - hf_validate_args(args, hf_config) - - args.rank = 0 - args.world_size = args.actor_num_nodes * args.actor_num_gpus_per_node - args = set_default_megatron_args(args) else: logger.warning( "🚧 🚧 🚧 FSDP backend is being rewritten, please use Megatron backend for better stability. 🚧 🚧 🚧" ) - from slime.backends.fsdp_utils.arguments import load_fsdp_args + from slime.backends.fsdp_utils.arguments import fsdp_parse_args - args = load_fsdp_args(extra_args_provider=add_slime_arguments) - args.rank = 0 # Primary process rank for wandb initialization - args.world_size = args.actor_num_nodes * args.actor_num_gpus_per_node + args = fsdp_parse_args(extra_args_provider=add_slime_arguments, ignore_unknown_args=True) - slime_validate_args(args) + # Merge pre-parsed args into the main namespace + for key, value in vars(pre).items(): + setattr(args, key, value) - if backend == "megatron": - megatron_validate_args(args) + # Merge sglang args into the main namespace + if sglang_ns is not None: + for key, value in vars(sglang_ns).items(): + setattr(args, key, value) - # always use varlen - args.variable_seq_lengths = True - if getattr(args, "moe_token_dispatcher_type", None) == "allgather": - logger.info( - "--moe-token-dispatcher-type allgather does not support variable sequence length, " - "please use alltoall dispatcher instead." - ) - args.moe_token_dispatcher_type = "alltoall" + slime_validate_args(args) - if args.pipeline_model_parallel_size == 1: - assert args.decoder_first_pipeline_num_layers is None and args.decoder_last_pipeline_num_layers is None, ( - "decoder_first_pipeline_num_layers and decoder_last_pipeline_num_layers should be None when " - "pipeline_model_parallel_size is 1." - ) + if pre.train_backend == "megatron" and not args.debug_rollout_only: + megatron_validate_args(args) - sglang_validate_args(args) + if not args.debug_train_only: + sglang_validate_args(args) return args -def parse_args_train_backend(): - if os.environ.get("SLIME_BACKEND") is not None: - raise Exception("`SLIME_BACKEND` is deprecated, please use --train-backend directly.") - - parser = argparse.ArgumentParser() - get_slime_extra_args_provider()(parser) - args_partial, _ = parser.parse_known_args() - return args_partial.train_backend - - def _resolve_eval_datasets(args) -> list[EvalDatasetConfig]: """ Build evaluation dataset configurations from either --eval-config or --eval-prompt-data. @@ -1848,33 +1802,3 @@ def slime_validate_args(args): if args.only_train_params_name_list and args.freeze_params_name_list: raise ValueError("You can only specify ONE of: --only-train-params-name-list, or --freeze-params-name-list.") - - -def hf_validate_args(args, hf_config): - def equal(x, y): - return x == y - - errors = [] - - # multimodal models have different config structure - if hasattr(hf_config, "text_config"): - hf_config = hf_config.text_config - - for hf_config_name, megatron_config_name, compare_fn in [ - ("hidden_size", "hidden_size", equal), - ("num_attention_heads", "num_attention_heads", equal), - ("num_hidden_layers", "num_layers", equal), - ("intermediate_size", "ffn_hidden_size", equal), - ("tie_word_embeddings", "untie_embeddings_and_output_weights", lambda x, y: not x == y), - ("rms_norm_eps", "norm_epsilon", equal), - ("rope_theta", "rotary_base", equal), - ]: - if hasattr(hf_config, hf_config_name): - if not compare_fn(getattr(hf_config, hf_config_name), getattr(args, megatron_config_name)): - errors.append( - f"{hf_config_name} in hf config {getattr(hf_config, hf_config_name)} is not equal to " - f"{megatron_config_name} {getattr(args, megatron_config_name)}, please check the config." - ) - - if len(errors) > 0: - raise AssertionError("hf_validate_args failed: " + "; ".join(errors)) diff --git a/tests/test_qwen2.5_0.5B_debug_rollout_then_train.py b/tests/test_qwen2.5_0.5B_debug_rollout_then_train.py new file mode 100644 index 0000000000..b170e00537 --- /dev/null +++ b/tests/test_qwen2.5_0.5B_debug_rollout_then_train.py @@ -0,0 +1,148 @@ +""" +Two-phase debug test: + Phase 1 – debug_rollout_only: launch sglang, generate rollout data for 2 steps, + and save them to a temp directory. + Phase 2 – load_debug_rollout_data (train only): skip sglang entirely, load the + saved rollout data, and run 2 training steps. + +Uses Qwen2.5-0.5B-Instruct (smallest supported model) with 2 GPUs. +""" + +import os +import tempfile + +import slime.utils.external_utils.command_utils as U + +TIGHT_DEVICE_MEMORY = U.get_bool_env_var("SLIME_TEST_TIGHT_DEVICE_MEMORY", "1") + +MODEL_NAME = "Qwen2.5-0.5B-Instruct" +MODEL_TYPE = "qwen2.5-0.5B" +NUM_GPUS = 8 +NUM_ROLLOUT = 2 + + +def prepare(): + U.exec_command("mkdir -p /root/models /root/datasets") + U.exec_command(f"huggingface-cli download Qwen/{MODEL_NAME} --local-dir /root/models/{MODEL_NAME}") + U.hf_download_dataset("zhuzilin/gsm8k") + + +def _common_args(debug_data_dir: str): + """Arguments shared by both phases.""" + + ckpt_args = f"--hf-checkpoint /root/models/{MODEL_NAME}/ " f"--ref-load /root/models/{MODEL_NAME}/ " + + rollout_args = ( + "--prompt-data /root/datasets/gsm8k/train.parquet " + "--input-key messages " + "--label-key label " + "--apply-chat-template " + "--rollout-shuffle " + "--rm-type math " + f"--num-rollout {NUM_ROLLOUT} " + "--rollout-batch-size 8 " + "--n-samples-per-prompt 4 " + "--rollout-max-response-len 256 " + "--rollout-temperature 0.8 " + "--global-batch-size 32 " + ) + + perf_args = ( + "--tensor-model-parallel-size 1 " + "--sequence-parallel " + "--pipeline-model-parallel-size 1 " + "--context-parallel-size 1 " + "--expert-model-parallel-size 1 " + "--expert-tensor-parallel-size 1 " + "--use-dynamic-batch-size " + "--max-tokens-per-gpu 4096 " + ) + + grpo_args = "--advantage-estimator grpo " "--eps-clip 0.2 " + + optimizer_args = ( + "--optimizer adam " + "--lr 1e-6 " + "--lr-decay-style constant " + "--weight-decay 0.1 " + "--adam-beta1 0.9 " + "--adam-beta2 0.98 " + ) + + misc_args = ( + "--attention-dropout 0.0 " + "--hidden-dropout 0.0 " + "--accumulate-allreduce-grads-in-fp32 " + "--attention-softmax-in-fp32 " + "--attention-backend flash " + "--actor-num-nodes 1 " + "--actor-num-gpus-per-node 8 " + "--colocate " + "--megatron-to-hf-mode bridge " + ) + + return f"{ckpt_args} " f"{rollout_args} " f"{optimizer_args} " f"{grpo_args} " f"{perf_args} " f"{misc_args} " + + +def execute_rollout_only(debug_data_dir: str): + """Phase 1: rollout-only, save data.""" + + sglang_args = ( + "--rollout-num-gpus-per-engine 1 " f"--sglang-mem-fraction-static {0.6 if TIGHT_DEVICE_MEMORY else 0.7} " + ) + + phase1_args = ( + f"{_common_args(debug_data_dir)} " + f"{sglang_args} " + "--debug-rollout-only " + f"--save-debug-rollout-data {debug_data_dir}/rollout_{{rollout_id}}.pt " + ) + + print("=" * 60) + print("Phase 1: debug-rollout-only (generate + save rollout data)") + print("=" * 60) + + U.execute_train( + train_args=phase1_args, + num_gpus_per_node=NUM_GPUS, + megatron_model_type=MODEL_TYPE, + ) + + +def execute_train_only(debug_data_dir: str): + """Phase 2: train-only, load saved rollout data.""" + + phase2_args = ( + f"{_common_args(debug_data_dir)} " + f"--load-debug-rollout-data {debug_data_dir}/rollout_{{rollout_id}}.pt " + "--ci-test " + ) + + print("=" * 60) + print("Phase 2: load-debug-rollout-data (train only)") + print("=" * 60) + + U.execute_train( + train_args=phase2_args, + num_gpus_per_node=NUM_GPUS, + megatron_model_type=MODEL_TYPE, + ) + + +def execute(): + debug_data_dir = tempfile.mkdtemp(prefix="slime_debug_rollout_") + print(f"Using temp dir for rollout data: {debug_data_dir}") + + execute_rollout_only(debug_data_dir) + execute_train_only(debug_data_dir) + + print("=" * 60) + print("Both phases completed successfully!") + print("=" * 60) + + +if __name__ == "__main__": + prepare() + for proxy_var in ("http_proxy", "https_proxy", "HTTP_PROXY", "HTTPS_PROXY"): + os.environ.pop(proxy_var, None) + execute() From d3462e210baff03e3862213d2af2d73018ebfc5a Mon Sep 17 00:00:00 2001 From: Zilin Zhu Date: Fri, 20 Feb 2026 12:02:38 +0000 Subject: [PATCH 2/5] fix: re-export set_default_megatron_args for tools/convert_hf_to_torch_dist.py --- slime/backends/megatron_utils/arguments.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/slime/backends/megatron_utils/arguments.py b/slime/backends/megatron_utils/arguments.py index e8def6c281..fc6bed7b7f 100644 --- a/slime/backends/megatron_utils/arguments.py +++ b/slime/backends/megatron_utils/arguments.py @@ -5,7 +5,7 @@ from megatron.training.tokenizer.tokenizer import _vocab_size_with_padding from transformers import AutoConfig -__all__ = ["validate_args", "megatron_parse_args"] +__all__ = ["validate_args", "megatron_parse_args", "set_default_megatron_args"] logger = logging.getLogger(__name__) @@ -85,6 +85,10 @@ def _set_default_megatron_args(args): return args +# Public alias for external tools (e.g. convert_hf_to_torch_dist.py) +set_default_megatron_args = _set_default_megatron_args + + def megatron_parse_args(extra_args_provider): """Parse megatron args, validate HF config, and set defaults.""" args = _megatron_parse_args(extra_args_provider=extra_args_provider, ignore_unknown_args=True) From 2aa7ffb2fa88907a9a7cc690125fe06f3d3add0f Mon Sep 17 00:00:00 2001 From: Zilin Zhu Date: Fri, 20 Feb 2026 12:16:06 +0000 Subject: [PATCH 3/5] fix: pass skip_hf_validate to megatron_parse_args instead of accessing args.debug_rollout_only args.debug_rollout_only is now set by _pre_parse_mode and merged after megatron_parse_args returns, so it's not available during parsing. --- slime/backends/megatron_utils/arguments.py | 4 ++-- slime/utils/arguments.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/slime/backends/megatron_utils/arguments.py b/slime/backends/megatron_utils/arguments.py index fc6bed7b7f..8be842c977 100644 --- a/slime/backends/megatron_utils/arguments.py +++ b/slime/backends/megatron_utils/arguments.py @@ -89,11 +89,11 @@ def _set_default_megatron_args(args): set_default_megatron_args = _set_default_megatron_args -def megatron_parse_args(extra_args_provider): +def megatron_parse_args(extra_args_provider, skip_hf_validate=False): """Parse megatron args, validate HF config, and set defaults.""" args = _megatron_parse_args(extra_args_provider=extra_args_provider, ignore_unknown_args=True) - if args.hf_checkpoint and not args.debug_rollout_only: + if args.hf_checkpoint and not skip_hf_validate: hf_config = AutoConfig.from_pretrained(args.hf_checkpoint, trust_remote_code=True) _hf_validate_args(args, hf_config) diff --git a/slime/utils/arguments.py b/slime/utils/arguments.py index efc023c2bd..94c713da8a 100644 --- a/slime/utils/arguments.py +++ b/slime/utils/arguments.py @@ -1476,7 +1476,10 @@ def parse_args(add_custom_arguments=None): from slime.backends.megatron_utils.arguments import megatron_parse_args from slime.backends.megatron_utils.arguments import validate_args as megatron_validate_args - args = megatron_parse_args(extra_args_provider=add_slime_arguments) + args = megatron_parse_args( + extra_args_provider=add_slime_arguments, + skip_hf_validate=pre.debug_rollout_only, + ) else: logger.warning( "🚧 🚧 🚧 FSDP backend is being rewritten, please use Megatron backend for better stability. 🚧 🚧 🚧" From 70cafe841a157ff3b128d7d99a1533ca6216fc3f Mon Sep 17 00:00:00 2001 From: Zilin Zhu Date: Fri, 20 Feb 2026 12:28:58 +0000 Subject: [PATCH 4/5] docs: add issue templates and CONTRIBUTING.md with collaboration scope --- .github/ISSUE_TEMPLATE/bug_report.yml | 102 ++++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 16 ++++ .github/ISSUE_TEMPLATE/question.yml | 72 ++++++++++++++++++ CONTRIBUTING.md | 87 ++++++++++++++++++++++ 4 files changed, 277 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/question.yml create mode 100644 CONTRIBUTING.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000000..a51e352ef2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,102 @@ +name: Bug Report +description: Report a bug to help us improve slime. Please check the docs and existing issues before submitting. +title: "[Bug] " +labels: ["bug"] +body: + - type: markdown + attributes: + value: | + Thank you for taking the time to report a bug! + + > **Note:** slime focuses open-source collaboration on **bug fixes** and **general-purpose RL optimizations**. + > Feature requests are not accepted — please read [CONTRIBUTING.md](https://github.com/THUDM/slime/blob/main/CONTRIBUTING.md) for details. + + Before submitting, please make sure you have: + - [ ] Read the [documentation](https://thudm.github.io/slime/) and [FAQ](https://thudm.github.io/slime/en/get_started/qa.html) + - [ ] Searched [existing issues](https://github.com/THUDM/slime/issues) to avoid duplicates + - [ ] Reproduced the issue with the latest version of slime + + - type: textarea + id: description + attributes: + label: Bug Description + description: A clear and concise description of what the bug is. + placeholder: Describe the bug here... + validations: + required: true + + - type: textarea + id: reproduction + attributes: + label: Steps to Reproduce + description: | + Please provide a minimal, reproducible example. Include the full command you used and any relevant configuration. + Issues without clear reproduction steps may be closed. + placeholder: | + 1. Run the following command: `...` + 2. With the following config: `...` + 3. Observe the error... + validations: + required: true + + - type: textarea + id: expected + attributes: + label: Expected Behavior + description: What did you expect to happen? + validations: + required: true + + - type: textarea + id: actual + attributes: + label: Actual Behavior + description: What actually happened? Please include the **full error message and traceback** if applicable. + validations: + required: true + + - type: textarea + id: environment + attributes: + label: Environment + description: | + Please provide your environment details. You can run `pip show slime` and `python -c "import torch; print(torch.__version__)"` to get some of this info. + value: | + - slime version: + - Python version: + - PyTorch version: + - CUDA/ROCm version: + - GPU type and count: + - OS: + - SGLang version (if relevant): + - Megatron-LM version (if relevant): + validations: + required: true + + - type: textarea + id: logs + attributes: + label: Logs + description: | + Please paste any relevant log output here. This will be automatically formatted into code, so no need for backticks. + render: shell + + - type: textarea + id: additional + attributes: + label: Additional Context + description: Add any other context, screenshots, or config files that might help us understand the issue. + + - type: checkboxes + id: checklist + attributes: + label: Pre-submission Checklist + options: + - label: I have read the [CONTRIBUTING.md](https://github.com/THUDM/slime/blob/main/CONTRIBUTING.md) and understand the collaboration scope. + required: true + - label: I have read the [documentation](https://thudm.github.io/slime/) and my issue is not addressed there. + required: true + - label: I have searched for [existing issues](https://github.com/THUDM/slime/issues) and this is not a duplicate. + required: true + - label: I have provided a minimal, reproducible example. + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000000..cc3ac96919 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,16 @@ +blank_issues_enabled: false +contact_links: + - name: Collaboration Scope / 协作范围 + url: https://github.com/THUDM/slime/blob/main/CONTRIBUTING.md + about: | + Please read before submitting. We accept bug reports and general RL optimizations, but do NOT accept feature requests. + 提交前请阅读。我们接受 bug 报告和通用 RL 优化,但不接受 feature request。 + - name: Documentation + url: https://thudm.github.io/slime/ + about: Please check the documentation before opening an issue. Many common questions are already answered there. + - name: Q&A / FAQ + url: https://thudm.github.io/slime/en/get_started/qa.html + about: Check the FAQ — your question might already have an answer. + - name: Discussions + url: https://github.com/THUDM/slime/discussions + about: For general questions and open-ended conversations, please use GitHub Discussions instead. diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml new file mode 100644 index 0000000000..5b06451caa --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -0,0 +1,72 @@ +name: Question / Help +description: Ask a question about using slime. Please check the docs and FAQ first. +title: "[Question] " +labels: ["question"] +body: + - type: markdown + attributes: + value: | + Thank you for reaching out! + + > **Note:** slime focuses open-source collaboration on **bug fixes** and **general-purpose RL optimizations**. + > Feature requests are not accepted — please read [CONTRIBUTING.md](https://github.com/THUDM/slime/blob/main/CONTRIBUTING.md) for details. + + Before asking, please make sure you have checked: + - [Quick Start Guide](https://thudm.github.io/slime/en/get_started/quick_start.html) + - [Usage Guide](https://thudm.github.io/slime/en/get_started/usage.html) + - [FAQ](https://thudm.github.io/slime/en/get_started/qa.html) + - [Examples](https://github.com/THUDM/slime/tree/main/examples) + + Many common questions are already covered in the documentation above. If your question is about general usage or open-ended discussion, consider using [GitHub Discussions](https://github.com/THUDM/slime/discussions) instead. + + - type: textarea + id: question + attributes: + label: Your Question + description: Describe your question clearly. Include enough context so we can understand what you're trying to achieve. + placeholder: I'm trying to ... and I'm confused about ... + validations: + required: true + + - type: textarea + id: what-tried + attributes: + label: What I've Tried + description: | + Please describe what you have already tried. This helps us avoid suggesting things you've already done, and shows us that you've done your homework. + placeholder: | + - I read the Quick Start Guide and followed the steps, but ... + - I tried modifying the config to ..., but got ... + validations: + required: true + + - type: textarea + id: environment + attributes: + label: Environment (if relevant) + description: If your question is related to setup or runtime behavior, please provide your environment details. + value: | + - slime version: + - Python version: + - PyTorch version: + - CUDA/ROCm version: + - GPU type and count: + - OS: + + - type: textarea + id: additional + attributes: + label: Additional Context + description: Add any other context, logs, config files, or screenshots that might help us answer your question. + + - type: checkboxes + id: checklist + attributes: + label: Pre-submission Checklist + options: + - label: I have read the [CONTRIBUTING.md](https://github.com/THUDM/slime/blob/main/CONTRIBUTING.md) and understand the collaboration scope. + required: true + - label: I have read the [documentation](https://thudm.github.io/slime/) and [FAQ](https://thudm.github.io/slime/en/get_started/qa.html) and my question is not answered there. + required: true + - label: I have searched for [existing issues](https://github.com/THUDM/slime/issues) and my question has not been asked before. + required: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..545fcad773 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,87 @@ +# Contributing to slime + +[中文版](#开源协作范围说明) + +Thank you for your interest in contributing to slime! We deeply appreciate every contribution from the community. To keep the project healthy and sustainable, please read this document carefully before submitting issues or pull requests. + +## Collaboration Scope + +slime is the RL training infrastructure behind [GLM-4.5 through GLM-4.7](https://z.ai) and a large number of internal experiments at Zhipu AI. We open-sourced slime because we believe the training scenarios used internally cover the majority of cutting-edge RL algorithm requirements, and we hope to provide the community with a correct and efficient large-scale RL training infrastructure. + +Our goal for open-source collaboration is focused on **bug fixes** and **general-purpose large-scale RL optimizations**. We have had several successful collaborations with the community in this area, including: + +- Speculative decoding in RL ([docs](https://thudm.github.io/slime/en/advanced/speculative_decoding.html)) +- Low-precision training: fp8 rollout + bf16/fp8 training, int4 rollout + int4 QAT training ([docs](https://thudm.github.io/slime/en/advanced/low_precision_training.html)) +- Deterministic training ([docs](https://thudm.github.io/slime/en/advanced/reproducibility.html)) + +### What We Welcome + +| Category | Examples | +|----------|----------| +| **Bug reports** | Crashes, incorrect results, documentation errors | +| **Bug fixes** | PRs that fix existing issues with tests or clear reproduction | +| **General RL optimizations** | Performance improvements with clear benchmarks that can be verified through CI or standard training runs | + +### What We Cannot Accept + +| Category | Reason | +|----------|--------| +| **Large-scale code refactoring** | Significantly increases the burden of syncing between the internal and open-source versions, especially in communication with internal algorithm teams. | +| **Design / abstraction proposals** | e.g., universal data standards, eval standards, tool base classes. Standard-setting involves non-technical factors; slime intentionally avoids such content to keep things flexible for both the community and internal teams. | +| **Features that cannot be clearly verified** | Correctness is the lifeline of a training framework. If a feature cannot be verified through CI or routine internal training, we cannot ensure timely fixes, which poses a serious risk to the project's reputation. | +| **Features independent of the RL framework** | e.g., full algorithm reproduction pipelines. While these lower the barrier to entry, they are difficult to include in routine verification. slime aims to be lightweight — more like Flask than Django. We recommend building such pipelines in separate repositories; we are happy to reference them in the README. | +| **Major modifications to Megatron** | We do not plan to maintain a Megatron fork through slime. The goal is to switch Megatron versions relatively painlessly; Megatron performance optimization and feature completion are not primary objectives. | + +### Why This Policy? + +slime's design and development roadmap must first align with Zhipu AI's internal requirements — the RL infrastructure design is tightly coupled with post-training plans, and publishing the full post-training R&D roadmap is not within the open-source scope of slime. This focused scope is what we believe is necessary to maintain slime as a long-term, trustworthy project. + +We understand this may slow down slime's pace of feature development. We are actively expanding the slime team through hiring to address this — if you're interested, feel free to reach out directly. + +Thank you for your understanding. We sincerely apologize for any inconvenience this policy may cause to community contributors who have invested their efforts. + +--- + +## 开源协作范围说明 + +感谢你对 slime 的关注和支持!社区的每一份贡献我们都非常珍视。为了保证项目的长期健康发展,请在提交 issue 或 PR 之前仔细阅读以下内容。 + +### 背景 + +slime 承担了智谱内部的大量实验,包括 GLM 4.5 至 4.7 的全部 RL 流程,以及大量的日常实验。我们开源的初衷是相信智谱内部的训练场景覆盖了大多数前沿算法需求,希望能够为社区提供一套**正确且高效**的大规模 RL 训练 Infra,同时也希望在此基础上和社区进行 Infra 性能优化上的共建。 + +在我们的已知范围内,目前只有极少的前沿大模型团队愿意公开如此核心且完整的 Infra 组件——这背后是公司对开源社区的极大热情。相应的,从维护者的角度,我们会充分利用这个开明的政策,让智谱内部使用的 slime 与开源版本同步,保持核心竞争力;同时,我们也不能因为开源而拖慢了内部的研发节奏。这意味着 slime 的设计与开发 roadmap 需要首先参考智谱内部的需求,而不能完全在开源社区内进行讨论。 + +### 协作范围 + +我们将开源协作的范围限制在 **bug fix** 和一些**通用的大规模 RL 优化**上。在这方面我们也和社区达成了多次成功的合作,例如: + +- RL 中的投机采样([文档](https://thudm.github.io/slime/en/advanced/speculative_decoding.html)) +- 低精度训练:fp8 rollout + bf16/fp8 training,int4 rollout + int4 QAT training([文档](https://thudm.github.io/slime/en/advanced/low_precision_training.html)) +- 确定性训练([文档](https://thudm.github.io/slime/en/advanced/reproducibility.html)) + +### 我们欢迎的 + +| 类别 | 说明 | +|------|------| +| **Bug 报告** | 崩溃、结果错误、文档错误等 | +| **Bug 修复** | 带有测试或清晰复现步骤的修复 PR | +| **通用 RL 优化** | 有明确 benchmark 且可通过 CI 或常规训练验证的性能优化 | + +### 我们无法接受的 + +| 类别 | 原因 | +|------|------| +| **较大范围的代码重构** | 会给内外部同步带来比较大的负担,尤其是和内部算法团队的交流负担。 | +| **带有项目规划建议的标准或抽象** | 例如引入某种通用数据标准、eval 标准、工具构建基类等。标准的设立在大多数团队中会涉及到非技术因素,slime 的设计中故意避开了类似的内容,一方面不希望将智谱内部的管理偏好投射给社区,另一方面也便于内部不同方向的团队进行合适的选型。 | +| **无法进行明确验证的功能** | 训练框架的正确性是生死线。如果一个功能不能通过 CI 或智谱内部常规训练进行验证,我们就无法及时修复,对项目的名誉是个比较严重的打击。 | +| **与 RL 框架较为独立的功能** | 例如整套算法复现流程。这样的流程很难进入日常的验证流程中,很难保证正确性。slime 是一个相对轻量的框架,更像是 Flask 而非 Django。建议通过搭建独立的 repo 进行,我们也愿意在 README 中引用所有使用了 slime 的项目链接。 | +| **对 Megatron 的大幅度改动** | 目前我们没有计划通过 slime 维护一套 Megatron fork。slime 的目标是能够相对无痛地切换 Megatron 版本,Megatron 的性能优化和功能补全不在主要目标中。 | + +### 为什么需要这样的策略? + +RL Infra 的设计与后训练的规划有很强的绑定关系,公开整个后训练的研发规划并不包含在 slime 框架的开源目标内。这种较为聚焦的策略是我们认为将 slime 这个项目更长久地维护下去的必要手段。 + +将上述 feature 拒之门外也许会减慢 slime 的开发速度,我们会通过招聘的方式逐渐扩展 slime 团队来进行弥补——对此有兴趣的朋友可以直接私信联系~ + +感谢大家的理解,对受影响的社区朋友表示街心的歉意。 From 935b4716c3125028316a4e000554071c42f9c22e Mon Sep 17 00:00:00 2001 From: Zilin Zhu Date: Sat, 21 Feb 2026 00:10:37 +0800 Subject: [PATCH 5/5] fix typo --- .github/ISSUE_TEMPLATE/bug_report.yml | 4 ++-- .github/ISSUE_TEMPLATE/config.yml | 4 ++-- .github/ISSUE_TEMPLATE/question.yml | 4 ++-- CONTRIBUTING.md | 30 +++++++++++++-------------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index a51e352ef2..36ff4770cf 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -8,8 +8,8 @@ body: value: | Thank you for taking the time to report a bug! - > **Note:** slime focuses open-source collaboration on **bug fixes** and **general-purpose RL optimizations**. - > Feature requests are not accepted — please read [CONTRIBUTING.md](https://github.com/THUDM/slime/blob/main/CONTRIBUTING.md) for details. + > **Note:** slime's open-source collaboration is currently focused on **bug fixes** and **general-purpose RL optimizations**. + > Feature requests are outside our current scope — please see [CONTRIBUTING.md](https://github.com/THUDM/slime/blob/main/CONTRIBUTING.md) for details. Before submitting, please make sure you have: - [ ] Read the [documentation](https://thudm.github.io/slime/) and [FAQ](https://thudm.github.io/slime/en/get_started/qa.html) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index cc3ac96919..04d024a2c2 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -3,8 +3,8 @@ contact_links: - name: Collaboration Scope / 协作范围 url: https://github.com/THUDM/slime/blob/main/CONTRIBUTING.md about: | - Please read before submitting. We accept bug reports and general RL optimizations, but do NOT accept feature requests. - 提交前请阅读。我们接受 bug 报告和通用 RL 优化,但不接受 feature request。 + Please read before submitting. We welcome bug reports and general RL optimizations; feature requests are currently outside our scope. + 提交前请阅读。我们欢迎 bug 报告和通用 RL 优化,feature request 暂时不在协作范围内。 - name: Documentation url: https://thudm.github.io/slime/ about: Please check the documentation before opening an issue. Many common questions are already answered there. diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml index 5b06451caa..7c9c4dac2e 100644 --- a/.github/ISSUE_TEMPLATE/question.yml +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -8,8 +8,8 @@ body: value: | Thank you for reaching out! - > **Note:** slime focuses open-source collaboration on **bug fixes** and **general-purpose RL optimizations**. - > Feature requests are not accepted — please read [CONTRIBUTING.md](https://github.com/THUDM/slime/blob/main/CONTRIBUTING.md) for details. + > **Note:** slime's open-source collaboration is currently focused on **bug fixes** and **general-purpose RL optimizations**. + > Feature requests are outside our current scope — please see [CONTRIBUTING.md](https://github.com/THUDM/slime/blob/main/CONTRIBUTING.md) for details. Before asking, please make sure you have checked: - [Quick Start Guide](https://thudm.github.io/slime/en/get_started/quick_start.html) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 545fcad773..222ea070b1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,7 @@ Thank you for your interest in contributing to slime! We deeply appreciate every ## Collaboration Scope -slime is the RL training infrastructure behind [GLM-4.5 through GLM-4.7](https://z.ai) and a large number of internal experiments at Zhipu AI. We open-sourced slime because we believe the training scenarios used internally cover the majority of cutting-edge RL algorithm requirements, and we hope to provide the community with a correct and efficient large-scale RL training infrastructure. +slime is the RL training infrastructure behind [GLM-4.5 through GLM-5](https://z.ai) and a large number of internal experiments at Z.ai. We open-sourced slime because we believe the training scenarios used internally cover the majority of cutting-edge RL algorithm requirements, and we hope to provide the community with a correct and efficient large-scale RL training infrastructure. Our goal for open-source collaboration is focused on **bug fixes** and **general-purpose large-scale RL optimizations**. We have had several successful collaborations with the community in this area, including: @@ -22,23 +22,23 @@ Our goal for open-source collaboration is focused on **bug fixes** and **general | **Bug fixes** | PRs that fix existing issues with tests or clear reproduction | | **General RL optimizations** | Performance improvements with clear benchmarks that can be verified through CI or standard training runs | -### What We Cannot Accept +### What's Currently Outside Our Scope | Category | Reason | |----------|--------| -| **Large-scale code refactoring** | Significantly increases the burden of syncing between the internal and open-source versions, especially in communication with internal algorithm teams. | +| **Large-scale code refactoring** | This would add considerable overhead to syncing between the internal and open-source versions, particularly in coordinating with internal algorithm teams. | | **Design / abstraction proposals** | e.g., universal data standards, eval standards, tool base classes. Standard-setting involves non-technical factors; slime intentionally avoids such content to keep things flexible for both the community and internal teams. | -| **Features that cannot be clearly verified** | Correctness is the lifeline of a training framework. If a feature cannot be verified through CI or routine internal training, we cannot ensure timely fixes, which poses a serious risk to the project's reputation. | +| **Features that cannot be clearly verified** | Correctness is critically important for a training framework. If a feature cannot be verified through CI or routine internal training, it becomes difficult for us to ensure timely fixes, which could affect the project's long-term reliability. | | **Features independent of the RL framework** | e.g., full algorithm reproduction pipelines. While these lower the barrier to entry, they are difficult to include in routine verification. slime aims to be lightweight — more like Flask than Django. We recommend building such pipelines in separate repositories; we are happy to reference them in the README. | | **Major modifications to Megatron** | We do not plan to maintain a Megatron fork through slime. The goal is to switch Megatron versions relatively painlessly; Megatron performance optimization and feature completion are not primary objectives. | ### Why This Policy? -slime's design and development roadmap must first align with Zhipu AI's internal requirements — the RL infrastructure design is tightly coupled with post-training plans, and publishing the full post-training R&D roadmap is not within the open-source scope of slime. This focused scope is what we believe is necessary to maintain slime as a long-term, trustworthy project. +slime's design and development roadmap must first align with Z.ai's internal requirements — the RL infrastructure design is tightly coupled with post-training plans, and publishing the full post-training R&D roadmap is not within the open-source scope of slime. This focused scope is what we believe is necessary to maintain slime as a long-term, trustworthy project. -We understand this may slow down slime's pace of feature development. We are actively expanding the slime team through hiring to address this — if you're interested, feel free to reach out directly. +We understand this may slow down slime's pace of feature development. We are actively expanding the slime team through hiring to help with this — if you're interested, feel free to reach out directly. -Thank you for your understanding. We sincerely apologize for any inconvenience this policy may cause to community contributors who have invested their efforts. +Thank you for your understanding and patience. We truly appreciate the effort community contributors put in, and we're sorry if this policy causes any inconvenience. --- @@ -48,9 +48,9 @@ Thank you for your understanding. We sincerely apologize for any inconvenience t ### 背景 -slime 承担了智谱内部的大量实验,包括 GLM 4.5 至 4.7 的全部 RL 流程,以及大量的日常实验。我们开源的初衷是相信智谱内部的训练场景覆盖了大多数前沿算法需求,希望能够为社区提供一套**正确且高效**的大规模 RL 训练 Infra,同时也希望在此基础上和社区进行 Infra 性能优化上的共建。 +slime 承担了智谱内部的大量实验,包括 GLM 4.5 至 5 的全部 RL 流程,以及大量的日常实验。我们开源的初衷是相信智谱内部的训练场景覆盖了大多数前沿算法需求,希望能够为社区提供一套**正确且高效**的大规模 RL 训练 Infra,同时也希望在此基础上和社区进行 Infra 性能优化上的共建。 -在我们的已知范围内,目前只有极少的前沿大模型团队愿意公开如此核心且完整的 Infra 组件——这背后是公司对开源社区的极大热情。相应的,从维护者的角度,我们会充分利用这个开明的政策,让智谱内部使用的 slime 与开源版本同步,保持核心竞争力;同时,我们也不能因为开源而拖慢了内部的研发节奏。这意味着 slime 的设计与开发 roadmap 需要首先参考智谱内部的需求,而不能完全在开源社区内进行讨论。 +在我们的已知范围内,目前只有极少的前沿大模型团队愿意公开如此核心且完整的 Infra 组件——这背后是公司对开源社区的极大热情。相应的,从维护者的角度,我们会充分利用这个开明的政策,让智谱内部使用的 slime 与开源版本同步,保持核心竞争力;同时,我们也希望在开源协作的过程中尽量不影响内部的研发节奏。因此,slime 的设计与开发 roadmap 需要优先参考智谱内部的需求,暂时无法完全在开源社区内进行讨论。 ### 协作范围 @@ -68,20 +68,20 @@ slime 承担了智谱内部的大量实验,包括 GLM 4.5 至 4.7 的全部 RL | **Bug 修复** | 带有测试或清晰复现步骤的修复 PR | | **通用 RL 优化** | 有明确 benchmark 且可通过 CI 或常规训练验证的性能优化 | -### 我们无法接受的 +### 暂时不在协作范围内的 | 类别 | 原因 | |------|------| -| **较大范围的代码重构** | 会给内外部同步带来比较大的负担,尤其是和内部算法团队的交流负担。 | +| **较大范围的代码重构** | 会给内外部版本同步带来较多额外工作,尤其是在与内部算法团队的沟通协调上。 | | **带有项目规划建议的标准或抽象** | 例如引入某种通用数据标准、eval 标准、工具构建基类等。标准的设立在大多数团队中会涉及到非技术因素,slime 的设计中故意避开了类似的内容,一方面不希望将智谱内部的管理偏好投射给社区,另一方面也便于内部不同方向的团队进行合适的选型。 | -| **无法进行明确验证的功能** | 训练框架的正确性是生死线。如果一个功能不能通过 CI 或智谱内部常规训练进行验证,我们就无法及时修复,对项目的名誉是个比较严重的打击。 | -| **与 RL 框架较为独立的功能** | 例如整套算法复现流程。这样的流程很难进入日常的验证流程中,很难保证正确性。slime 是一个相对轻量的框架,更像是 Flask 而非 Django。建议通过搭建独立的 repo 进行,我们也愿意在 README 中引用所有使用了 slime 的项目链接。 | +| **无法进行明确验证的功能** | 训练框架的正确性至关重要。如果一个功能不能通过 CI 或智谱内部常规训练进行验证,我们就难以及时发现和修复问题,这对项目的长期可靠性会带来不小的风险。 | +| **与 RL 框架较为独立的功能** | 例如整套算法复现流程。这类内容较难纳入日常验证流程,不太容易持续保证正确性。slime 是一个相对轻量的框架,更像是 Flask 而非 Django。建议在独立的 repo 中搭建,我们也非常愿意在 README 中引用所有使用了 slime 的项目链接。 | | **对 Megatron 的大幅度改动** | 目前我们没有计划通过 slime 维护一套 Megatron fork。slime 的目标是能够相对无痛地切换 Megatron 版本,Megatron 的性能优化和功能补全不在主要目标中。 | ### 为什么需要这样的策略? RL Infra 的设计与后训练的规划有很强的绑定关系,公开整个后训练的研发规划并不包含在 slime 框架的开源目标内。这种较为聚焦的策略是我们认为将 slime 这个项目更长久地维护下去的必要手段。 -将上述 feature 拒之门外也许会减慢 slime 的开发速度,我们会通过招聘的方式逐渐扩展 slime 团队来进行弥补——对此有兴趣的朋友可以直接私信联系~ +暂时无法纳入上述 feature 也许会减慢 slime 的功能迭代速度,我们会通过招聘的方式逐渐扩展 slime 团队来改善这一点——对此有兴趣的朋友欢迎直接私信联系~ -感谢大家的理解,对受影响的社区朋友表示街心的歉意。 +感谢大家的理解与支持,如果这一策略给您带来了不便,我们深表歉意。