Skip to content
TheChatArchiveThe Chat Archive
xiaomi/mimo-v2.5-pro· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION OPD losses error for Megatron when i use megatron for compute losses…

  1. User

    ISSUE DESCRIPTION

    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

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /verl, current file: none) bash-$

  2. Assistant

    I'll start by exploring the repository structure to understand the codebase and locate the problematic file. Let's first check the overall structure.

  3. Assistant

    Let me look at the specific file mentioned in the issue.

  4. Assistant

    Let me find the correct path.

  5. Assistant

    The correct path is /verl/verl/trainer/distillation/megatron/losses.py. Let me open it.

  6. Assistant

    Let me see the full file to understand the issue better, particularly around line 248.

  7. Assistant

    Let me see the rest of the file.

  8. Assistant

    Let me see the rest of the file.

  9. Assistant

    Now let me look at the preprocess_bshd_engine function to understand what format it expects:

  10. Assistant

    Let me examine the preprocess_bshd_engine function to understand what input shape it expects.

  11. Assistant

    Let me search for preprocess_bshd_engine in this file.

  12. Assistant

    Let me examine the preprocess_bshd_engine function to understand what it expects and why it's failing with the shape [b, length, 64].

  13. Assistant

    Let me continue reading the function to understand the issue better.

  14. Assistant

    Now I understand the issue. The preprocess_bshd_engine function expects a nested tensor where each element is 1D (shape (seq_len,)), but teacher_topk_log_probs and teacher_topk_ids are 3D tensors with shape (bsz, seqlen, topk) where each nested element is 2D (seq_len, topk). The function creates output tensors of shape (batch_size, local_max_seqlen) and tries to assign 2D slices into them, which causes a shape mismatch.

    Let me search for all callers of preprocess_bshd_engine to understand the impact of any changes:

  15. Assistant

    Let me check what the input to preprocess_bshd_engine looks like in the model_forward.py:

  16. Assistant

    Let me look at preprocess_thd_engine to see how it handles the nested tensors:

  17. Assistant

    Let me look at preprocess_thd_engine to understand how it handles multi-dimensional nested tensors:

  18. Assistant

    Let me continue reading preprocess_thd_engine to see how it handles nested tensors with extra dimensions:

  19. Assistant

    Let me continue reading the function:

  20. Assistant

    Now I have a clear understanding of the issue. Let me read the full preprocess_bshd_engine function to implement the fix:

  21. Assistant

    Let me see the rest of the function:

  22. Assistant

    Now I have a clear understanding of the issue. The preprocess_bshd_engine function assumes the input nested tensor has 1D elements (shape (seq_len,)), but teacher_topk_log_probs and teacher_topk_ids have 2D elements (shape (seq_len, topk)). The function creates 2D output tensors (batch_size, local_max_seqlen) which can't accommodate the extra dimension.

    The fix is to make preprocess_bshd_engine handle multi-dimensional nested tensor elements, similar to how preprocess_thd_engine already does.

    Let me implement the fix:

  23. Assistant

    Let me verify the changes by scrolling through the modified section:

  24. Assistant

    Good, the changes look correct. Now let me verify that the changes are backward-compatible by checking the git diff:

  25. Assistant

    The diff looks clean and focused. Now let me create a test script to verify the fix works:

  26. Assistant

    The import chain is complex and requires many megatron dependencies. Let me try a different approach - directly test the logic:

  27. Assistant

    All tests pass. The fix correctly handles both1D and2D nested tensors. Let me also test with the exact scenario from the issue - a teacher_topk_log_probs with shape [b, length, 64]:

  28. Assistant

    Now let me check if there are existing tests in the repository:

  29. Assistant

    Let me check the relevant test files:

  30. Assistant

    Let me check the other test file and see if it tests anything related to preprocess_bshd_engine:

  31. Assistant

    Let me run the first test to see if it passes:

  32. Assistant

    All existing tests pass. Let me also test the need_roll path to make sure it works correctly with extra dimensions:

  33. Assistant

    All tests pass. Let me clean up the temporary test files:

  34. Assistant

    Let me verify the final state of the changes one more time:

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.