THUDM / THUDM/slime

[Question] How to add a custom auxiliary SFT loss to the GRPO training loop (Chord)?

Open
#1,843 0 comments 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

How to add a custom auxiliary SFT loss to the GRPO training loop?

I'm training DeepSeek-V3.2 on 128×H200 with GRPO and would like to mix in an SFT loss term during training, similar to CHORD (https://arxiv.org/abs/2508.11408):

$$\mathcal{L} = (1 - \mu) \cdot \mathcal{L}{\text{GRPO}} + \mu \cdot \mathcal{L}{\text{SFT}}$$

Could you point me to where in the codebase the GRPO loss is computed so I can add the SFT forward pass and combine the two losses?

Also, one question about MoE: routing replay forces the same expert routing from rollout during training, but SFT data has no corresponding rollout. Should I just skip routing replay for the SFT forward pass and use live routing?

Thanks!

What I've Tried

Verified CHORD on smaller models using ms-swift, but ms-swift only supports vLLM for GRPO rollout and lacks routing replay / off-policy sequence masking, so it doesn't work for DeepSeek-V3.2 at this scale.

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

No source file, test, or entry point is named in the issue. Start by locating the GRPO loss computation and routing-replay implementation, then determine how an SFT forward pass would interact with both; done would be a maintainer-confirmed design for combining the losses and handling SFT routing.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.