Conversation
7d6b5a9 to
4bb5b80
Compare
|
@claude review |
|
Claude: Summary本次重构将训练数据构造按归属拆分:per-sample 全序列 token 字段( 核心原理实现与单测
其他 Issues未发现 |
…troller - AgentLoop.canonicalize_train_fields (base + localhost/sandbox overrides) builds the unified full-sequence train fields (input_ids/labels/logprobs) at generation time; semantic holes are baked into labels by the loops. - RolloutState drops response_mask; labels become the only supervision carrier. agent_loop_type records the producing loop class name and AGENTIC_AGENT_LOOP_TYPES discriminates agentic full-sequence samples. - TrainingController.fit accepts list[list[RolloutState]] and absorbs validation, session-clustered advantages, shift/tensorization, seq_ctx, teacher fields and data_info; BaseRLTrainer._prepare_train_data is gone. - calculate_group_effective_response_masks now bakes token staleness into labels in place (monotone, convergent) and its agentic exclusion uses agent_loop_type instead of the input_ids/labels presence heuristic.
…ut conversion - response_ids now denotes the contiguous suffix of input_ids after the prompt (env/tool tokens included) in every loop; localhost/sandbox export input_ids[len(prompt_ids):] so response_model_steps stay aligned with the full response region. - Token staleness baking becomes branch-free: effective mask = semantic mask (labels != -100 on the suffix) * per-token staleness mask; the zero-prompt suffix state becomes eligible and agent_loop_type plus AGENTIC_AGENT_LOOP_TYPES are removed. - data_info stats: prompt_len reports the original prompt length and response_len the supervised (LLM-generated) token count; env/tool injected tokens count in neither. - _rollout_groups_to_colate_items is phase-split into session reward clustering, group advantage estimation, per-state ColateItem conversion and data_info summarization.
7c29de9 to
066bd24
Compare
|
Following work: #2055 |
| continue | ||
| for group in batch_by_task.get(task.task_name, []): | ||
| effective_masks = calculate_group_effective_response_masks( | ||
| calculate_group_effective_response_masks( |
There was a problem hiding this comment.
已修复,改为返回 effective_masks 并且显式赋值
| ) | ||
| rollout_state.response_ids = final_response_ids | ||
| rollout_state.response_mask = final_response_mask | ||
| rollout_state.logprobs = final_logprobs |
There was a problem hiding this comment.
这里没有对logprobs进行拼接,但后面要求assert相等了
| rollout_state.logprobs = final_logprobs | |
| rollout_state.logprobs = [0.0] * len(prompt_ids) + final_logprobs |
| semantic_mask = output.response_mask if output.response_mask is not None else [1] * len(response_ids) | ||
| rollout_state.prompt_ids = prompt_ids | ||
| rollout_state.response_ids = response_ids | ||
| rollout_state.logprobs = output.response_logprobs |
| # Unified response_ids convention: the contiguous suffix of input_ids after the prompt | ||
| # (env-injected tokens included), aligned with response_model_steps for per-token | ||
| # staleness; also the token count used by rollout throughput logging. | ||
| prompt_len = len(rollout_state.prompt_ids or []) |
There was a problem hiding this comment.
这里用prompt_ids这个字段切分在多轮的时候会有问题吗
There was a problem hiding this comment.
文本多轮应该也没问题,多轮的赋值过程如下:
第一轮:token = prompt_id
第二轮:token = token + response_ids
...
所以不会修改原始的prompt_id
另外多模的输入这里会有问题,我增加了显式的判断agent_in_localhost_loop不支持多模输入的判断
fbf2b05 to
d92d059
Compare
…ing, multimodal assert
Summary
Training data construction is split by ownership: per-sample token fields are now built at generation time inside
AgentLoop, while step-level conversion (validation, advantage, shift, tensorization, seq_ctx/teacher fields,data_info) moves intoTrainingController.BaseRLTrainer._prepare_train_datais deleted.AgentLoop.canonicalize_train_fields(base + localhost/sandbox overrides) builds the unified full-sequenceinput_ids/labels/logprobsconvention; semantic holes (tool/env tokens) are baked intolabelsas-100by the loops themselves.RolloutStatedropsresponse_mask;labelsbecomes the only supervision carrier. Newagent_loop_typerecords the producing loop class name (type(self).__name__), andAGENTIC_AGENT_LOOP_TYPESdiscriminates agentic full-sequence samples (None/unregistered types fall back to prompt+response semantics).TrainingController.fitacceptslist[list[RolloutState]]and absorbs group validation, session-clustered advantages, the one-position shift, tensorization, seq_ctx/teacher fields anddata_infostatistics.calculate_group_effective_response_masksnow bakes token staleness intolabelsin place (clearing is monotone, so replay-buffer expiry checks and the train-batch bake converge to identical labels); the agentic exclusion condition now keys onagent_loop_typeinstead ofinput_ids/labelspresence, which would have silently disabled token staleness after canonicalization.Behavior changes
FAILEDat generation time (their group is skipped) instead of asserting at training time.task_adv_weight == 0trains with zero advantage; with weight > 0 it still raises (crash semantics preserved, location moved).prepare_datatiming key disappears; conversion cost is now inside thetrainingtimer.prompt_len/response_lenstats keep exact denominators for reasoning samples; only mixed-form edge cases may drift by +/-1 (log metrics only).ProduceBatchResult impact:
leftover_*/raw_rewards*/produced_*counts unchanged; generation-time canonicalize failures can flip individual samples toFAILED, which converts to group-level skips via validation (affectsrollout_statescontent, not the accounting).RoutedExperts impact: not affected;
routed_expertsis still attached toseq_ctxby the controller, ownership and release paths unchanged.Ray concurrency impact: not affected; no agent-loop actor methods, decorators, or concurrency groups changed.
Test plan
tests/rl/test_prepare_train_data.pyrewritten as contract tests forcanonicalize_train_fields(base + both agentic overrides) andTrainingController._convert_rollout_groups, including the packed-alignment regression (advantage used to be one position longer than input_ids).reset_rollout_responseclears canonical train fields, canonicalized prompt+response states remain staleness-eligible.pytest tests/rl).