Repository navigation
[fsdp] fix: use torch 2.7 state dict api for torch 2.6 to resolve OOM - #2606
Conversation
There was a problem hiding this comment.
Code Review
This pull request addresses an Out-Of-Memory issue in torch<2.7 by backporting the state_dict API from torch 2.7. The approach of vendoring the newer code and using it conditionally based on the PyTorch version is sound. However, the changes include debugging code in verl/workers/fsdp_workers.py that must be removed before merging, as it contains a hard breakpoint that will halt execution.
|
|
||
| @register(dispatch_mode=Dispatch.ONE_TO_ALL) | ||
| def init_model(self): | ||
| torch.cuda.memory._record_memory_history(max_entries=10000000) |
| try: | ||
| ( | ||
| self.actor_module_fsdp, | ||
| self.actor_optimizer, | ||
| self.actor_lr_scheduler, | ||
| self.actor_model_config, | ||
| ) = self._build_model_optimizer( | ||
| model_path=local_path, | ||
| fsdp_config=fsdp_config, | ||
| optim_config=optim_config, | ||
| override_model_config=override_model_config, | ||
| use_remove_padding=use_remove_padding, | ||
| use_fused_kernels=use_fused_kernels, | ||
| enable_gradient_checkpointing=self.config.model.get("enable_gradient_checkpointing", False), | ||
| trust_remote_code=self.config.model.get("trust_remote_code", False), | ||
| use_liger=self.config.model.get("use_liger", False), | ||
| role="actor", | ||
| enable_activation_offload=self.config.model.get("enable_activation_offload", False), | ||
| ) | ||
| except Exception: | ||
| torch.cuda.memory._dump_snapshot(f"{self.config.actor.strategy}_rank{torch.distributed.get_rank()}.pkl") | ||
| torch.cuda.memory._dump_snapshot(f"{self.config.actor.strategy}_rank{torch.distributed.get_rank()}.pkl") | ||
| torch.distributed.breakpoint() |
There was a problem hiding this comment.
This try...except block and the subsequent lines for memory snapshotting and breakpointing appear to be debugging code. The torch.distributed.breakpoint() will halt execution, and memory dumps are not intended for production code. This debugging logic should be removed.
(
self.actor_module_fsdp,
self.actor_optimizer,
self.actor_lr_scheduler,
self.actor_model_config,
) = self._build_model_optimizer(
model_path=local_path,
fsdp_config=fsdp_config,
optim_config=optim_config,
override_model_config=override_model_config,
use_remove_padding=use_remove_padding,
use_fused_kernels=use_fused_kernels,
enable_gradient_checkpointing=self.config.model.get("enable_gradient_checkpointing", False),
trust_remote_code=self.config.model.get("trust_remote_code", False),
use_liger=self.config.model.get("use_liger", False),
role="actor",
enable_activation_offload=self.config.model.get("enable_activation_offload", False),
)| ) | ||
| except Exception: | ||
| torch.cuda.memory._dump_snapshot(f"{self.config.actor.strategy}_rank{torch.distributed.get_rank()}.pkl") | ||
| torch.cuda.memory._dump_snapshot(f"{self.config.actor.strategy}_rank{torch.distributed.get_rank()}.pkl") |
There was a problem hiding this comment.
is this code for debugging only?
There was a problem hiding this comment.
yeap. I will update the PR to undo all the changes to fsdp_workder.py
There was a problem hiding this comment.
done. the PR is now ready for review
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
| full_state (`dict`): The full state dict to load, can only be on rank 0 | ||
| """ | ||
| from torch.distributed.checkpoint.state_dict import StateDictOptions, set_model_state_dict | ||
|
|
There was a problem hiding this comment.
fsdp_utils.py has the true change @eric-haibin-lin
third_party/torch are just copy-paste from torch==2.7.0 (state_dict.py and _state_dict_utils.py)
|
@eric-haibin-lin should we kick off CI? |
…verl-project#2606) ### What does this PR do? for torch==2.6.0, distributed state dict is buggy and can leads to OOM copy the fixed state dict api from torch==2.7.0 to verl/third_party. It's convinent for users who cannot upgrade to torch==2.7.0 ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: ... - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python HYDRA_FULL_ERROR=1 CUDA_LAUNCH_BLOCKING=1 python3 -m verl.trainer.main_ppo algorithm.adv_estimator=grpo data.train_files=$HOME/data/gsm8k/train.parquet data.val_files=$HOME/data/gsm8k/test.parquet data.train_batch_size=512 data.max_prompt_length=1024 data.max_response_length=2048 data.filter_overlong_prompts=True data.truncation='error' data.image_key=images actor_rollout_ref.model.path=Qwen/Qwen2.5-VL-32B-Instruct actor_rollout_ref.model.use_remove_padding=True actor_rollout_ref.model.enable_gradient_checkpointing=True actor_rollout_ref.actor.strategy=fsdp2 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=10 actor_rollout_ref.actor.use_kl_loss=True actor_rollout_ref.actor.kl_loss_coef=0.01 actor_rollout_ref.actor.kl_loss_type=low_var_kl actor_rollout_ref.actor.entropy_coeff=0 actor_rollout_ref.rollout.name=vllm actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=20 actor_rollout_ref.rollout.tensor_model_parallel_size=4 actor_rollout_ref.rollout.gpu_memory_utilization=0.6 actor_rollout_ref.rollout.enable_chunked_prefill=True actor_rollout_ref.rollout.enforce_eager=False actor_rollout_ref.rollout.free_cache_engine=False actor_rollout_ref.rollout.n=5 actor_rollout_ref.ref.strategy=fsdp2 actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=20 actor_rollout_ref.ref.fsdp_config.param_offload=True trainer.critic_warmup=0 trainer.logger=['console','tensorboard'] trainer.project_name='verl_grpo_example_geo3k' trainer.experiment_name='qwen2_5_vl_32b_function_rm' trainer.n_gpus_per_node=8 trainer.nnodes=1 trainer.save_freq=-1 trainer.test_freq=5 trainer.total_epochs=5 ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [x] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [x] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [x] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). FSDP2 memory snapshot: cpu offloading works and peak memory is slightly lower than FSDP1 <img width="1193" height="543" alt="Screenshot 2025-07-17 at 14 53 49" src="https://github.com/user-attachments/assets/2d5b88b2-0d9e-40f7-ad75-f42b9acf1bab" /> --------- Co-authored-by: H <linhaibin.eric@gmail.com>
|
Still have oom issue using fsdp2_load_full_state_dict after upgrading to verl-0.5.0 release, using torch 2.6.0. May still need to upgrade torch version? |
probably to install verl from source code directly to include the fix |
…verl-project#2606) ### What does this PR do? for torch==2.6.0, distributed state dict is buggy and can leads to OOM copy the fixed state dict api from torch==2.7.0 to verl/third_party. It's convinent for users who cannot upgrade to torch==2.7.0 ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: ... - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python HYDRA_FULL_ERROR=1 CUDA_LAUNCH_BLOCKING=1 python3 -m verl.trainer.main_ppo algorithm.adv_estimator=grpo data.train_files=$HOME/data/gsm8k/train.parquet data.val_files=$HOME/data/gsm8k/test.parquet data.train_batch_size=512 data.max_prompt_length=1024 data.max_response_length=2048 data.filter_overlong_prompts=True data.truncation='error' data.image_key=images actor_rollout_ref.model.path=Qwen/Qwen2.5-VL-32B-Instruct actor_rollout_ref.model.use_remove_padding=True actor_rollout_ref.model.enable_gradient_checkpointing=True actor_rollout_ref.actor.strategy=fsdp2 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=10 actor_rollout_ref.actor.use_kl_loss=True actor_rollout_ref.actor.kl_loss_coef=0.01 actor_rollout_ref.actor.kl_loss_type=low_var_kl actor_rollout_ref.actor.entropy_coeff=0 actor_rollout_ref.rollout.name=vllm actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=20 actor_rollout_ref.rollout.tensor_model_parallel_size=4 actor_rollout_ref.rollout.gpu_memory_utilization=0.6 actor_rollout_ref.rollout.enable_chunked_prefill=True actor_rollout_ref.rollout.enforce_eager=False actor_rollout_ref.rollout.free_cache_engine=False actor_rollout_ref.rollout.n=5 actor_rollout_ref.ref.strategy=fsdp2 actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=20 actor_rollout_ref.ref.fsdp_config.param_offload=True trainer.critic_warmup=0 trainer.logger=['console','tensorboard'] trainer.project_name='verl_grpo_example_geo3k' trainer.experiment_name='qwen2_5_vl_32b_function_rm' trainer.n_gpus_per_node=8 trainer.nnodes=1 trainer.save_freq=-1 trainer.test_freq=5 trainer.total_epochs=5 ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [x] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [x] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [x] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). FSDP2 memory snapshot: cpu offloading works and peak memory is slightly lower than FSDP1 <img width="1193" height="543" alt="Screenshot 2025-07-17 at 14 53 49" src="https://github.com/user-attachments/assets/2d5b88b2-0d9e-40f7-ad75-f42b9acf1bab" /> --------- Co-authored-by: H <linhaibin.eric@gmail.com>
…verl-project#2606) ### What does this PR do? for torch==2.6.0, distributed state dict is buggy and can leads to OOM copy the fixed state dict api from torch==2.7.0 to verl/third_party. It's convinent for users who cannot upgrade to torch==2.7.0 ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: ... - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python HYDRA_FULL_ERROR=1 CUDA_LAUNCH_BLOCKING=1 python3 -m verl.trainer.main_ppo algorithm.adv_estimator=grpo data.train_files=$HOME/data/gsm8k/train.parquet data.val_files=$HOME/data/gsm8k/test.parquet data.train_batch_size=512 data.max_prompt_length=1024 data.max_response_length=2048 data.filter_overlong_prompts=True data.truncation='error' data.image_key=images actor_rollout_ref.model.path=Qwen/Qwen2.5-VL-32B-Instruct actor_rollout_ref.model.use_remove_padding=True actor_rollout_ref.model.enable_gradient_checkpointing=True actor_rollout_ref.actor.strategy=fsdp2 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=10 actor_rollout_ref.actor.use_kl_loss=True actor_rollout_ref.actor.kl_loss_coef=0.01 actor_rollout_ref.actor.kl_loss_type=low_var_kl actor_rollout_ref.actor.entropy_coeff=0 actor_rollout_ref.rollout.name=vllm actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=20 actor_rollout_ref.rollout.tensor_model_parallel_size=4 actor_rollout_ref.rollout.gpu_memory_utilization=0.6 actor_rollout_ref.rollout.enable_chunked_prefill=True actor_rollout_ref.rollout.enforce_eager=False actor_rollout_ref.rollout.free_cache_engine=False actor_rollout_ref.rollout.n=5 actor_rollout_ref.ref.strategy=fsdp2 actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=20 actor_rollout_ref.ref.fsdp_config.param_offload=True trainer.critic_warmup=0 trainer.logger=['console','tensorboard'] trainer.project_name='verl_grpo_example_geo3k' trainer.experiment_name='qwen2_5_vl_32b_function_rm' trainer.n_gpus_per_node=8 trainer.nnodes=1 trainer.save_freq=-1 trainer.test_freq=5 trainer.total_epochs=5 ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [x] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [x] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [x] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). FSDP2 memory snapshot: cpu offloading works and peak memory is slightly lower than FSDP1 <img width="1193" height="543" alt="Screenshot 2025-07-17 at 14 53 49" src="https://github.com/user-attachments/assets/2d5b88b2-0d9e-40f7-ad75-f42b9acf1bab" /> --------- Co-authored-by: H <linhaibin.eric@gmail.com>
…verl-project#2606) ### What does this PR do? for torch==2.6.0, distributed state dict is buggy and can leads to OOM copy the fixed state dict api from torch==2.7.0 to verl/third_party. It's convinent for users who cannot upgrade to torch==2.7.0 ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: ... - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python HYDRA_FULL_ERROR=1 CUDA_LAUNCH_BLOCKING=1 python3 -m verl.trainer.main_ppo algorithm.adv_estimator=grpo data.train_files=$HOME/data/gsm8k/train.parquet data.val_files=$HOME/data/gsm8k/test.parquet data.train_batch_size=512 data.max_prompt_length=1024 data.max_response_length=2048 data.filter_overlong_prompts=True data.truncation='error' data.image_key=images actor_rollout_ref.model.path=Qwen/Qwen2.5-VL-32B-Instruct actor_rollout_ref.model.use_remove_padding=True actor_rollout_ref.model.enable_gradient_checkpointing=True actor_rollout_ref.actor.strategy=fsdp2 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=10 actor_rollout_ref.actor.use_kl_loss=True actor_rollout_ref.actor.kl_loss_coef=0.01 actor_rollout_ref.actor.kl_loss_type=low_var_kl actor_rollout_ref.actor.entropy_coeff=0 actor_rollout_ref.rollout.name=vllm actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=20 actor_rollout_ref.rollout.tensor_model_parallel_size=4 actor_rollout_ref.rollout.gpu_memory_utilization=0.6 actor_rollout_ref.rollout.enable_chunked_prefill=True actor_rollout_ref.rollout.enforce_eager=False actor_rollout_ref.rollout.free_cache_engine=False actor_rollout_ref.rollout.n=5 actor_rollout_ref.ref.strategy=fsdp2 actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=20 actor_rollout_ref.ref.fsdp_config.param_offload=True trainer.critic_warmup=0 trainer.logger=['console','tensorboard'] trainer.project_name='verl_grpo_example_geo3k' trainer.experiment_name='qwen2_5_vl_32b_function_rm' trainer.n_gpus_per_node=8 trainer.nnodes=1 trainer.save_freq=-1 trainer.test_freq=5 trainer.total_epochs=5 ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [x] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [x] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [x] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). FSDP2 memory snapshot: cpu offloading works and peak memory is slightly lower than FSDP1 <img width="1193" height="543" alt="Screenshot 2025-07-17 at 14 53 49" src="https://github.com/user-attachments/assets/2d5b88b2-0d9e-40f7-ad75-f42b9acf1bab" /> --------- Co-authored-by: H <linhaibin.eric@gmail.com>
…verl-project#2606) ### What does this PR do? for torch==2.6.0, distributed state dict is buggy and can leads to OOM copy the fixed state dict api from torch==2.7.0 to verl/third_party. It's convinent for users who cannot upgrade to torch==2.7.0 ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: ... - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python HYDRA_FULL_ERROR=1 CUDA_LAUNCH_BLOCKING=1 python3 -m verl.trainer.main_ppo algorithm.adv_estimator=grpo data.train_files=$HOME/data/gsm8k/train.parquet data.val_files=$HOME/data/gsm8k/test.parquet data.train_batch_size=512 data.max_prompt_length=1024 data.max_response_length=2048 data.filter_overlong_prompts=True data.truncation='error' data.image_key=images actor_rollout_ref.model.path=Qwen/Qwen2.5-VL-32B-Instruct actor_rollout_ref.model.use_remove_padding=True actor_rollout_ref.model.enable_gradient_checkpointing=True actor_rollout_ref.actor.strategy=fsdp2 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=10 actor_rollout_ref.actor.use_kl_loss=True actor_rollout_ref.actor.kl_loss_coef=0.01 actor_rollout_ref.actor.kl_loss_type=low_var_kl actor_rollout_ref.actor.entropy_coeff=0 actor_rollout_ref.rollout.name=vllm actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=20 actor_rollout_ref.rollout.tensor_model_parallel_size=4 actor_rollout_ref.rollout.gpu_memory_utilization=0.6 actor_rollout_ref.rollout.enable_chunked_prefill=True actor_rollout_ref.rollout.enforce_eager=False actor_rollout_ref.rollout.free_cache_engine=False actor_rollout_ref.rollout.n=5 actor_rollout_ref.ref.strategy=fsdp2 actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=20 actor_rollout_ref.ref.fsdp_config.param_offload=True trainer.critic_warmup=0 trainer.logger=['console','tensorboard'] trainer.project_name='verl_grpo_example_geo3k' trainer.experiment_name='qwen2_5_vl_32b_function_rm' trainer.n_gpus_per_node=8 trainer.nnodes=1 trainer.save_freq=-1 trainer.test_freq=5 trainer.total_epochs=5 ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [x] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [x] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [x] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). FSDP2 memory snapshot: cpu offloading works and peak memory is slightly lower than FSDP1 <img width="1193" height="543" alt="Screenshot 2025-07-17 at 14 53 49" src="https://github.com/user-attachments/assets/2d5b88b2-0d9e-40f7-ad75-f42b9acf1bab" /> --------- Co-authored-by: H <linhaibin.eric@gmail.com>
…verl-project#2606) ### What does this PR do? for torch==2.6.0, distributed state dict is buggy and can leads to OOM copy the fixed state dict api from torch==2.7.0 to verl/third_party. It's convinent for users who cannot upgrade to torch==2.7.0 ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: ... - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python HYDRA_FULL_ERROR=1 CUDA_LAUNCH_BLOCKING=1 python3 -m verl.trainer.main_ppo algorithm.adv_estimator=grpo data.train_files=$HOME/data/gsm8k/train.parquet data.val_files=$HOME/data/gsm8k/test.parquet data.train_batch_size=512 data.max_prompt_length=1024 data.max_response_length=2048 data.filter_overlong_prompts=True data.truncation='error' data.image_key=images actor_rollout_ref.model.path=Qwen/Qwen2.5-VL-32B-Instruct actor_rollout_ref.model.use_remove_padding=True actor_rollout_ref.model.enable_gradient_checkpointing=True actor_rollout_ref.actor.strategy=fsdp2 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=10 actor_rollout_ref.actor.use_kl_loss=True actor_rollout_ref.actor.kl_loss_coef=0.01 actor_rollout_ref.actor.kl_loss_type=low_var_kl actor_rollout_ref.actor.entropy_coeff=0 actor_rollout_ref.rollout.name=vllm actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=20 actor_rollout_ref.rollout.tensor_model_parallel_size=4 actor_rollout_ref.rollout.gpu_memory_utilization=0.6 actor_rollout_ref.rollout.enable_chunked_prefill=True actor_rollout_ref.rollout.enforce_eager=False actor_rollout_ref.rollout.free_cache_engine=False actor_rollout_ref.rollout.n=5 actor_rollout_ref.ref.strategy=fsdp2 actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=20 actor_rollout_ref.ref.fsdp_config.param_offload=True trainer.critic_warmup=0 trainer.logger=['console','tensorboard'] trainer.project_name='verl_grpo_example_geo3k' trainer.experiment_name='qwen2_5_vl_32b_function_rm' trainer.n_gpus_per_node=8 trainer.nnodes=1 trainer.save_freq=-1 trainer.test_freq=5 trainer.total_epochs=5 ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [x] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [x] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [x] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). FSDP2 memory snapshot: cpu offloading works and peak memory is slightly lower than FSDP1 <img width="1193" height="543" alt="Screenshot 2025-07-17 at 14 53 49" src="https://github.com/user-attachments/assets/2d5b88b2-0d9e-40f7-ad75-f42b9acf1bab" /> --------- Co-authored-by: H <linhaibin.eric@gmail.com>
…verl-project#2606) ### What does this PR do? for torch==2.6.0, distributed state dict is buggy and can leads to OOM copy the fixed state dict api from torch==2.7.0 to verl/third_party. It's convinent for users who cannot upgrade to torch==2.7.0 ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: ... - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python HYDRA_FULL_ERROR=1 CUDA_LAUNCH_BLOCKING=1 python3 -m verl.trainer.main_ppo algorithm.adv_estimator=grpo data.train_files=$HOME/data/gsm8k/train.parquet data.val_files=$HOME/data/gsm8k/test.parquet data.train_batch_size=512 data.max_prompt_length=1024 data.max_response_length=2048 data.filter_overlong_prompts=True data.truncation='error' data.image_key=images actor_rollout_ref.model.path=Qwen/Qwen2.5-VL-32B-Instruct actor_rollout_ref.model.use_remove_padding=True actor_rollout_ref.model.enable_gradient_checkpointing=True actor_rollout_ref.actor.strategy=fsdp2 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=10 actor_rollout_ref.actor.use_kl_loss=True actor_rollout_ref.actor.kl_loss_coef=0.01 actor_rollout_ref.actor.kl_loss_type=low_var_kl actor_rollout_ref.actor.entropy_coeff=0 actor_rollout_ref.rollout.name=vllm actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=20 actor_rollout_ref.rollout.tensor_model_parallel_size=4 actor_rollout_ref.rollout.gpu_memory_utilization=0.6 actor_rollout_ref.rollout.enable_chunked_prefill=True actor_rollout_ref.rollout.enforce_eager=False actor_rollout_ref.rollout.free_cache_engine=False actor_rollout_ref.rollout.n=5 actor_rollout_ref.ref.strategy=fsdp2 actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=20 actor_rollout_ref.ref.fsdp_config.param_offload=True trainer.critic_warmup=0 trainer.logger=['console','tensorboard'] trainer.project_name='verl_grpo_example_geo3k' trainer.experiment_name='qwen2_5_vl_32b_function_rm' trainer.n_gpus_per_node=8 trainer.nnodes=1 trainer.save_freq=-1 trainer.test_freq=5 trainer.total_epochs=5 ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [x] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [x] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [x] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). FSDP2 memory snapshot: cpu offloading works and peak memory is slightly lower than FSDP1 <img width="1193" height="543" alt="Screenshot 2025-07-17 at 14 53 49" src="https://github.com/user-attachments/assets/2d5b88b2-0d9e-40f7-ad75-f42b9acf1bab" /> --------- Co-authored-by: H <linhaibin.eric@gmail.com>
…verl-project#2606) ### What does this PR do? for torch==2.6.0, distributed state dict is buggy and can leads to OOM copy the fixed state dict api from torch==2.7.0 to verl/third_party. It's convinent for users who cannot upgrade to torch==2.7.0 ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: ... - [x] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. ```python HYDRA_FULL_ERROR=1 CUDA_LAUNCH_BLOCKING=1 python3 -m verl.trainer.main_ppo algorithm.adv_estimator=grpo data.train_files=$HOME/data/gsm8k/train.parquet data.val_files=$HOME/data/gsm8k/test.parquet data.train_batch_size=512 data.max_prompt_length=1024 data.max_response_length=2048 data.filter_overlong_prompts=True data.truncation='error' data.image_key=images actor_rollout_ref.model.path=Qwen/Qwen2.5-VL-32B-Instruct actor_rollout_ref.model.use_remove_padding=True actor_rollout_ref.model.enable_gradient_checkpointing=True actor_rollout_ref.actor.strategy=fsdp2 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=10 actor_rollout_ref.actor.use_kl_loss=True actor_rollout_ref.actor.kl_loss_coef=0.01 actor_rollout_ref.actor.kl_loss_type=low_var_kl actor_rollout_ref.actor.entropy_coeff=0 actor_rollout_ref.rollout.name=vllm actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=20 actor_rollout_ref.rollout.tensor_model_parallel_size=4 actor_rollout_ref.rollout.gpu_memory_utilization=0.6 actor_rollout_ref.rollout.enable_chunked_prefill=True actor_rollout_ref.rollout.enforce_eager=False actor_rollout_ref.rollout.free_cache_engine=False actor_rollout_ref.rollout.n=5 actor_rollout_ref.ref.strategy=fsdp2 actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=20 actor_rollout_ref.ref.fsdp_config.param_offload=True trainer.critic_warmup=0 trainer.logger=['console','tensorboard'] trainer.project_name='verl_grpo_example_geo3k' trainer.experiment_name='qwen2_5_vl_32b_function_rm' trainer.n_gpus_per_node=8 trainer.nnodes=1 trainer.save_freq=-1 trainer.test_freq=5 trainer.total_epochs=5 ``` ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [x] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [x] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [x] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). FSDP2 memory snapshot: cpu offloading works and peak memory is slightly lower than FSDP1 <img width="1193" height="543" alt="Screenshot 2025-07-17 at 14 53 49" src="https://github.com/user-attachments/assets/2d5b88b2-0d9e-40f7-ad75-f42b9acf1bab" /> --------- Co-authored-by: H <linhaibin.eric@gmail.com>
What does this PR do?
for torch==2.6.0, distributed state dict is buggy and can leads to OOM
copy the fixed state dict api from torch==2.7.0 to verl/third_party. It's convinent for users who cannot upgrade to torch==2.7.0
Checklist Before Starting
[{modules}] {type}: {description}(This will be checked by the CI){modules}includefsdp,megatron,sglang,vllm,rollout,trainer,ci,training_utils,recipe,hardware,deployment,ray,worker,single_controller,misc,perf,model,algo,env,tool,ckpt,doc,data,like[megatron, fsdp, doc]{type}is infeat,fix,refactor,chore,test[BREAKING]to the beginning of the title.[BREAKING][fsdp, megatron] feat: dynamic batchingTest
API and Usage Example
Design & Code Changes
Checklist Before Submitting
Important
Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review.
pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=alwaysci-requestchannel in theverlSlack workspace.FSDP2 memory snapshot: cpu offloading works and peak memory is slightly lower than FSDP1
