-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add DeepSeek 671B GRPO example #1771
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
Show all changes
10 commits
Select commit
Hold shift + click to select a range
04b1990
add deepseek 671b example
yzlnew c2fc9f6
fix namespace
yzlnew 4bd4b55
add fix for vllm
yzlnew 1785373
update ds defaults
yzlnew c99700e
remove duplicates
yzlnew 219662b
improve uneven split
yzlnew 11b36b7
Merge branch 'main' into mine_main
yzlnew 98197c0
add full recompute
yzlnew dc57035
remove
yzlnew a326deb
add some notes
yzlnew 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
103 changes: 103 additions & 0 deletions
103
examples/grpo_trainer/run_deepseek671b_math_megatron.sh
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,103 @@ | ||
set -x | ||
|
||
# 0. download the config | ||
# only need to download the configuration_deepseek.py and config.json | ||
# remove the `quantization_config` in the `config.json` | ||
# set `num_nextn_predict_layers=0` to disable MTP, which is not currently supported | ||
huggingface-cli download deepseek-ai/DeepSeek-V3-0324 configuration_deepseek.py config.json | ||
|
||
# 1. download the dist_ckpt format model from https://huggingface.co/BearBiscuit05/dpsk-v3-671B-BF16-dist_ckpt/tree/main | ||
# change the HF_MODEL_PATH and DIST_CKPT_PATH to your own path | ||
DIST_CKPT_PATH="<path_to_dist_ckpt>" | ||
LLM="<path_to_dsv3_config>" | ||
|
||
|
||
# 2. run the script | ||
gsm8k_train_path=/data/gsm8k/train.parquet | ||
gsm8k_test_path=/data/gsm8k/test.parquet | ||
train_files=$gsm8k_train_path | ||
test_files=$gsm8k_test_path | ||
|
||
ALL_OFFLOAD=${ALL_OFFLOAD:-True} | ||
COMMON_PARAM_OFFLOAD=${COMMON_PARAM_OFFLOAD:-$ALL_OFFLOAD} | ||
COMMON_GRAD_OFFLOAD=${COMMON_GRAD_OFFLOAD:-$ALL_OFFLOAD} | ||
COMMON_OPTIMIZER_OFFLOAD=${COMMON_OPTIMIZER_OFFLOAD:-$ALL_OFFLOAD} | ||
|
||
ACTOR_PARAM_OFFLOAD=${ACTOR_PARAM_OFFLOAD:-$COMMON_PARAM_OFFLOAD} | ||
ACTOR_GRAD_OFFLOAD=${ACTOR_GRAD_OFFLOAD:-$COMMON_GRAD_OFFLOAD} | ||
ACTOR_OPTIMIZER_OFFLOAD=${ACTOR_OPTIMIZER_OFFLOAD:-$COMMON_OPTIMIZER_OFFLOAD} | ||
REF_PARAM_OFFLOAD=${REF_PARAM_OFFLOAD:-$COMMON_PARAM_OFFLOAD} | ||
CRITIC_PARAM_OFFLOAD=${CRITIC_PARAM_OFFLOAD:-$COMMON_PARAM_OFFLOAD} | ||
CRITIC_GRAD_OFFLOAD=${CRITIC_GRAD_OFFLOAD:-$COMMON_GRAD_OFFLOAD} | ||
CRITIC_OPTIMIZER_OFFLOAD=${CRITIC_OPTIMIZER_OFFLOAD:-$COMMON_OPTIMIZER_OFFLOAD} | ||
RM_PARAM_OFFLOAD=${RM_PARAM_OFFLOAD:-$COMMON_PARAM_OFFLOAD} | ||
|
||
|
||
NODES=32 | ||
PP=16 | ||
TP=1 | ||
EP=16 | ||
ETP=1 | ||
INFER_TP=16 | ||
|
||
n_resp_per_prompt=4 | ||
|
||
# RAY_ADDRESS='auto' ray job submit --working-dir . -- | ||
python3 -m verl.trainer.main_ppo --config-path=./config --config-name='ppo_megatron_trainer'\ | ||
algorithm.adv_estimator=grpo \ | ||
data.train_files="$train_files" \ | ||
data.val_files="$test_files" \ | ||
data.train_batch_size=512 \ | ||
data.max_prompt_length=1024 \ | ||
data.max_response_length=512 \ | ||
data.filter_overlong_prompts=True \ | ||
data.truncation='error' \ | ||
actor_rollout_ref.model.path=$LLM \ | ||
actor_rollout_ref.actor.optim.lr=1e-6 \ | ||
actor_rollout_ref.actor.ppo_mini_batch_size=128 \ | ||
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=1 \ | ||
actor_rollout_ref.actor.use_kl_loss=False \ | ||
actor_rollout_ref.actor.use_torch_compile=False \ | ||
+actor_rollout_ref.actor.megatron.override_transformer_config.recompute_method=uniform \ | ||
+actor_rollout_ref.actor.megatron.override_transformer_config.recompute_granularity=full \ | ||
+actor_rollout_ref.actor.megatron.override_transformer_config.recompute_num_layers=1 \ | ||
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=1 \ | ||
actor_rollout_ref.rollout.name=vllm \ | ||
actor_rollout_ref.rollout.gpu_memory_utilization=0.8 \ | ||
actor_rollout_ref.rollout.n=${n_resp_per_prompt} \ | ||
actor_rollout_ref.rollout.temperature=1.0 \ | ||
actor_rollout_ref.rollout.top_p=1.0 \ | ||
actor_rollout_ref.rollout.top_k=-1 \ | ||
actor_rollout_ref.rollout.tensor_model_parallel_size=$INFER_TP \ | ||
algorithm.use_kl_in_reward=False \ | ||
trainer.logger=['console','tensorboard'] \ | ||
trainer.project_name='verl_megatron_gsm8k_examples' \ | ||
trainer.experiment_name='dsv3-32nodes' \ | ||
trainer.n_gpus_per_node=8 \ | ||
trainer.nnodes=$NODES \ | ||
trainer.save_freq=-1 \ | ||
trainer.test_freq=5 \ | ||
+actor_rollout_ref.actor.megatron.override_transformer_config.num_layers_in_first_pipeline_stage=3 \ | ||
+actor_rollout_ref.actor.megatron.override_transformer_config.num_layers_in_last_pipeline_stage=2 \ | ||
+actor_rollout_ref.actor.megatron.override_transformer_config.moe_router_bias_update_rate=0.0 \ | ||
+actor_rollout_ref.actor.megatron.override_transformer_config.moe_aux_loss_coeff=0.0001 \ | ||
actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=$PP \ | ||
actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=$PP \ | ||
actor_rollout_ref.actor.megatron.tensor_model_parallel_size=$TP \ | ||
actor_rollout_ref.ref.megatron.tensor_model_parallel_size=$TP \ | ||
actor_rollout_ref.actor.megatron.expert_model_parallel_size=$EP \ | ||
actor_rollout_ref.ref.megatron.expert_model_parallel_size=$EP \ | ||
actor_rollout_ref.actor.megatron.expert_tensor_parallel_size=$ETP \ | ||
actor_rollout_ref.ref.megatron.expert_tensor_parallel_size=$ETP \ | ||
actor_rollout_ref.actor.megatron.param_offload=${ACTOR_PARAM_OFFLOAD} \ | ||
actor_rollout_ref.actor.megatron.optimizer_offload=${ACTOR_OPTIMIZER_OFFLOAD} \ | ||
actor_rollout_ref.actor.megatron.grad_offload=${ACTOR_GRAD_OFFLOAD} \ | ||
actor_rollout_ref.ref.megatron.param_offload=${REF_PARAM_OFFLOAD} \ | ||
actor_rollout_ref.actor.megatron.use_dist_checkpointing=True \ | ||
actor_rollout_ref.ref.megatron.use_dist_checkpointing=True \ | ||
actor_rollout_ref.actor.megatron.dist_checkpointing_path=$DIST_CKPT_PATH \ | ||
actor_rollout_ref.ref.megatron.dist_checkpointing_path=$DIST_CKPT_PATH \ | ||
trainer.default_hdfs_dir=null \ | ||
trainer.default_local_dir=$CKPT_DIR \ | ||
trainer.val_before_train=False \ | ||
trainer.total_epochs=100 $@ |
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.
Uh oh!
There was an error while loading. Please reload this page.