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 fix the two
expand_as(input_ids_bshd)calls, which break wheninput_ids_bshdis 3-D: - Assistant
Now let me verify the fix with a test. Check if megatron is available in this environment:
- Assistant
The package
__init__pulls in more megatron symbols. Loadutil.pydirectly instead: - Assistant
All pre-commit hooks pass. Here's the final diff:
- Assistant
Fixed. The bug and the fix:
Root cause
compute_forward_kl_topkinverl/trainer/distillation/megatron/losses.py:291passes teacher top-k nested tensors of shape(b, jagged_s, topk)intopreprocess_bshd_engine, but that function was written only for 1-D-per-sequence nested tensors like (). It allocated a strictly 2-D output buffer, so assigning a sequence into a row errored. The THD path never hit this because already preserves trailing dims ( at ) — which is why only the BSHD/ case failed.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.