OpenMOSS / OpenMOSS/MOSS-TTSD

[DDP] 并行训练问题/Multi-head shared-backbone model triggers “Expected to mark a variable ready only once” — how to parallelize training?

Open
#40 3 comments 1 reaction 1 assignee View on GitHub

@rulerman is already working on this.

Since Aug 6, 2025.

Dominant language
Python
Stars
1.4k
Forks
138
PR merge metrics
No merged PRs in 30d

Description

In multi-GPU DDP training, the model has a shared backbone (LLM) and multiple output heads (8 channels, each computing a different loss).
In a single forward pass, all heads use the same backbone parameters (e.g., down_proj.weight) to compute 8 separate losses, which are then weighted, summed into a single total_loss, and backpropagated once.

Single-GPU training works fine, but in multi-GPU DDP we get:

RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one. This error indicates that your module has parameters that were not used in producing loss

or

Parameter at index 314 with name model.language_model.layers.27.mlp.down_proj.weight has been marked as ready twice. This means that multiple autograd engine hooks have fired for this particular parameter during this iteration.

Tried:
• Disabled gradient_checkpointing
• find_unused_parameters=True/False
• model._set_static_graph() + static_graph=True
• Only one backward() call

Still fails. I suspect this is a known limitation in DDP when handling multi-output, multi-loss architectures with shared parameters.
Could the maintainers share the recommended way to handle this, and how do you parallelize training in similar architectures?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.