THUDM / THUDM/slime

[Question] motivation and recommended usage of --allgather-cp

Open
#1,716 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
8.5k
Forks
1.3k
Avg merge
5h 36m
Merged PRs (30d)
22

Description

Your Question

Hi, thanks for the project.

I’m trying to understand the motivation behind --allgather-cp, especially because I noticed that:

  • it appears to have been introduced together with GLM5 support
  • in the Megatron backend, it changes the CP data layout quite significantly

From reading the code, my current understanding is:

  • without --allgather-cp, CP uses the more traditional zigzag-style per-sample slicing
  • with --allgather-cp, the batch is first globally concatenated, then split into contiguous chunks across CP ranks
  • after forward, the response-aligned outputs are redistributed back into the zigzag-style view expected by downstream loss logic

What I’m still confused about is the tradeoff.

My intuition was that zigzag CP is useful because it balances computation for each sequence more evenly across ranks.
So I’m trying to understand why the “global concat + contiguous split” layout is preferable here.

Thanks.

What I've Tried

The relevant places I looked at are:

  • slime/backends/megatron_utils/data.py
  • slime/backends/megatron_utils/loss.py
  • slime_plugins/models/glm5/glm5.py
Environment (if relevant)
  • slime version:
  • Python version:
  • PyTorch version:
  • CUDA/ROCm version:
  • GPU type and count:
  • OS:
Additional Context

No response

Pre-submission Checklist

Contributor guide

Open the contributing guide

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.

Research direction

Read slime/backends/megatron_utils/data.py and loss.py alongside slime_plugins/models/glm5/glm5.py. Trace how --allgather-cp changes layout and output redistribution, then establish the rationale, tradeoffs, and recommended usage from the implementation. Done means providing a documented, evidence-based answer to the question.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
backend, distributed-systems, machine-learning
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.