OPD losses error for Megatron when i use megatron for compute losses the code position…
- User
OPD losses error for Megatron when i use megatron for compute losses the code position is: /verl/trainer/distillation/megatron/losses.py Line 248 teacher_topk_log_probs_cp_split, *_ = preprocess_bshd_engine(teacher_topk_log_probs, pre_process=True)
the teacher_topk_log_probs is [b, length, 64] but preprocess_bshd_engine this function need [n, length] dim, so error happens
Interface
No new interfaces are introduced.
- Assistant
Now let me check the imports at the top of util.py and verify the change with a quick test using mocked mpu:
- Assistant
Megatron isn't installed here, so I'll test with a stub
megatronmodule to exercise the pure-tensor logic: - Assistant
The verl package
__init__chain pulls in more megatron internals. I'll loadutil.pydirectly as a standalone module instead: - Assistant
All hooks pass (the earlier non-zero exit was just the first-time hook environment installation). Here's the final diff:
- Assistant
Fixed. Summary of the change:
Root cause
compute_forward_kl_topkinverl/trainer/distillation/megatron/losses.py:291passes nested teacher tensors of shape(b, seqlen_j, topk)topreprocess_bshd_engine, but that function hard-coded 2-D output buffers(batch_size, local_max_seqlen). The THD counterpartpreprocess_thd_enginealready supports trailing dims (verl/models/mcore/util.py:378builds the output shape from ), so only the BSHD path errored.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.