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 look at how
compute_forward_kl_topkis called and how the thd path handles the extratopkdimension, to make sure the fix matches: - Assistant
All pre-commit hooks pass. Here's the final diff:
- Assistant
Fixed. Summary of the change:
Root cause
compute_forward_kl_topkinverl/trainer/distillation/megatron/losses.py:291passesteacher_topk_log_probs/teacher_topk_ids— nested tensors of shape(b, seqlen, topk=64)— throughpreprocess_bshd_engine. Unlike its counterpartpreprocess_thd_engine(which preserves trailing dims viashape = list(input_ids.shape[1:])),preprocess_bshd_enginehardcoded 2D buffers , so assigning a slice into a 1D row errored.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.