-
Notifications
You must be signed in to change notification settings - Fork 259
[Generator][Env] Add stop str, remove need for post-processed action in search and txt2sql #190
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
259f0b0
[Generator][Env] Add stop str, remove need for postprocessed action f…
CharlieFRuan 33fb740
fix lint, add warning
CharlieFRuan 62d38fd
address gemini comments
CharlieFRuan cf9a63a
remove postprocess action tests from skyrlgym
CharlieFRuan cdf24a5
append eos to response after stop str in multiturn
CharlieFRuan b3fc6ff
fix scripts and doc according to append_eos
CharlieFRuan cb67035
fix unit tests
CharlieFRuan f8971ed
change logs
CharlieFRuan c05f2e9
Address how sampling_params is None for rollout
CharlieFRuan 0d2effd
Address comments
CharlieFRuan 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
79 changes: 79 additions & 0 deletions
79
skyrl-train/examples/search/run_search_conversation_format.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,79 @@ | ||
| set -x | ||
|
|
||
| # The exact same script as `run_search.sh` but with `use_conversation_multi_turn=true` | ||
| # and hence `append_eos_token_after_stop_str_in_multi_turn=true` | ||
| # See https://skyrl.readthedocs.io/en/latest/tutorials/skyrl_gym_generator.html on the | ||
| # difference between the two options. You might want to change the data generation prompt | ||
| # to let the model know that we are doing multi-turn conversations (i.e. user will provide | ||
| # the search result for each turn). | ||
|
|
||
| # Colocated GRPO training+generation for Qwen2.5-Coder-3B-Instruct on SearchR1 data. | ||
| # follow the instructions in examples/search/README.md for setting up the dataset | ||
| # and for starting the local search server | ||
| # export WANDB_API_KEY=<your_key_here> | ||
| # bash examples/search/run_search.sh | ||
|
|
||
| # path for dataset (.parquet files) containing the prompts and metadata for each question | ||
| DATA_DIR="$HOME/data/searchR1" | ||
|
|
||
| uv run --isolated --frozen --extra vllm -m skyrl_train.entrypoints.main_base \ | ||
| data.train_data="['${DATA_DIR}/train.parquet']" \ | ||
| data.val_data="['${DATA_DIR}/validation.parquet']" \ | ||
| trainer.algorithm.advantage_estimator="grpo" \ | ||
| trainer.policy.optimizer_config.lr=1.0e-6 \ | ||
| trainer.policy.optimizer_config.max_grad_norm=0.5 \ | ||
| trainer.policy.optimizer_config.num_warmup_steps=94 \ | ||
| trainer.algorithm.use_kl_loss=true \ | ||
| trainer.algorithm.kl_loss_coef=0.001 \ | ||
| trainer.policy.model.path="Qwen/Qwen2.5-3B-Instruct" \ | ||
| trainer.placement.colocate_all=true \ | ||
| trainer.strategy=fsdp2 \ | ||
| trainer.policy.fsdp_config.cpu_offload=false \ | ||
| trainer.ref.fsdp_config.cpu_offload=true \ | ||
| trainer.placement.policy_num_gpus_per_node=8 \ | ||
| trainer.placement.ref_num_gpus_per_node=8 \ | ||
| generator.num_inference_engines=4 \ | ||
| generator.inference_engine_tensor_parallel_size=2 \ | ||
| generator.backend=vllm \ | ||
| generator.run_engines_locally=true \ | ||
| generator.weight_sync_backend=nccl \ | ||
| generator.gpu_memory_utilization=0.5 \ | ||
| trainer.epochs=1 \ | ||
| trainer.update_epochs_per_batch=1 \ | ||
| trainer.train_batch_size=512 \ | ||
| trainer.policy_mini_batch_size=256 \ | ||
| trainer.micro_forward_batch_size_per_gpu=4 \ | ||
| trainer.micro_train_batch_size_per_gpu=4 \ | ||
| trainer.max_prompt_length=2048 \ | ||
| generator.max_input_length=4096 \ | ||
| generator.sampling_params.max_generate_length=500 \ | ||
| generator.async_engine=true \ | ||
| generator.batched=false \ | ||
| generator.use_conversation_multi_turn=true \ | ||
| generator.n_samples_per_prompt=5 \ | ||
| generator.max_turns=4 \ | ||
| generator.sampling_params.temperature=1.0 \ | ||
| generator.sampling_params.top_p=1.0 \ | ||
| generator.sampling_params.stop='["</search>", "</answer>"]' \ | ||
| generator.append_eos_token_after_stop_str_in_multi_turn=true \ | ||
| environment.env_class="search" \ | ||
| environment.skyrl_gym.max_env_workers=16 \ | ||
| environment.skyrl_gym.search.log_requests=false \ | ||
| environment.skyrl_gym.search.search_url="http://127.0.0.1:8000/retrieve" \ | ||
| environment.skyrl_gym.search.topk=3 \ | ||
| trainer.logger="wandb" \ | ||
| trainer.project_name="skyrl-search" \ | ||
| trainer.run_name="skyrl-search_4turns_maxgeneratelen_500" \ | ||
| trainer.ckpt_interval=20 \ | ||
| trainer.hf_save_interval=100 \ | ||
| trainer.max_ckpts_to_keep=5 \ | ||
| trainer.resume_mode=latest \ | ||
| trainer.ckpt_path="$HOME/skyrl-search_4turns_maxgeneratelen_500" \ | ||
| trainer.eval_batch_size=256 \ | ||
| trainer.eval_before_train=false \ | ||
| generator.eval_sampling_params.temperature=0 \ | ||
| generator.eval_sampling_params.stop='["</search>", "</answer>"]' \ | ||
| trainer.export_path="$HOME/skyrl-search_4turns_maxgeneratelen_500/exports" \ | ||
| trainer.eval_interval=50 \ | ||
| $@ | ||
|
|
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
80 changes: 80 additions & 0 deletions
80
skyrl-train/examples/text_to_sql/run_skyrl_sql_conversation_format.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,80 @@ | ||
| set -x | ||
|
|
||
| # The exact same script as `run_search.sh` but with `use_conversation_multi_turn=true` | ||
SumanthRH marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # and hence `append_eos_token_after_stop_str_in_multi_turn=true` | ||
| # See https://skyrl.readthedocs.io/en/latest/tutorials/skyrl_gym_generator.html on what behavior | ||
| # use_conversation_multi_turn corresponds to. You might want to change the data generation prompt | ||
| # to let the model know that we are doing multi-turn conversations (i.e. user will provide | ||
| # the search result for each turn). | ||
|
|
||
| # Colocated GRPO training+generation for Qwen2.5-Coder-7B-Instruct on SkyRL-SQL-653 data. | ||
| # Uses 1 node with 8 GPUs. | ||
| # huggingface-cli download NovaSky-AI/SkyRL-SQL-653-data-newfmt --local-dir $HOME/data/sql --repo-type dataset | ||
| # export WANDB_API_KEY=<your_key_here> | ||
| # bash examples/text_to_sql/run_skyrl_sql.sh | ||
|
|
||
| # change these paths to your own | ||
| DATA_DIR="$HOME/data/sql" | ||
| DB_PATH="$HOME/data/sql/db_files/data" | ||
| CKPT_PATH="$HOME/ckpts/skyrl_sql_7B_ckpt" | ||
|
|
||
| NUM_GPUS=8 | ||
| NUM_INFERENCE_ENGINES=2 | ||
| TP_SIZE=4 | ||
| MAX_INPUT_LENGTH=29000 | ||
| MAX_GENERATE_LENGTH=3000 | ||
| TRAIN_BATCH_SIZE=256 | ||
|
|
||
| uv run --isolated --extra vllm -m skyrl_train.entrypoints.main_base \ | ||
| trainer.algorithm.advantage_estimator="grpo" \ | ||
| data.train_data="['$DATA_DIR/train.parquet']" \ | ||
| data.val_data="['$DATA_DIR/validation.parquet']" \ | ||
| trainer.policy.model.path="Qwen/Qwen2.5-Coder-7B-Instruct" \ | ||
| trainer.epochs=30 \ | ||
| trainer.placement.colocate_all=true \ | ||
| trainer.strategy=fsdp2 \ | ||
| trainer.policy.fsdp_config.cpu_offload=false \ | ||
| trainer.ref.fsdp_config.cpu_offload=true \ | ||
| trainer.policy.optimizer_config.max_grad_norm=0.5 \ | ||
| trainer.policy.sequence_parallel_size=1 \ | ||
| trainer.placement.policy_num_gpus_per_node=$NUM_GPUS \ | ||
| trainer.placement.ref_num_gpus_per_node=$NUM_GPUS \ | ||
| generator.num_inference_engines=$NUM_INFERENCE_ENGINES \ | ||
| generator.inference_engine_tensor_parallel_size=$TP_SIZE \ | ||
| trainer.train_batch_size=$TRAIN_BATCH_SIZE \ | ||
| trainer.micro_forward_batch_size_per_gpu=8 \ | ||
| trainer.micro_train_batch_size_per_gpu=1 \ | ||
| trainer.max_prompt_length=6000 \ | ||
| generator.max_input_length=$MAX_INPUT_LENGTH \ | ||
| generator.sampling_params.max_generate_length=$MAX_GENERATE_LENGTH \ | ||
| trainer.policy.optimizer_config.lr=1.0e-6 \ | ||
| trainer.policy_mini_batch_size=256 \ | ||
| trainer.algorithm.use_kl_loss=false \ | ||
| trainer.ckpt_interval=60 \ | ||
| trainer.hf_save_interval=30 \ | ||
| trainer.dump_data_batch=true \ | ||
| generator.backend=vllm \ | ||
| generator.run_engines_locally=true \ | ||
| generator.weight_sync_backend=nccl \ | ||
| generator.async_engine=true \ | ||
| generator.batched=false \ | ||
| environment.env_class=text2sql \ | ||
| generator.use_conversation_multi_turn=true \ | ||
| generator.n_samples_per_prompt=5 \ | ||
| generator.gpu_memory_utilization=0.7 \ | ||
| generator.max_turns=6 \ | ||
| generator.sampling_params.temperature=0.6 \ | ||
| generator.sampling_params.top_p=0.95 \ | ||
| generator.sampling_params.stop='["</sql>", "</solution>"]' \ | ||
| generator.append_eos_token_after_stop_str_in_multi_turn=true \ | ||
| generator.eval_sampling_params.stop='["</sql>", "</solution>"]' \ | ||
| environment.skyrl_gym.text2sql.db_path=$DB_PATH \ | ||
| trainer.logger="wandb" \ | ||
| trainer.project_name="skyrlsql" \ | ||
| trainer.run_name="skyrlsql_repro" \ | ||
| trainer.resume_mode=latest \ | ||
| trainer.ckpt_path=$CKPT_PATH \ | ||
| trainer.eval_batch_size=1024 \ | ||
| trainer.eval_before_train=true \ | ||
| trainer.eval_interval=5 \ | ||
| $@ | ||
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
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.
It would be best for our Generator to handle this case, and to link that as an example in the doc.
Currently, both the search and the sql scripts use
use_conversation_multi_turn=False, but technically after #123 , these should be able to douse_conversation_multi_turn=Truewith limited effect on performance.Ideally, I'd like SkyGymGenerator to handle this case in this PR itself. Could you modify SkyGymGenerator to support
use_conversation_multi_turnand customstoptokens?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.
Yes makes sense. I'll add a flag to toggle it and add a multi-turn search-R1 script
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.
Should be addressed with flag
append_eos_token_after_stop_str_in_multi_turn. Updated PR description and a new unit test.Could you take another look when you get a chance? Thanks!
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.
Nvm, just realized
sampling_paramsis None in the generator level. Will further fixThere 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.
@SumanthRH ready again!