FSDP2 Leads to `AttributeError` on HF Qwen2.5 Model
Error message: It happens at the end of validation:
(WorkerDict pid=33418) [DP=0,TP=0] execute_method: wake_up
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] Invocation of wake_up method failed
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] Traceback (most recent call last):
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/opt/conda/lib/python3.12/site-packages/vllm/v1/engine/core.py", line 697, in _handle_client_request
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] output.result = method(
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] ^^^^^^^
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/opt/conda/lib/python3.12/site-packages/vllm/v1/engine/core.py", line 353, in wake_up
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] self.model_executor.wake_up(tags)
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/opt/conda/lib/python3.12/site-packages/vllm/executor/executor_base.py", line 201, in wake_up
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] self.collective_rpc("wake_up", kwargs=dict(tags=tags))
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/workspace/mnt/rllm/verl/verl/workers/rollout/vllm_rollout/vllm_async_server.py", line 104, in collective_rpc
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] outputs = ray.get([worker.execute_method.remote(sent_method, *args, **(kwargs or {})) for worker in self.workers])
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/opt/conda/lib/python3.12/site-packages/ray/_private/auto_init_hook.py", line 22, in auto_init_wrapper
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] return fn(*args, **kwargs)
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] ^^^^^^^^^^^^^^^^^^^
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/opt/conda/lib/python3.12/site-packages/ray/_private/client_mode_hook.py", line 104, in wrapper
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] return func(*args, **kwargs)
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] ^^^^^^^^^^^^^^^^^^^^^
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/opt/conda/lib/python3.12/site-packages/ray/_private/worker.py", line 2858, in get
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] values, debugger_breakpoint = worker.get_objects(object_refs, timeout=timeout)
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/opt/conda/lib/python3.12/site-packages/ray/_private/worker.py", line 958, in get_objects
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] raise value.as_instanceof_cause()
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] ray.exceptions.RayTaskError(AttributeError): ray::WorkerDict.execute_method() (pid=33418, ip=10.244.241.92, actor_id=909e7b1446d1ae8cbba6e10701000000, repr=<verl.single_controller.ray.base.WorkerDict object at 0x7fb294f1a6c0>)
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/opt/conda/lib/python3.12/concurrent/futures/_base.py", line 449, in result
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] return self.__get_result()
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] ^^^^^^^^^^^^^^^^^^^
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/opt/conda/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] raise self._exception
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] ^^^^^^^^^^^^^^^^^^^^^
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/workspace/mnt/rllm/verl/verl/single_controller/ray/base.py", line 638, in func
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] return getattr(self.worker_dict[key], name)(*args, **kwargs)
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/workspace/mnt/rllm/verl/verl/single_controller/base/decorator.py", line 540, in inner_regular
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] return func(*args, **kwargs)
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] ^^^^^^^^^^^^^^^^^^^^^
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/workspace/mnt/rllm/verl/verl/workers/fsdp_workers.py", line 1772, in execute_method
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] return self.rollout.execute_method(method, *args, **kwargs)
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/workspace/mnt/rllm/verl/verl/workers/rollout/vllm_rollout/vllm_rollout_spmd.py", line 450, in execute_method
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] return self.wake_up(*args, **kwargs)
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/workspace/mnt/rllm/verl/verl/workers/rollout/vllm_rollout/vllm_rollout_spmd.py", line 439, in wake_up
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] self.sharding_manager.__enter__() # pylint: disable=C2801
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/workspace/mnt/rllm/verl/verl/utils/debug/performance.py", line 80, in f
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] return self.log(decorated_function, *args, **kwargs)
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/workspace/mnt/rllm/verl/verl/utils/debug/performance.py", line 90, in log
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] output = func(*args, **kwargs)
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] ^^^^^^^^^^^^^^^^^^^^^
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/workspace/mnt/rllm/verl/verl/workers/sharding_manager/fsdp_vllm.py", line 179, in __enter__
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] if isinstance(self.module._fsdp_wrapped_module, PeftModel):
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] File "/opt/conda/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1940, in __getattr__
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] raise AttributeError(
(AsyncvLLMServer pid=34963) ERROR 08-02 22:16:00 [core.py:700] AttributeError: 'FSDPQwen2ForCausalLM' object has no attribute '_fsdp_wrapped_module'
(train_agent pid=32594) Exception in thread Thread-7 (runner):
(train_agent pid=32594) Traceback (most recent call last):
(train_agent pid=32594) File "/opt/conda/lib/python3.12/threading.py", line 1075, in _bootstrap_inner
(train_agent pid=32594) self.run()
(train_agent pid=32594) File "/opt/conda/lib/python3.12/threading.py", line 1012, in run
(train_agent pid=32594) self._target(*self._args, **self._kwargs)
(train_agent pid=32594) File "/workspace/mnt/rllm/rllm/trainer/verl/agent_ppo_trainer.py", line 822, in runner
(train_agent pid=32594) asyncio.run(consume())
(train_agent pid=32594) File "/opt/conda/lib/python3.12/asyncio/runners.py", line 195, in run
(train_agent pid=32594) return runner.run(main)
(train_agent pid=32594) ^^^^^^^^^^^^^^^^
(train_agent pid=32594) File "/opt/conda/lib/python3.12/asyncio/runners.py", line 118, in run
(train_agent pid=32594) return self._loop.run_until_complete(task)
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) File "uvloop/loop.pyx", line 1518, in uvloop.loop.Loop.run_until_complete
(train_agent pid=32594) File "/workspace/mnt/rllm/rllm/trainer/verl/agent_ppo_trainer.py", line 818, in consume
(train_agent pid=32594) async for item in self.agent_execution_engine.trajectory_generator(timing_raw=timing_raw, mode=mode, meta_info=meta_info):
(train_agent pid=32594) File "/workspace/mnt/rllm/rllm/engine/agent_execution_engine.py", line 490, in trajectory_generator
(train_agent pid=32594) self.rollout_engine.wake_up()
(train_agent pid=32594) File "/workspace/mnt/rllm/verl/verl/workers/rollout/async_server.py", line 384, in wake_up
(train_agent pid=32594) ray.get([server.wake_up.remote() for server in self.async_llm_servers])
(train_agent pid=32594) File "/opt/conda/lib/python3.12/site-packages/ray/_private/auto_init_hook.py", line 22, in auto_init_wrapper
(train_agent pid=32594) return fn(*args, **kwargs)
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) File "/opt/conda/lib/python3.12/site-packages/ray/_private/client_mode_hook.py", line 104, in wrapper
(train_agent pid=32594) return func(*args, **kwargs)
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) File "/opt/conda/lib/python3.12/site-packages/ray/_private/worker.py", line 2858, in get
(train_agent pid=32594) values, debugger_breakpoint = worker.get_objects(object_refs, timeout=timeout)
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) File "/opt/conda/lib/python3.12/site-packages/ray/_private/worker.py", line 958, in get_objects
(train_agent pid=32594) raise value.as_instanceof_cause()
(train_agent pid=32594) ray.exceptions.RayTaskError: ray::AsyncvLLMServer.wake_up() (pid=34963, ip=10.244.241.92, actor_id=398a7d95559b96a4c4d52d9701000000, repr=<verl.workers.rollout.vllm_rollout.vllm_async_server.AsyncvLLMServer object at 0x7fa652ec6780>)
(train_agent pid=32594) File "/opt/conda/lib/python3.12/concurrent/futures/_base.py", line 449, in result
(train_agent pid=32594) return self.__get_result()
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) File "/opt/conda/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
(train_agent pid=32594) raise self._exception
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) File "/workspace/mnt/rllm/verl/verl/workers/rollout/vllm_rollout/vllm_async_server.py", line 292, in wake_up
(train_agent pid=32594) await self.engine.wake_up(tags)
(train_agent pid=32594) File "/opt/conda/lib/python3.12/site-packages/vllm/v1/engine/async_llm.py", line 569, in wake_up
(train_agent pid=32594) await self.engine_core.wake_up_async(tags)
(train_agent pid=32594) File "/opt/conda/lib/python3.12/site-packages/vllm/v1/engine/core_client.py", line 827, in wake_up_async
(train_agent pid=32594) await self.call_utility_async("wake_up", tags)
(train_agent pid=32594) File "/opt/conda/lib/python3.12/site-packages/vllm/v1/engine/core_client.py", line 790, in call_utility_async
(train_agent pid=32594) return await self._call_utility_async(method,
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) File "/opt/conda/lib/python3.12/site-packages/vllm/v1/engine/core_client.py", line 803, in _call_utility_async
(train_agent pid=32594) return await future
(train_agent pid=32594) ^^^^^^^^^^^^
(train_agent pid=32594) Exception: Call to wake_up method failed: ray::WorkerDict.execute_method() (pid=33418, ip=10.244.241.92, actor_id=909e7b1446d1ae8cbba6e10701000000, repr=<verl.single_controller.ray.base.WorkerDict object at 0x7fb294f1a6c0>)
(train_agent pid=32594) File "/opt/conda/lib/python3.12/concurrent/futures/_base.py", line 449, in result
(train_agent pid=32594) return self.__get_result()
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) File "/opt/conda/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
(train_agent pid=32594) raise self._exception
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) File "/workspace/mnt/rllm/verl/verl/single_controller/ray/base.py", line 638, in func
(train_agent pid=32594) return getattr(self.worker_dict[key], name)(*args, **kwargs)
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) File "/workspace/mnt/rllm/verl/verl/single_controller/base/decorator.py", line 540, in inner_regular
(train_agent pid=32594) return func(*args, **kwargs)
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) File "/workspace/mnt/rllm/verl/verl/workers/fsdp_workers.py", line 1772, in execute_method
(train_agent pid=32594) return self.rollout.execute_method(method, *args, **kwargs)
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) File "/workspace/mnt/rllm/verl/verl/workers/rollout/vllm_rollout/vllm_rollout_spmd.py", line 450, in execute_method
(train_agent pid=32594) return self.wake_up(*args, **kwargs)
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) File "/workspace/mnt/rllm/verl/verl/workers/rollout/vllm_rollout/vllm_rollout_spmd.py", line 439, in wake_up
(train_agent pid=32594) self.sharding_manager.__enter__() # pylint: disable=C2801
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) File "/workspace/mnt/rllm/verl/verl/utils/debug/performance.py", line 80, in f
(train_agent pid=32594) return self.log(decorated_function, *args, **kwargs)
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) File "/workspace/mnt/rllm/verl/verl/utils/debug/performance.py", line 90, in log
(train_agent pid=32594) output = func(*args, **kwargs)
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) File "/workspace/mnt/rllm/verl/verl/workers/sharding_manager/fsdp_vllm.py", line 179, in __enter__
(train_agent pid=32594) if isinstance(self.module._fsdp_wrapped_module, PeftModel):
(train_agent pid=32594) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(train_agent pid=32594) File "/opt/conda/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1940, in __getattr__
(train_agent pid=32594) raise AttributeError(
(train_agent pid=32594) AttributeError: 'FSDPQwen2ForCausalLM' object has no attribute '_fsdp_wrapped_module'
training file:
import hydra
from rllm.agents import MathAgent
from rllm.data.dataset import DatasetRegistry
from rllm.environments.base.single_turn_env import SingleTurnEnvironment
from rllm.rewards.reward_fn import math_reward_fn
from rllm.trainer.agent_trainer import AgentTrainer
@hydra.main(config_path=".", config_name="ppo", version_base=None)
def main(config):
train_dataset = DatasetRegistry.load_dataset("big_math", "train")
test_dataset = DatasetRegistry.load_dataset("omnimath", "train")
agent_args = {
"accumulate_thinking": True,
}
env_args = {
"reward_fn": math_reward_fn,
}
trainer = AgentTrainer(
agent_class=MathAgent,
env_class=SingleTurnEnvironment,
agent_args=agent_args,
env_args=env_args,
config=config,
train_dataset=train_dataset,
val_dataset=test_dataset,
)
trainer.train()
if __name__ == "__main__":
main()
yaml
data:
tokenizer: null
use_shm: False
train_files: ~/data/rlhf/gsm8k/train.parquet
val_files: ~/data/rlhf/gsm8k/test.parquet
prompt_key: prompt
reward_fn_key: data_source
max_prompt_length: 4096
max_response_length: 16384
train_batch_size: 1024
val_batch_size: null
return_raw_input_ids: False # This should be set to true when the tokenizer between policy and rm differs
return_raw_chat: False
return_full_prompt: False
shuffle: True
filter_overlong_prompts: False # for large-scale dataset, filtering overlong prompts could be timeconsuming. You cat set the filter_overlong_prompts_workers to use multiprocessing to speed up.
filter_overlong_prompts_workers: 1
truncation: error
image_key: images
video_key: videos
trust_remote_code: False # main_ppo will check this config to determine whether to use remote code for tokenizer
custom_cls:
path: null
name: null
actor_rollout_ref:
hybrid_engine: True
model:
path: ~/models/deepseek-llm-7b-chat
use_shm: False
external_lib: null
override_config: { }
enable_gradient_checkpointing: True
enable_activation_offload: False
use_remove_padding: False
lora_rank: 0 # Set to positive value to enable LoRA (e.g., 32)
lora_alpha: 16 # LoRA scaling factor
target_modules: all-linear # all-linear or [q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj]
use_liger: False
use_fused_kernels: False
trust_remote_code: False
actor:
strategy: fsdp # [fsdp, fsdp2], This is for backward-compatibility
ppo_mini_batch_size: 256
ppo_num_mini_batches: 1
ppo_micro_batch_size_per_gpu: 4
use_dynamic_bsz: False
use_dynamic_mini_batch: False
ppo_max_token_len_per_gpu: 16384 # n * ${data.max_prompt_length} + ${data.max_response_length}
grad_clip: 1.0
# pg_losses2 = -advantages * torch.clamp(ratio, 1 - cliprange_low, 1 + cliprange_high)
clip_ratio: 0.2 # default value if clip_ratio_low and clip_ratio_high are not specified
clip_ratio_low: 0.2
clip_ratio_high: 0.2
clip_ratio_c: 3.0 # lower bound of the value for Dual-clip PPO from https://arxiv.org/pdf/1912.09729
loss_agg_mode: "token-mean" # / "seq-mean-token-sum" / "seq-mean-token-mean"
entropy_coeff: 0
use_kl_loss: False # True for GRPO
use_torch_compile: True # False to disable torch compile
kl_loss_coef: 0.001 # for grpo
kl_loss_type: low_var_kl # for grpo
ppo_epochs: 1
shuffle: False
ulysses_sequence_parallel_size: 1 # sp size
checkpoint:
contents: ['model', 'optimizer', 'extra'] # with 'hf_model' you can save whole model as hf format, now only use sharded model checkpoint to save space
optim:
lr: 1e-6
lr_warmup_steps: -1 # Prioritized. Negative values mean delegating to lr_warmup_steps_ratio.
lr_warmup_steps_ratio: 0. # the total steps will be injected during runtime
min_lr_ratio: null # only useful for warmup with cosine
num_cycles: 0.5 # only used with cosine lr scheduler, default to 0.5
warmup_style: constant # select from constant/cosine
total_training_steps: -1 # must be override by program
weight_decay: 0.01
fsdp_config:
wrap_policy:
# transformer_layer_cls_to_wrap: None
min_num_params: 0
param_offload: False
optimizer_offload: False
offload_policy: False # only for fsdp2, offload param\grad\optimizer during train
reshard_after_forward: False # only for fsdp2, [True, False, int between 1 and fsdp_size]
fsdp_size: -1
# RLLM Arguments
grad_norm_threshold: 1e5 # Max grad norm to skip gradient update.
ref:
strategy: fsdp
fsdp_config:
param_offload: False
reshard_after_forward: False # only for fsdp2, [True, False, int between 1 and fsdp_size]
wrap_policy:
# transformer_layer_cls_to_wrap: None
min_num_params: 0
use_torch_compile: ${actor_rollout_ref.actor.use_torch_compile}
log_prob_micro_batch_size_per_gpu: null
log_prob_use_dynamic_bsz: ${actor_rollout_ref.actor.use_dynamic_bsz}
log_prob_max_token_len_per_gpu: ${actor_rollout_ref.actor.ppo_max_token_len_per_gpu}
ulysses_sequence_parallel_size: ${actor_rollout_ref.actor.ulysses_sequence_parallel_size} # sp size
rollout:
name: vllm
mode: sync # sync: LLM, async: AsyncLLM
chat_scheduler: null # async chat scheduler, e.g verl.schedulers.naive_chat_scheduler.NaiveChatCompletionScheduler
chat_template: null
temperature: 1.0
top_k: -1 # 0 for hf rollout, -1 for vllm rollout
top_p: 1
use_fire_sampling: False # https://arxiv.org/abs/2410.21236
prompt_length: ${data.max_prompt_length} # not use for opensource
response_length: ${data.max_response_length}
# for vllm rollout
dtype: bfloat16 # should align with FSDP
gpu_memory_utilization: 0.5
ignore_eos: False
enforce_eager: False
free_cache_engine: False
load_format: dummy_dtensor # safetensors (for huge model, and set use_shm=True); dummy_dtensor: randomly init model weight
layered_summon: False # for huge model, layered summon can save memory (prevent OOM) but make it slower
tensor_model_parallel_size: 2
max_num_batched_tokens: 8192
max_model_len: null
max_num_seqs: 1024
log_prob_micro_batch_size: null # will be deprecated, use log_prob_micro_batch_size_per_gpu
log_prob_micro_batch_size_per_gpu: null
log_prob_use_dynamic_bsz: ${actor_rollout_ref.actor.use_dynamic_bsz}
log_prob_max_token_len_per_gpu: ${actor_rollout_ref.actor.ppo_max_token_len_per_gpu}
disable_log_stats: True
enable_chunked_prefill: True # may get higher throughput when set to True. When activated, Please increase max_num_batched_tokens or decrease max_model_len.
# for hf rollout
do_sample: True
# number of responses (i.e. num sample times)
n: 1 # > 1 for grpo
# Accuracy bounds for filtering (only used when oversample_factor > 1.0)
accuracy_lower_bound: 0.2 # Lower bound for preferred accuracy range
accuracy_upper_bound: 0.8 # Upper bound for preferred accuracy range
engine_kwargs: # inference engine parameters
vllm:
swap_space: null # null means "use the engine default value" (usually 4 GB), setting it to, e.g., 32 means 32 GB
sglang:
attention_backend: null # null means use the engine default value, available options: flashinfer, triton, flashmla
val_kwargs:
# sampling parameters for validation
top_k: -1 # 0 for hf rollout, -1 for vllm rollout
top_p: 1.0
temperature: 0
n: 1
do_sample: False # default eager for validation
multi_turn:
enable: False # should set rollout.name to sglang_async if True
max_turns: null # null for no limit (default max_length // 3)
tool_config_path: null # null for no tool
format: chatml # chatml, more formats will be supported in the future
# RLLM Arguments
disable_logging: True # Disable logging for vLLM async rollout.
oversample_factor: 1.0 # Sample more prompts than batch size for accuracy-based filtering
critic:
rollout_n: ${actor_rollout_ref.rollout.n}
strategy: fsdp # [fsdp, fsdp2]
optim:
lr: 1e-5
lr_warmup_steps_ratio: 0. # the total steps will be injected during runtime
min_lr_ratio: null # only useful for warmup with cosine
warmup_style: constant # select from constant/cosine
total_training_steps: -1 # must be override by program
weight_decay: 0.01
model:
path: ~/models/deepseek-llm-7b-chat
freeze_backbone: True
use_shm: False
tokenizer_path: ${actor_rollout_ref.model.path}
override_config: { }
external_lib: ${actor_rollout_ref.model.external_lib}
enable_gradient_checkpointing: True
enable_activation_offload: False
use_remove_padding: False
trust_remote_code: ${actor_rollout_ref.model.trust_remote_code}
fsdp_config:
param_offload: False
optimizer_offload: False
offload_policy: False # only for fsdp2, offload param\grad\optimizer during train
reshard_after_forward: True # only for fsdp2, [True, False, int between 1 and fsdp_size]
wrap_policy:
# transformer_layer_cls_to_wrap: None
min_num_params: 0
fsdp_size: -1
lora_rank: 0 # Set to positive value to enable LoRA (e.g., 32)
lora_alpha: 16 # LoRA scaling factor
target_modules: all-linear # all-linear or [q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj]
ppo_mini_batch_size: ${actor_rollout_ref.actor.ppo_mini_batch_size}
ppo_micro_batch_size_per_gpu: null
forward_micro_batch_size: ${critic.ppo_micro_batch_size}
forward_micro_batch_size_per_gpu: ${critic.ppo_micro_batch_size_per_gpu}
use_dynamic_bsz: ${actor_rollout_ref.actor.use_dynamic_bsz}
ppo_max_token_len_per_gpu: 32768 # (${actor_rollout_ref.actor.ppo_max_token_len_per_gpu}) * 2
forward_max_token_len_per_gpu: ${critic.ppo_max_token_len_per_gpu}
ulysses_sequence_parallel_size: 1 # sp size
ppo_epochs: ${actor_rollout_ref.actor.ppo_epochs}
shuffle: ${actor_rollout_ref.actor.shuffle}
grad_clip: 1.0
cliprange_value: 0.5
loss_agg_mode: ${actor_rollout_ref.actor.loss_agg_mode}
checkpoint:
contents: ['model', 'optimizer', 'extra'] # with 'hf_model' you can save whole model as hf format, now only use sharded model checkpoint to save space
reward_model:
enable: False
strategy: fsdp2
model:
input_tokenizer: ${actor_rollout_ref.model.path} # set this to null if the chat template is identical
path: ~/models/FsfairX-LLaMA3-RM-v0.1
use_shm: False
external_lib: ${actor_rollout_ref.model.external_lib}
use_remove_padding: False
use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels}
trust_remote_code: False
fsdp_config:
wrap_policy:
min_num_params: 0
param_offload: False
reshard_after_forward: False # only for fsdp2, [True, False, int between 1 and fsdp_size]
fsdp_size: -1
micro_batch_size: null # will be deprecated, use micro_batch_size_per_gpu
micro_batch_size_per_gpu: null # set a number
max_length: null
ulysses_sequence_parallel_size: 1 # sp size
use_dynamic_bsz: ${critic.use_dynamic_bsz}
forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu}
reward_manager: naive
launch_reward_fn_async: False # custom reward function executed async on CPU, during log_prob
sandbox_fusion:
url: null # faas url to run code in cloud sandbox
max_concurrent: 64 # max concurrent requests to sandbox
custom_reward_function:
path: null
name: compute_score
algorithm:
gamma: 1.0
lam: 1.0
alpha: 1.0
adv_estimator: gae
norm_adv_by_std_in_grpo: True
use_kl_in_reward: False
kl_penalty: kl # how to estimate kl divergence
kl_ctrl:
type: fixed
kl_coef: 0.001
horizon: 10000
target_kl: 0.1
use_pf_ppo: False
pf_ppo:
reweight_method: pow # ["pow", "max_min", "max_random"]
weight_pow: 2.0
# RLLM Arguments
mask_truncated_samples: False # Zero gradient for truncated samples (by setting advantage=0)
clip_advantages: False
trainer:
balance_batch: True
total_epochs: 30
total_training_steps: null
project_name: verl_examples
experiment_name: gsm8k
logger: [ 'console', 'wandb' ]
log_debug: True
log_val_generations: 0
rollout_data_dir: null # directory for logging the rollout data, no dump if null
validation_data_dir: null # directory for logging the validation data, no dump if null
nnodes: 1
n_gpus_per_node: 8
save_freq: -1
# auto: find the last ckpt to resume. If can't find, start from scratch
resume_mode: auto # or disable or resume_path if resume_from_path is set
resume_from_path: null
val_before_train: True
test_freq: -1
critic_warmup: 0
default_hdfs_dir: null
del_local_ckpt_after_load: False
default_local_dir: /workspace/mnt/checkpoints/${trainer.project_name}/${trainer.experiment_name}
max_actor_ckpt_to_keep: null
max_critic_ckpt_to_keep: null
# The timeout for ray worker group to wait for the register center to be ready
ray_wait_register_center_timeout: 300
# RLLM arguments
rejection_sample: False # Reject sample prompts that all succeed or all fail (0 signal for GRPO due to normalization).
rejection_sample_multiplier: 2 # Multiple the training batch size by this factor to account for rejection sampling reduction.
n_training_gpus_per_node: 4 # For verl-pipeline.
ray_init:
num_cpus: null # `None` means using all CPUs, which might cause hang if limited in systems like SLURM. Please set to a number allowed then.
# RLLM Agent Config
env:
name: custom
env_args: {}
agent:
name: miniwobagent
max_steps: 20
async_engine: True
trajectory_timeout: null
overlong_filter: False
normalize_step_advantage: False
use_stepwise_advantage: False
stepwise_advantage_mode: "broadcast"
agent_args: {}
engine_args: {}
sh script:
set -x
export VLLM_ATTENTION_BACKEND=FLASH_ATTN
export PYTORCH_CUDA_ALLOC_CONF="expandable_segments:False"
export VLLM_USE_V1=1
export VLLM_ALLOW_LONG_MAX_MODEL_LEN=1
export VLLM_ENGINE_ITERATION_TIMEOUT_S=100000000000
# Find the directory where rllm package is located
RLLM_DIR=$(python3 -c "import rllm; import os; print(os.path.dirname(os.path.dirname(rllm.__file__)))")
python train_math_debug.py \
algorithm.adv_estimator=grpo \
data.train_batch_size=1024 \
data.val_batch_size=500 \
data.max_prompt_length=2048 \
data.max_response_length=8192 \
actor_rollout_ref.model.path=Qwen/Qwen2.5-1.5B-Instruct \
actor_rollout_ref.hybrid_engine=True \
actor_rollout_ref.actor.optim.lr=1e-6 \
actor_rollout_ref.model.use_remove_padding=True \
actor_rollout_ref.actor.loss_agg_mode=seq-mean-token-mean \
actor_rollout_ref.actor.ppo_mini_batch_size=256 \
+actor_rollout_ref.actor.ppo_micro_batch_size=4 \
actor_rollout_ref.actor.use_dynamic_mini_batch=True \
actor_rollout_ref.actor.ppo_num_mini_batches=1 \
actor_rollout_ref.actor.use_dynamic_bsz=True \
actor_rollout_ref.actor.ppo_max_token_len_per_gpu=8192 \
actor_rollout_ref.actor.use_kl_loss=False \
actor_rollout_ref.actor.clip_ratio_high=0.28 \
actor_rollout_ref.actor.kl_loss_coef=0.001 \
actor_rollout_ref.actor.kl_loss_type=low_var_kl \
actor_rollout_ref.actor.ulysses_sequence_parallel_size=1 \
actor_rollout_ref.actor.grad_norm_threshold=10 \
actor_rollout_ref.model.enable_gradient_checkpointing=True \
actor_rollout_ref.actor.fsdp_config.param_offload=False \
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \
actor_rollout_ref.rollout.tensor_model_parallel_size=1 \
actor_rollout_ref.rollout.name=vllm \
actor_rollout_ref.rollout.mode="async" \
actor_rollout_ref.rollout.chat_scheduler=verl.schedulers.completions_scheduler.CompletionsScheduler \
actor_rollout_ref.rollout.enforce_eager=False \
actor_rollout_ref.rollout.temperature=1.0 \
actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \
actor_rollout_ref.rollout.n=4 \
actor_rollout_ref.rollout.val_kwargs.n=1 \
actor_rollout_ref.rollout.val_kwargs.temperature=1.0 \
actor_rollout_ref.rollout.val_kwargs.top_p=0.95 \
actor_rollout_ref.ref.fsdp_config.param_offload=False \
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=4 \
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \
actor_rollout_ref.actor.entropy_coeff=0 \
+critic.ppo_micro_batch_size=4 \
algorithm.kl_ctrl.kl_coef=0.001 \
algorithm.mask_truncated_samples=False \
algorithm.clip_advantages=False \
trainer.critic_warmup=0 \
trainer.logger=['console','tensorboard'] \
trainer.project_name='dgpo' \
trainer.experiment_name='grpo_debug' \
trainer.val_before_train=True \
trainer.n_gpus_per_node=1 \
trainer.n_training_gpus_per_node=1 \
trainer.nnodes=1 \
trainer.save_freq=100 \
trainer.test_freq=20 \
trainer.default_hdfs_dir=null \
agent.max_steps=2 \
agent.async_engine=True \
agent.use_stepwise_advantage=False \
agent.stepwise_advantage_mode="broadcast" \
trainer.total_epochs=1
similar issue.
I am getting
raise AttributeError(
AttributeError: 'FSDPQwen2ForCausalLM' object has no attribute 'shard'
solve it #now? I get the same question AttributeError: 'FSDPQwen2ForCausalLM' object has no attribute 'shard'
similar issue AttributeError: 'FSDPLlamaForTokenClassification' object has no attribute '_handle'
for no attribute shard, should be resolved by https://github.com/volcengine/verl/pull/2941. update branch and error should be gone
定时清理检查结论:按社区 issue 定时处理规则关闭此 issue。
证据:最近一次非当前运行账号的公开回复或引用是 2025-08-13T14:49:03Z(actor: weifengpy, kind: comment),早于本轮 6 个月阈值 2026-01-13T01:10:17.218155+00:00。 检查来源:https://github.com/verl-project/verl/issues/2879,comments API https://api.github.com/repos/verl-project/verl/issues/2879/comments,timeline API https://api.github.com/repos/verl-project/verl/issues/2879/timeline。
如果作者或社区成员仍能提供新的复现、证据或需求背景,请在这里重新评论请求维护者重开,或创建新的 issue 并链接到本 issue。
Scheduled cleanup conclusion: this issue is being closed under the community issue processing policy.
Evidence: The latest public reply or reference from an account other than the current automation account was 2025-08-13T14:49:03Z (actor: weifengpy, kind: comment), which is older than the six-month threshold for this run (2026-01-13T01:10:17.218155+00:00). Sources checked: https://github.com/verl-project/verl/issues/2879, comments API https://api.github.com/repos/verl-project/verl/issues/2879/comments, timeline API https://api.github.com/repos/verl-project/verl/issues/2879/timeline.
If the author or community can still provide a fresh reproduction, evidence, or requirement context, please comment here to ask maintainers to reopen it, or open a new issue and link back to this one.
This response was generated by a scheduled Codex GPT5.5 issue processing task.