-
Notifications
You must be signed in to change notification settings - Fork 747
add no colocate update critic only #1567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| import os | ||
|
|
||
| import slime.utils.external_utils.command_utils as U | ||
|
|
||
|
|
||
| ENABLE_EVAL = bool(int(os.environ.get("SLIME_TEST_ENABLE_EVAL", "1"))) | ||
| TIGHT_HOST_MEMORY = bool(int(os.environ.get("SLIME_TEST_TIGHT_HOST_MEMORY", "1"))) | ||
|
|
||
| MODEL_NAME = "Qwen3-4B" | ||
| MODEL_TYPE = "qwen3-4B" | ||
| NUM_GPUS = 8 | ||
|
|
||
|
|
||
| def prepare(): | ||
| U.exec_command("mkdir -p /root/models /root/datasets") | ||
| U.exec_command("hf download Qwen/Qwen3-4B --local-dir /root/models/Qwen3-4B") | ||
| U.hf_download_dataset("zhuzilin/dapo-math-17k") | ||
| U.hf_download_dataset("zhuzilin/aime-2024") | ||
|
|
||
| U.convert_checkpoint(model_name=MODEL_NAME, megatron_model_type=MODEL_TYPE, num_gpus_per_node=NUM_GPUS) | ||
|
|
||
|
|
||
| def execute(): | ||
| ckpt_args = f"--hf-checkpoint /root/models/{MODEL_NAME}/ " f"--ref-load /root/{MODEL_NAME}_torch_dist " | ||
|
|
||
| rollout_args = ( | ||
| "--prompt-data /root/datasets/dapo-math-17k/dapo-math-17k.jsonl " | ||
| "--input-key prompt " | ||
| "--label-key label " | ||
| "--apply-chat-template " | ||
| "--rollout-shuffle " | ||
| "--rm-type deepscaler " | ||
| "--num-rollout 3 " | ||
| "--rollout-batch-size 8 " | ||
| "--n-samples-per-prompt 8 " | ||
| "--rollout-max-response-len 8192 " | ||
| "--rollout-temperature 0.8 " | ||
| "--global-batch-size 32 " | ||
| "--balance-data " | ||
| ) | ||
|
|
||
| eval_args = ( | ||
| f"{'--eval-interval 20 ' if ENABLE_EVAL else ''}" | ||
| "--eval-prompt-data aime24 /root/datasets/aime-2024/aime-2024.jsonl " | ||
| "--n-samples-per-eval-prompt 1 " | ||
| "--eval-max-response-len 16384 " | ||
| "--eval-top-k 1 " | ||
| ) | ||
|
|
||
| perf_args = ( | ||
| "--tensor-model-parallel-size 2 " | ||
| "--sequence-parallel " | ||
| "--pipeline-model-parallel-size 1 " | ||
| "--context-parallel-size 2 " | ||
| "--recompute-granularity full " | ||
| "--recompute-method uniform " | ||
| "--recompute-num-layers 1 " | ||
| "--use-dynamic-batch-size " | ||
| f"--max-tokens-per-gpu {2048 if TIGHT_HOST_MEMORY else 16384} " | ||
| ) | ||
|
|
||
| ppo_args = ( | ||
| "--advantage-estimator ppo " | ||
| f"{'' if TIGHT_HOST_MEMORY else '--use-kl-loss '}" | ||
| "--kl-loss-coef 0.00 " | ||
| "--kl-loss-type k1 " | ||
| "--kl-coef 0.00 " | ||
| "--entropy-coef 0.00 " | ||
| "--eps-clip 4e-4 " | ||
| "--critic-train-only " | ||
| "--normalize-advantages " | ||
| "--critic-lr 1e-5 " | ||
| ) | ||
|
|
||
| optimizer_args = ( | ||
| "--optimizer adam " | ||
| "--lr 1e-6 " | ||
| "--lr-decay-style constant " | ||
| "--weight-decay 0.1 " | ||
| "--adam-beta1 0.9 " | ||
| "--adam-beta2 0.98 " | ||
| ) | ||
|
|
||
| sglang_args = ( | ||
| "--rollout-num-gpus-per-engine 2 " | ||
| "--rollout-num-gpus 4 " | ||
| "--sglang-mem-fraction-static 0.8 " | ||
| "--sglang-max-running-requests 512 " | ||
| "--sglang-enable-metrics " | ||
| ) | ||
|
|
||
| ci_args = "--ci-test " | ||
|
|
||
| misc_args = ( | ||
| # default dropout in megatron is 0.1 | ||
| "--attention-dropout 0.0 " | ||
| "--hidden-dropout 0.0 " | ||
| # should be good for model performance | ||
| "--accumulate-allreduce-grads-in-fp32 " | ||
| "--attention-softmax-in-fp32 " | ||
| # need to comment this when using model with MLA | ||
| "--attention-backend flash " | ||
| "--actor-num-nodes 0 " | ||
| "--actor-num-gpus-per-node 0 " | ||
| "--critic-num-nodes 1 " | ||
| "--critic-num-gpus-per-node 4 " | ||
| ) | ||
|
|
||
| train_args = ( | ||
| f"{ckpt_args} " | ||
| f"{rollout_args} " | ||
| f"{optimizer_args} " | ||
| f"{ppo_args} " | ||
| f"{U.get_default_wandb_args(__file__)} " | ||
| f"{perf_args} " | ||
| f"{eval_args} " | ||
| f"{sglang_args} " | ||
| f"{ci_args} " | ||
| f"{misc_args} " | ||
| ) | ||
|
|
||
| U.execute_train( | ||
| train_args=train_args, | ||
| num_gpus_per_node=NUM_GPUS, | ||
| megatron_model_type=MODEL_TYPE, | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| # TODO also use typer | ||
| prepare() | ||
| for proxy_var in ("http_proxy", "https_proxy", "HTTP_PROXY", "HTTPS_PROXY"): | ||
| os.environ.pop(proxy_var, None) | ||
| execute() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
--critic-train-onlyis set but--use-criticis not,critic_modelisNoneand this will raise an AttributeError. Either validate thatcritic_train_onlyimpliesuse_critic, or guard this block withif args.use_critic(and provide a clear error message if not).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can always run
maybe change
if args.critic_train_onlytoif use_criticand remove the critic.set_rollout_manager in actor_model.set_rollout_manager