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
I'll inspect the Megatron OPD loss path and how
preprocess_bshd_engineexpects its inputs. - Assistant
Extending
preprocess_bshd_engineto handle trailing dimensions likepreprocess_thd_engine, since teacher top-k tensors are[length, topk]per batch item. - Assistant
I'll add a unit test and run it to confirm the fix.
- Assistant
The failure comes from a shape mismatch in
preprocess_bshd_engine: OPD teacher top-k tensors are nested[batch, length, topk], but the function only handled[batch, length].Root cause
In
compute_forward_kl_topk(Megatron), teacher top-k tensors go throughpreprocess_bshd_enginefor BSHD format:teacher_topk_log_probs_cp_split, *_ = preprocess_bshd_engine(teacher_topk_log_probs, pre_process=True) teacher_topk_ids_cp_split, *_ = preprocess_bshd_engine(teacher_topk_ids, pre_process=True)Each nested sequence is
[length, 64], butpreprocess_bshd_enginebuilt a 2D output[batch, local_max_seqlen]and assigned 2D sequences into 1D slots — hence the error.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.