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 layout against nearby loss implementations, then patch it and run focused tests.
- Assistant
rgisn’t installed in this checkout, so I’m switching tofind/grepand continuing the same inspection. - Assistant
The failure is confirmed:
preprocess_bshd_enginepreserves only batch/sequence storage and assumes scalar tokens when allocating and assigning, while OPD supplies jagged tensors with a trailing top-k dimension. I’m checking its existing test coverage before making the preprocessing shape-generic without changing its call signature. - Assistant
The implementation now preserves all trailing feature dimensions through padding and zigzag context-parallel slicing, while keeping attention masks and position IDs two-dimensional. I’ve added a distributed regression case that exercises the OPD BSHD loss path with
[batch, sequence, topk]teacher tensors. - Assistant
Static validation passes. The repository’s Megatron test cannot collect in this environment because
megatron.coreis not installed, so I’m running the preprocessing regression directly with a minimal local Megatron module stub, including both non-CP and zigzag-CP layouts. - Assistant
The direct regression passes for
[B, S, K]tensors in both ordinary and zigzag context-parallel cases. I’m finishing the repository’s targeted formatting/lint hooks now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.