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
No existing tests. Now I'll generalize
preprocess_bshd_engineto support nested tensors with trailing dims: - Assistant
Now let me check how
mpuis imported to write a verification test: - Assistant
Megatron isn't installed; I'll stub it to test the function in isolation:
- Assistant
All tests pass, including 2D regression and verification that the 3D zigzag CP split maps tokens identically to the 2D split. Now run the linter on the changed file:
- Assistant
Fixed. The bug was in
preprocess_bshd_engine(verl/models/mcore/util.py:564), which hardcoded a 2D(batch, seqlen)output buffer, so it crashed when the OPD loss atverl/trainer/distillation/megatron/losses.py:291passed 3D(bsz, seqlen, topk)teacher tensors. Note the THD path never had this issue —preprocess_thd_enginealready carries trailing dims viashape = list(input_ids.shape[1:]), which is why only the BSHD format errored.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.