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 trace the Megatron OPD loss preprocessing path, confirm the expected context-parallel tensor layout, then patch it and run focused tests.
- Assistant
The failure is confirmed at the BSHD branch: it passes a three-dimensional
[batch, sequence, top-k]tensor into a helper whose contract appears specialized for token tensors. I’m checking the helper’s exact reshaping and CP split semantics before choosing the minimal safe adaptation. - Assistant
The helper’s CP algorithm is already correct for arbitrary per-token payloads; only its padding/output allocation incorrectly drops trailing dimensions. I’ll extend those internal allocations to preserve dimensions such as
top-k, while keeping masks and position IDs two-dimensional, and add regression coverage for both CP splitting and padding. - Assistant
The implementation patch is in place. The local environment does not have Megatron installed, so the new test currently fails during collection rather than exercising the code; I’m adjusting the regression test to skip cleanly without that optional dependency, then I’ll validate the tensor logic independently and run available checks.
- Assistant
The regression test now skips cleanly when Megatron is unavailable, and syntax/diff checks have passed up to the formatting hook run. I’m waiting for the repository’s pre-commit checks to finish, then I’ll address any findings.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.