|
| 1 | +#!/bin/sh |
| 2 | +MODEL_FAMILY=qwen2 |
| 3 | + |
| 4 | +EXP_NAME="$1" |
| 5 | +MODEL_NAME="$2" |
| 6 | +DATASET_NAME="$3" |
| 7 | +TRAIN_BATCH_SIZE="$4" |
| 8 | +GROUP_SIZE="$5" |
| 9 | +NODES="$6" |
| 10 | +ALLOCATION_MODE="$7" |
| 11 | +MAX_NEW_TOKENS=$8 |
| 12 | +MAX_NUM_SEQS=$9 |
| 13 | +PPO_MBS=${10} |
| 14 | +KL_CTL=${11} |
| 15 | + |
| 16 | +MAX_TOKEN_PER_MB=$(expr 2048 + ${MAX_NEW_TOKENS} + 1024) |
| 17 | +MAX_SEQ_LEN_TO_CAPTURE=$(expr 2048 + ${MAX_NEW_TOKENS}) |
| 18 | + |
| 19 | +BASE_MODEL_PATH="/storage/models/${MODEL_NAME}" |
| 20 | + |
| 21 | +# original data |
| 22 | +DATA_PATH="/storage/datasets/${DATASET_NAME}" |
| 23 | +REAL_CODE_METADATA_PATH="/storage/datasets/codeparrot-apps-test.jsonl" |
| 24 | + |
| 25 | +# Option 1: The experiment runs locally with subprocesses. |
| 26 | +# MODE=local |
| 27 | +# Option 2: The experiment runs in a Ray cluster |
| 28 | +# MODE=ray |
| 29 | +# Option 3: The experiment runs in a SLURM + pyxis cluster |
| 30 | +# Using the slurm mode requires a cluster spec file |
| 31 | +# and setting CLUSTER_SPEC_PATH to the path of it. |
| 32 | +MODE=ray |
| 33 | + |
| 34 | +# `experiment_name` and `trial_name` can be arbitrary. |
| 35 | +# Logs and saved checkpoints will be indexed by them. |
| 36 | +#EXP_NAME=ppo-zero--${MODEL_NAME}--${DATASET_NAME} |
| 37 | +#EXP_NAME=ppo-zero-distill-1.5B-default |
| 38 | +TRIAL_NAME="${TRAIN_BATCH_SIZE}x${GROUP_SIZE}-n${NODES}" |
| 39 | + |
| 40 | +# We use the "heuristic" allocation mode here to automatically determine the parallelism strategy |
| 41 | +# for each model function call, i.e., actor generation, critic inference, actor train, etc. |
| 42 | +# The number of GPUs is `n_nodes` * `n_gpus_per_node` (not set explictly here, defaults to 8). |
| 43 | +# ReaL will make full use of these available GPUs to design allocations. |
| 44 | +# This does not ensure the optimal throughput, but it is a good starting point. |
| 45 | + |
| 46 | +# The `heuristic` allocation mode is not ensured to run with every model configurations. |
| 47 | +# For example, if the vocabulary size is an odd number, the model parallelism may not work. |
| 48 | +# In these cases, you can use the `ppo_manual.sh` to specify the parallelism strategy manually. |
| 49 | + |
| 50 | +# The `ppo` subcommand specifies that this is a PPO experiment. |
| 51 | +# The `save_freq_steps` is set to `null` to disable saving checkpoints. |
| 52 | +# Enable it if you want to save checkpoints. |
| 53 | +# The `ppo` option is used to control the generation and PPO algorithm hyperparameters. |
| 54 | +# Note that the performance of PPO is sensitive to the the pre-trained model and hyperparameters. |
| 55 | +# It's the user's responsibility to tune them appropriately. |
| 56 | +unset CLUSTER_SPEC_PATH |
| 57 | +CLUSTER_SPEC_PATH=/storage/ray/cluster_config_on_ray.json \ |
| 58 | +REAL_CODE_METADATA_PATH=${REAL_CODE_METADATA_PATH} \ |
| 59 | +FUNCTIONCALL_SERVICE_DOMAIN="" \ |
| 60 | +REAL_GPU_MEMORY_KILL_THRESHOLD=1 \ |
| 61 | +python3 -m realhf.apps.quickstart ppo-code \ |
| 62 | + mode=$MODE \ |
| 63 | + experiment_name=$EXP_NAME \ |
| 64 | + trial_name=$TRIAL_NAME \ |
| 65 | + wandb.mode=disabled \ |
| 66 | + exp_ctrl.total_train_epochs=1 \ |
| 67 | + exp_ctrl.save_freq_epochs=1 \ |
| 68 | + exp_ctrl.ckpt_freq_secs=600 \ |
| 69 | + group_size=${GROUP_SIZE} \ |
| 70 | + group_adv_norm=False \ |
| 71 | + use_dense_reward=False \ |
| 72 | + reward_delta=True \ |
| 73 | + rw_type=sparse \ |
| 74 | + check_xml_format=False \ |
| 75 | + actor.type._class=$MODEL_FAMILY \ |
| 76 | + actor.path=$BASE_MODEL_PATH \ |
| 77 | + actor.vllm.hybrid_train=False \ |
| 78 | + actor.vllm.enforce_eager=False \ |
| 79 | + actor.vllm.max_seq_len_to_capture=${MAX_SEQ_LEN_TO_CAPTURE} \ |
| 80 | + actor.vllm.max_num_seqs=${MAX_NUM_SEQS} \ |
| 81 | + actor.vllm.gpu_memory_utilization=1 \ |
| 82 | + actor.vllm.swap_space=64 \ |
| 83 | + critic.type._class=$MODEL_FAMILY \ |
| 84 | + critic.type.is_critic=True \ |
| 85 | + critic.init_critic_from_actor=True \ |
| 86 | + critic.path=$BASE_MODEL_PATH\ |
| 87 | + ref.type._class=$MODEL_FAMILY \ |
| 88 | + ref.path=$BASE_MODEL_PATH \ |
| 89 | + rew.type._class=$MODEL_FAMILY \ |
| 90 | + rew.type.is_critic=True \ |
| 91 | + rew.init_critic_from_actor=True \ |
| 92 | + rew.path=$BASE_MODEL_PATH \ |
| 93 | + dataset.path=$DATA_PATH \ |
| 94 | + dataset.max_prompt_len=2048 \ |
| 95 | + dataset.train_bs_n_seqs=${TRAIN_BATCH_SIZE} \ |
| 96 | + ppo.gen.max_new_tokens=${MAX_NEW_TOKENS} \ |
| 97 | + ppo.gen.min_new_tokens=0 \ |
| 98 | + ppo.disable_value=True \ |
| 99 | + ppo.gen.top_p=1 ppo.gen.top_k=1000000 \ |
| 100 | + ppo.ppo_n_minibatches=${PPO_MBS} \ |
| 101 | + ppo.gen.temperature=0.6 \ |
| 102 | + ppo.kl_ctl=${KL_CTL} \ |
| 103 | + ppo.value_eps_clip=0.2 \ |
| 104 | + ppo.reward_output_scaling=5 \ |
| 105 | + ppo.reward_output_bias=0.0 \ |
| 106 | + ppo.adv_norm=True ppo.value_norm=True \ |
| 107 | + mask_too_long=False \ |
| 108 | + ppo.discount=1.0 \ |
| 109 | + actor.optimizer.lr=1e-6 \ |
| 110 | + critic.optimizer.lr=5e-6 \ |
| 111 | + actor.optimizer.lr_scheduler_type=constant \ |
| 112 | + actor_gen.mb_spec.max_tokens_per_mb=${MAX_TOKEN_PER_MB} \ |
| 113 | + ref_inf.mb_spec.max_tokens_per_mb=${MAX_TOKEN_PER_MB} \ |
| 114 | + rew_inf.mb_spec.max_tokens_per_mb=${MAX_TOKEN_PER_MB} \ |
| 115 | + critic_inf.mb_spec.max_tokens_per_mb=${MAX_TOKEN_PER_MB} \ |
| 116 | + actor_train.mb_spec.max_tokens_per_mb=${MAX_TOKEN_PER_MB} \ |
| 117 | + critic_train.mb_spec.max_tokens_per_mb=${MAX_TOKEN_PER_MB} \ |
| 118 | + cache_clear_freq=1 \ |
| 119 | + n_nodes=${NODES} \ |
| 120 | + allocation_mode="'${ALLOCATION_MODE}'" n_gpus_per_node=8 \ |
| 121 | + recover_mode=auto \ |
| 122 | + recover_retries=10 \ |
| 123 | + torch_cache_mysophobia=True |
0 commit comments