verl icon indicating copy to clipboard operation
verl copied to clipboard

Bug: AttributeError: 'tuple' object has no attribute 'logits'

Open hljjjmssyh opened this issue 1 year ago • 9 comments

recipe/prime/prime_dp_rm.py", line 97, in _forward_micro_batch (main_task pid=14851) rm_output_logits = output.logits.squeeze(0) (main_task pid=14851) AttributeError: 'tuple' object has no attribute 'logits'

hljjjmssyh avatar Jul 15 '25 12:07 hljjjmssyh

https://github.com/volcengine/verl/blob/152c599303dd4364aa8d581d405a84922dc8c713/recipe/prime/prime_dp_rm.py#L89 May I ask why this is set to false? It seems this is causing the bug.

hljjjmssyh avatar Jul 16 '25 06:07 hljjjmssyh

@hljjjmssyh return_dict should always be True right? Could you help use a PR to fix this?

ETOgaosion avatar Jul 17 '25 06:07 ETOgaosion

@ETOgaosion I believe so, but I’m not sure why this parameter was introduced in the first place. According to the log history, earlier versions didn’t set it. When I tried removing the parameter, I ran into a different error, so I’m not certain whether the two issues are related.

(main_task pid=11700) File "verl/workers/actor/dp_actor.py", line 373, in update_policy (main_task pid=11700) data = data.select(batch_keys=select_keys, non_tensor_batch_keys=non_tensor_select_keys) (main_task pid=11700) File "verl/protocol.py", line 438, in select (main_task pid=11700) sub_batch = self.batch.select(*batch_keys) (main_task pid=11700) File "/usr/local/lib/python3.10/dist-packages/tensordict/base.py", line 9293, in select (main_task pid=11700) result = self._select(*keys, inplace=inplace, strict=strict) (main_task pid=11700) File "/usr/local/lib/python3.10/dist-packages/tensordict/_td.py", line 3052, in _select (main_task pid=11700) val = self._get_str(key, default=None if not strict else NO_DEFAULT) (main_task pid=11700) File "/usr/local/lib/python3.10/dist-packages/tensordict/_td.py", line 2464, in _get_str (main_task pid=11700) return self._default_get(first_key, default) (main_task pid=11700) File "/usr/local/lib/python3.10/dist-packages/tensordict/base.py", line 4995, in _default_get (main_task pid=11700) raise KeyError( (main_task pid=11700) KeyError: 'key "response_mask" not found in TensorDict with keys ['acc', 'advantages', 'attention_mask', 'input_ids', 'old_log_probs', 'position_ids', 'prompts', 'q', 'ref_log_prob', 'responses', 'returns', 'rm_scores']'

hljjjmssyh avatar Jul 17 '25 07:07 hljjjmssyh

Seems that compute_advantage should add response_mask to data batch

ETOgaosion avatar Jul 17 '25 09:07 ETOgaosion

Same error

liudan193 avatar Aug 21 '25 02:08 liudan193

Just add this line to prime_ray_trainer.py is work for me.

data.batch["response_mask"] = response_mask

def compute_advantage(data: DataProto, adv_estimator, config):
    if adv_estimator == "rloo":
        responses = data.batch["responses"]
        response_length = responses.size(-1)
        attention_mask = data.batch["attention_mask"]
        response_mask = attention_mask[:, -response_length:]
        advantages, returns = prime_core_algos.compute_rloo_advantage_return(
            data, response_mask, config.actor_rollout_ref.rollout.n, config
        )
        data.batch["advantages"] = advantages
        data.batch["returns"] = returns
        data.batch["response_mask"] = response_mask
    else:
        raise NotImplementedError
    return data

liudan193 avatar Aug 21 '25 09:08 liudan193

Just add this line to prime_ray_trainer.py is work for me.

data.batch["response_mask"] = response_mask

def compute_advantage(data: DataProto, adv_estimator, config): if adv_estimator == "rloo": responses = data.batch["responses"] response_length = responses.size(-1) attention_mask = data.batch["attention_mask"] response_mask = attention_mask[:, -response_length:] advantages, returns = prime_core_algos.compute_rloo_advantage_return( data, response_mask, config.actor_rollout_ref.rollout.n, config ) data.batch["advantages"] = advantages data.batch["returns"] = returns data.batch["response_mask"] = response_mask else: raise NotImplementedError return data

Did you set actor_rollout_ref.model.use_fused_kernels=True and then add the line data.batch["response_mask"] = response_mask? After I set actor_rollout_ref.model.use_fused_kernels=True, but get another error 'NotImplementedError: forward_with_torch_backend has to return_dict'.

Karina-ww avatar Aug 21 '25 11:08 Karina-ww

Just add this line to prime_ray_trainer.py is work for me. data.batch["response_mask"] = response_mask def compute_advantage(data: DataProto, adv_estimator, config): if adv_estimator == "rloo": responses = data.batch["responses"] response_length = responses.size(-1) attention_mask = data.batch["attention_mask"] response_mask = attention_mask[:, -response_length:] advantages, returns = prime_core_algos.compute_rloo_advantage_return( data, response_mask, config.actor_rollout_ref.rollout.n, config ) data.batch["advantages"] = advantages data.batch["returns"] = returns data.batch["response_mask"] = response_mask else: raise NotImplementedError return data

Did you set actor_rollout_ref.model.use_fused_kernels=True and then add the line data.batch["response_mask"] = response_mask? After I set actor_rollout_ref.model.use_fused_kernels=True, but get another error 'NotImplementedError: forward_with_torch_backend has to return_dict'.

I set actor_rollout_ref.model.use_fused_kernels=False. I also replace all return_dict=self.use_fused_kernels to return_dict=True.

liudan193 avatar Aug 21 '25 11:08 liudan193

中文

定时清理检查结论:这个 issue 最近一次非当前运行账号的公开回复或引用是 2025-11-27T00:51:22Z,截至本轮运行时间 2026-07-10T01:03:01Z 已经超过 6 个月。检查来源包括 issue comments API https://api.github.com/repos/verl-project/verl/issues/2547/comments 和 timeline API https://api.github.com/repos/verl-project/verl/issues/2547/timeline;最近证据:https://github.com/verl-project/verl/pull/4315。

因此按社区 issue 定时清理标准关闭。若作者或社区成员仍能提供当前版本的复现、日志、PR 关联或新的需求背景,欢迎继续评论请求重开,或创建一个带有最新证据的新 issue。

English

Scheduled cleanup check: the latest public reply or reference from an account other than the current automation account was 2025-11-27T00:51:22Z, which is more than 6 months before this run time 2026-07-10T01:03:01Z. The checked public sources were the issue comments API https://api.github.com/repos/verl-project/verl/issues/2547/comments and the timeline API https://api.github.com/repos/verl-project/verl/issues/2547/timeline; latest evidence: https://github.com/verl-project/verl/pull/4315.

Closing this under the scheduled issue cleanup policy. If the author or community can still provide a current reproduction, logs, PR reference, or updated requirement context, please comment to request reopening or open a new issue with fresh evidence.

This response was generated by a scheduled Codex GPT5.5 issue processing task.

Kirrito-k423 avatar Jul 10 '26 01:07 Kirrito-k423