hf rollout error
I use hf for rollout instead of vllm or sglang, but got error. Please refine the following code that handles sharding manager for hf rollout:
volcengine/verl/verl/workers/fsdp_workers.py
def _build_rollout(self, trust_remote_code=False):
from torch.distributed.device_mesh import init_device_mesh
# TODO(sgm): support FSDP hybrid shard for larger model
infer_tp = self.config.rollout.tensor_model_parallel_size
dp = self.world_size // infer_tp
assert self.world_size % infer_tp == 0, f"rollout world_size: {self.world_size} is not divisible by infer_tp: {infer_tp}"
rollout_device_mesh = init_device_mesh(device_name, mesh_shape=(dp, infer_tp), mesh_dim_names=["dp", "infer_tp"])
rollout_name = self.config.rollout.name
if rollout_name == "hf":
from verl.workers.rollout import HFRollout
from verl.workers.sharding_manager.base import BaseShardingManager
rollout = HFRollout(module=self.actor_module_fsdp, config=self.config.rollout)
rollout_sharding_manager = BaseShardingManager()
# TODO: a sharding manager that do nothing?
elif rollout_name == "vllm":
The complete command and error are as follows:
PYTHONUNBUFFERED=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=256 \
data.max_prompt_length=512 \
data.max_response_length=256 \
actor_rollout_ref.model.path=Qwen/Qwen2.5-0.5B-Instruct \
actor_rollout_ref.actor.optim.lr=1e-6 \
actor_rollout_ref.actor.ppo_mini_batch_size=64 \
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=1 \
actor_rollout_ref.rollout.name=hf \
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=1 \
actor_rollout_ref.rollout.tensor_model_parallel_size=1 \
actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=1 \
trainer.logger=['console'] \
trainer.val_before_train=False \
trainer.default_hdfs_dir=null \
trainer.n_gpus_per_node=2 \
trainer.nnodes=1 \
trainer.save_freq=10 \
trainer.test_freq=10 \
trainer.total_epochs=3 2>&1 | tee verl_demo.log
...
# Traceback (most recent call last):
...
# ray.get(runner.run.remote(config))
# File "/usr/local/lib/python3.11/dist-packages/ray/_private/auto_init_hook.py", line 21, in auto_init_wrapper
# return fn(*args, **kwargs)
# ^^^^^^^^^^^^^^^^^^^
# File "/usr/local/lib/python3.11/dist-packages/ray/_private/client_mode_hook.py", line 103, in wrapper
# return func(*args, **kwargs)
# ^^^^^^^^^^^^^^^^^^^^^
# File "/usr/local/lib/python3.11/dist-packages/ray/_private/worker.py", line 2822, in get
# values, debugger_breakpoint = worker.get_objects(object_refs, timeout=timeout)
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# File "/usr/local/lib/python3.11/dist-packages/ray/_private/worker.py", line 930, in get_objects
# raise value.as_instanceof_cause()
# ray.exceptions.RayTaskError(AttributeError): ray::TaskRunner.run() (pid=1154, ip=172.19.2.2, actor_id=99a201f8cb1192454b5a04a501000000, repr=<main_ppo.TaskRunner object at 0x796738b79e10>)
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
# gen_batch_output = self.actor_rollout_wg.generate_sequences(gen_batch)
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
# output = ray.get(output)
# ^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ray.exceptions.RayTaskError(AttributeError): ray::WorkerDict.actor_rollout_generate_sequences() (pid=1333, ip=172.19.2.2, actor_id=15ebe653a958a89fd92a7d1301000000, repr=<verl.single_controller.ray.base.WorkerDict object at 0x792db09bbcd0>)
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
....
# timing_generate.update(self.rollout_sharding_manager.timing)
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# AttributeError: 'BaseShardingManager' object has no attribute 'timing'
...
The documentation claims, vllm, TGI (hf) and sglang are supported, but in the code, only vllm and sgland are defined as valid options.
encountering the same issue.
中文:我重新核对了当前 main 和相关 PR。这个问题看起来还不能关闭为已修复:actor_rollout_ref.rollout.name=hf 仍在 rollout 配置注释中列为可选项,但当前 async rollout registry 只注册了 vllm、sglang、trtllm,没有注册 hf。此外,当前 HFRollout.__init__ 仍调用无参 super().__init__(),而 BaseRollout.__init__ 需要 config/model_config/device_mesh。上游 PR #1945 曾尝试处理 #1940 相关的 timing 异常,但该 PR 已关闭且未合并。另有 fork PR torad-labs/verl#2 提供了一个更完整的 HF rollout 修复方向,但它只合入 fork,并未进入 upstream。
English: I re-checked the current main branch and the related PRs. This issue does not look safe to close as fixed yet: actor_rollout_ref.rollout.name=hf is still documented in the rollout config comment, but the current async rollout registry only registers vllm, sglang, and trtllm, not hf. Also, current HFRollout.__init__ still calls super().__init__() without the config/model_config/device_mesh arguments required by BaseRollout.__init__. Upstream PR #1945 attempted to address the #1940 timing error, but it was closed without being merged. A fork PR, torad-labs/verl#2, describes a broader HF rollout fix, but it was only merged into the fork, not upstream.
Evidence:
- Issue error report: https://github.com/verl-project/verl/issues/1940#issuecomment-2958065443
- Rollout config lists hf: https://github.com/verl-project/verl/blob/6a4a0784337828523126ddd3d668524bd4578d4d/verl/trainer/config/rollout/rollout.yaml#L4-L8
- Registry omits hf: https://github.com/verl-project/verl/blob/6a4a0784337828523126ddd3d668524bd4578d4d/verl/workers/rollout/base.py#L83-L100
- HFRollout initializer: https://github.com/verl-project/verl/blob/6a4a0784337828523126ddd3d668524bd4578d4d/verl/workers/rollout/hf_rollout.py#L39-L45
- Upstream PR #1945 closed unmerged: https://github.com/verl-project/verl/pull/1945
- Fork PR with proposed HF rollout fix: https://github.com/torad-labs/verl/pull/2
This response was generated by a scheduled Codex GPT5.5 issue processing task.