Prhub

#7106 [megatron] fix: preserve R2 router replay for THD-packed batches

原始 PR 作者 hbhflw2000 合并时间 2026-09-07 19:51 文件变更 6 提交数 8 评论 15 代码增减 +448 / -38

执行摘要

实现拆解

  1. 核心源码路径
    - verl/utils/megatron_utils.py(core-logic):源码主路径;涉及符号 _iter_hf_config_tree, get_hf_config_attr, _maybe_get_theta;包含 控制流调整、配置键调整、异常路径调整;+49/-21;关键符号:_iter_hf_config_tree, get_hf_config_attr, _maybe_get_theta
    - verl/utils/megatron/router_replay_utils.py(entrypoint):源码主路径;包含 控制流调整、配置键调整、异常路径调整;+66/-14
    - verl/workers/engine/megatron/transformer_impl.py(core-logic):源码主路径;包含 控制流调整、配置键调整、异常路径调整;+19/-3

  2. 测试与验证
    - tests/workers/engine/megatron/test_router_replay_utils_on_cpu.py(test-coverage):测试配套;涉及符号 _FakeRouter, init, set_target_indices, _restore_router_registry;包含 测试覆盖调整、导入关系调整、控制流调整;+242/-0;关键符号:_FakeRouter, init, set_target_indices, _restore_router_registry
    - tests/utils/test_megatron_utils_nested_config.py(test-coverage):测试配套;涉及符号 test_get_hf_rope_theta_from_nested_omni_text_config, test_get_hf_rope_theta_from_nested_transformers_v5_parameters, test_get_hf_config_attr_handles_nested_configs_and_cycles, test_nested_config_lookup_rejects_missing_attributes;包含 测试覆盖调整、导入关系调整、控制流调整;+54/-0;关键符号:test_get_hf_rope_theta_from_nested_omni_text_config, test_get_hf_rope_theta_from_nested_transformers_v5_parameters, test_get_hf_config_attr_handles_nested_configs_and_cycles, test_nested_config_lookup_rejects_missing_attributes
    - tests/utils/test_megatron_bshd_preprocess.py(test-coverage):测试配套;涉及符号 test_thd_router_replay_drops_record_padding_and_restores_expert_zero;包含 测试覆盖调整、配置键调整、符号定义调整;+18/-0;关键符号:test_thd_router_replay_drops_record_padding_and_restores_expert_zero

文件 模块 状态 重要度
tests/workers/engine/megatron/test_router_replay_utils_on_cpu.py router/replay/utils/on/cpu added 8.41
verl/utils/megatron_utils.py verl/utils modified 8.05
verl/utils/megatron/router_replay_utils.py verl/utils modified 7.46
tests/utils/test_megatron_utils_nested_config.py megatron/utils/nested/config added 7.4
verl/workers/engine/megatron/transformer_impl.py verl/workers modified 6.81

关键符号

_FakeRouter __init__ set_target_indices _restore_router_registry _config test_get_micro_batch_router_list_uses_pp_layer_offset test_get_micro_batch_router_list_supports_local_only_registry test_get_micro_batch_router_list_supports_local_only_vpp_registry _iter_hf_config_tree get_hf_config_attr

分析完成后,这里会展示 LLM 生成的相对完整源码片段和详细注释。

评论区精华

没有提炼出高价值讨论线程

当前评论区没有形成足够清晰的争议点或结论,后续有更多讨论时会体现在这里。

风险与影响

关联 Issue

#290 example: fix remove padding flags for gemma example. update v0.2 install docs

完整报告

参与讨论