Paper notes

GSPO: Moving Importance Ratios and Clipping From Tokens to Whole Responses

GSPO (Group Sequence Policy Optimization), from the Qwen team in 2025, replaces GRPO's per-token importance ratios and clipping with one length-normalized ratio per response, and reportedly needs no Routing Replay for MoE models. This post reviews it and verifies its gradients in code.

Published Updated 19 min read

On this page
  1. Why This Paper Is Worth Reading
  2. Background: PPO and GRPO
  3. The Paper’s Argument: What Is Wrong With Per-Token Ratios
  4. GSPO: From Token Ratios to a Response Ratio
  5. What Differs in the Gradient
  6. GSPO-token: When You Need Token-Level Advantages
  7. Hands-On: Gradient Formulas, Weight Ranges After Clipping, and Ratio Spread Against Length
  8. All the Gradient Formulas Hold
  9. Token Weights of GRPO After Clipping
  10. How the Spread of the Ratios Changes With Length
  11. What This Check Shows and What It Does Not
  12. Experiments and Conclusions in the Paper
  13. Limitations and What Came Next
  14. What to Take Away From This Paper
  15. Further Reading
  16. FAQ

Group Sequence Policy Optimization (Zheng et al., Qwen Team, Alibaba) changes the unit of GRPO. GRPO computes an importance ratio for every token of a response and clips it token by token; GSPO computes one ratio for the whole response (the ratio of the new and old sequence likelihoods, raised to the power 1/length) and clips the whole response, so the unit of the correction matches the unit of the reward. The paper reports more stable and more efficient training, reinforcement learning of Mixture of Experts (MoE) models without Routing Replay, and says these benefits contributed to the latest Qwen3 models.

The paper appeared on arXiv on July 24, 2025 (v1) and this post follows v2 (July 28). It is 7 pages long, has no tables, and every experimental result is a training curve; the headline claims need a 30B MoE to be trained, which I cannot reproduce. This post does the part that can be verified mathematically: it checks the paper’s gradient formulas with automatic differentiation, checks the range of GRPO’s token weights after clipping, and uses a toy policy to see how the ratios’ spread changes with response length. The result: all formulas hold (the largest difference from autograd is at the 1e-17 level); GRPO’s token weights do fall in the ranges the paper states; and under independent numerical noise the per-token ratio’s spread does not depend on length, the unnormalized sequence ratio’s spread grows with the square root of the length, and length normalization makes it shrink with the inverse square root.

Why This Paper Is Worth Reading

  • It questions a design GRPO takes for granted. Importance sampling needs many samples from the same distribution to correct a mismatch, while GRPO’s per-token ratio has a single sample at each position; the paper argues that such a weight cannot correct anything and only adds noise.
  • It states a simple principle: the unit of optimization should match the unit of reward. The reward goes to a whole response, so the off-policy correction should be made on the whole response.
  • The change is small. In the objective the token ratio wi,tw_{i,t} is replaced by the response ratio sis_i; group-normalized advantages, PPO-style clipping and the absence of a value model all stay, so it is easy to read and easy to add to an existing GRPO codebase.
  • It ties to a concrete engineering problem. In reinforcement learning of MoE models, fluctuating expert activations invalidate token-level ratios; Routing Replay fixes that at a cost, and the paper offers another route.
  • It is short, which makes it good practice in judging claims against evidence. There are only curves, no tables, seed-to-seed variation or ablations, so it is worth sorting out for yourself which conclusions have evidence and which are narrative.

Background: PPO and GRPO

PPO updates the current policy πθ\pi_\theta with samples from the old policy πθold\pi_{\theta_{\text{old}}} and uses clipping to keep the update near the old policy. For a response yy the objective is (Equation 1 of the paper, KL term omitted):

JPPO(θ)=E[1∣y∣∑t=1∣y∣min⁡(wt(θ)A^t, clip(wt(θ),1−ε,1+ε)A^t)],wt(θ)=πθ(yt∣x,y<t)πθold(yt∣x,y<t)J_{\text{PPO}}(\theta)=\mathbb E\Big[\frac{1}{|y|}\sum_{t=1}^{|y|}\min\big(w_t(\theta)\hat A_t,\ \mathrm{clip}(w_t(\theta),1-\varepsilon,1+\varepsilon)\hat A_t\big)\Big],\qquad w_t(\theta)=\frac{\pi_\theta(y_t\mid x,y_{<t})}{\pi_{\theta_{\text{old}}}(y_t\mid x,y_{<t})}

Here the advantage A^t\hat A_t comes from a value model that is usually as large as the policy, a burden in memory and compute and harder to train reliably for longer responses and harder tasks. GRPO (see the DeepSeekMath explainer) drops the value model: for each question xx it samples a group of GG responses and uses the relative reward inside the group as the advantage (Equations 2 and 3):

JGRPO(θ)=E[1G∑i=1G1∣yi∣∑t=1∣yi∣min⁡(wi,t(θ)A^i, clip(wi,t(θ),1−ε,1+ε)A^i)],A^i=r(x,yi)−mean{r(x,yj)}j=1Gstd{r(x,yj)}j=1G\begin{aligned} J_{\text{GRPO}}(\theta)&=\mathbb E\Big[\frac{1}{G}\sum_{i=1}^{G}\frac{1}{|y_i|}\sum_{t=1}^{|y_i|}\min\big(w_{i,t}(\theta)\hat A_i,\ \mathrm{clip}(w_{i,t}(\theta),1-\varepsilon,1+\varepsilon)\hat A_i\big)\Big], \\ \hat A_i&=\frac{r(x,y_i)-\mathrm{mean}\{r(x,y_j)\}_{j=1}^{G}}{\mathrm{std}\{r(x,y_j)\}_{j=1}^{G}} \end{aligned}

All tokens of a response share the same advantage A^i\hat A_i, while each token has its own ratio wi,tw_{i,t}.

The Paper’s Argument: What Is Wrong With Per-Token Ratios

Section 3 of the paper argues in three steps.

  1. Training is off-policy by construction. To keep hardware busy, a large batch of rollouts is split into several mini-batches for gradient updates, so later updates use samples from an older policy; importance ratios and clipping are there to limit samples that are too far from the current policy.
  2. Importance sampling relies on many samples from the behavior distribution. It rewrites an expectation under the target distribution as one under the behavior distribution (Equation 4):
Ez∼πtar[f(z)]=Ez∼πbeh[πtar(z)πbeh(z)f(z)]\mathbb E_{z\sim\pi_{\text{tar}}}[f(z)]=\mathbb E_{z\sim\pi_{\text{beh}}}\Big[\frac{\pi_{\text{tar}}(z)}{\pi_{\text{beh}}(z)}f(z)\Big]

and the weight only corrects the mismatch when averaged over many samples (N≫1N\gg 1). GRPO’s weight at position tt rests on a single token drawn from πθold(⋅∣x,yi,<t)\pi_{\theta_{\text{old}}}(\cdot\mid x,y_{i,<t}), so it cannot play the correcting role and only adds high-variance noise to the gradient. 3. The noise accumulates with length and is amplified by clipping. The paper says it observed this leading to model collapse that is often irreversible: after a collapse, reverting to an earlier checkpoint, tuning the clipping ranges, lengthening generation or switching the query set did not help. The paper gives no curve or statistics for this phenomenon, only a description in words.

The principle that follows: the unit of the optimization objective should match the unit of the reward. The reward is given to a whole response, so the off-policy correction should be made on the whole response.

GSPO: From Token Ratios to a Response Ratio

The GSPO objective (Equations 5 to 7):

JGSPO(θ)=E[1G∑i=1Gmin⁡(si(θ)A^i, clip(si(θ),1−ε,1+ε)A^i)],si(θ)=(πθ(yi∣x)πθold(yi∣x))1/∣yi∣=exp⁡(1∣yi∣∑t=1∣yi∣log⁡πθ(yi,t∣x,yi,<t)πθold(yi,t∣x,yi,<t))\begin{aligned} J_{\text{GSPO}}(\theta)&=\mathbb E\Big[\frac{1}{G}\sum_{i=1}^{G}\min\big(s_i(\theta)\hat A_i,\ \mathrm{clip}(s_i(\theta),1-\varepsilon,1+\varepsilon)\hat A_i\big)\Big], \\ s_i(\theta)&=\Big(\frac{\pi_\theta(y_i\mid x)}{\pi_{\theta_{\text{old}}}(y_i\mid x)}\Big)^{1/|y_i|}=\exp\Big(\frac{1}{|y_i|}\sum_{t=1}^{|y_i|}\log\frac{\pi_\theta(y_{i,t}\mid x,y_{i,<t})}{\pi_{\theta_{\text{old}}}(y_{i,t}\mid x,y_{i,<t})}\Big) \end{aligned}

The advantage A^i\hat A_i is computed as in GRPO, and sis_i is the mean of the log ratios of all the tokens in the response, exponentiated. The paper says the sequence-level importance weight πθ(y∣x)/πθold(y∣x)\pi_\theta(y\mid x)/\pi_{\theta_{\text{old}}}(y\mid x) has a clear meaning, how far a response sampled from the old policy has drifted from the current one, which aligns naturally with a response-level reward and makes a sensible basis for clipping; sis_i is its length-normalized version.

Why the power 1/∣yi∣1/|y_i|. The paper gives two reasons: it reduces variance and keeps sis_i within a unified numerical range, and without it the likelihood change of a few tokens could make the sequence ratio fluctuate dramatically, while responses of different lengths would need different clipping ranges. It also notes that the clipping ranges of GSPO and GRPO typically differ in order of magnitude because the ratios are defined differently.

ItemGRPOGSPO
Importance ratioone per token: wi,tw_{i,t}one per response: sis_i
What is clippeda single tokenthe whole response
Advantagegroup-normalized, shared by the responsesame
Token weight in the gradientdifferent for each token: wi,tw_{i,t}the same within a response: sis_i
Clipping range in the paper0.2 and 0.27 (left, right)3e-4 and 4e-4 (left, right)

What Differs in the Gradient

Leaving clipping out, the paper derives the two gradients (Equations 10 and 12):

∇θJGSPO=E[1G∑i=1GsiA^i⋅1∣yi∣∑t=1∣yi∣∇θlog⁡πθ(yi,t∣x,yi,<t)]\nabla_\theta J_{\text{GSPO}}=\mathbb E\Big[\frac{1}{G}\sum_{i=1}^{G}s_i\hat A_i\cdot\frac{1}{|y_i|}\sum_{t=1}^{|y_i|}\nabla_\theta\log\pi_\theta(y_{i,t}\mid x,y_{i,<t})\Big] ∇θJGRPO=E[1G∑i=1GA^i⋅1∣yi∣∑t=1∣yi∣wi,t∇θlog⁡πθ(yi,t∣x,yi,<t)]\nabla_\theta J_{\text{GRPO}}=\mathbb E\Big[\frac{1}{G}\sum_{i=1}^{G}\hat A_i\cdot\frac{1}{|y_i|}\sum_{t=1}^{|y_i|}w_{i,t}\nabla_\theta\log\pi_\theta(y_{i,t}\mid x,y_{i,<t})\Big]

The two differ by one weight: GRPO multiplies each token’s ∇log⁡π\nabla\log\pi by its own wi,tw_{i,t}, GSPO multiplies all tokens of a response by the same sis_i. The paper adds that after clipping, GRPO’s token weights wi,tw_{i,t} lie in (0,1+ε](0,1+\varepsilon] when A^i>0\hat A_i>0 and in [1−ε,+∞)[1-\varepsilon,+\infty) when A^i<0\hat A_i<0; these weights are not negligible and their effect accumulates over training. The code below checks both the formulas and the ranges.

GSPO-token: When You Need Token-Level Advantages

Multi-turn reinforcement learning and similar settings may want to adjust advantages per token. The paper gives a variant, GSPO-token (Equations 13 and 14), which writes the token ratio as si,t(θ)=sg[si(θ)]⋅πθ(yi,t∣⋅)/sg[πθ(yi,t∣⋅)]s_{i,t}(\theta)=\mathrm{sg}[s_i(\theta)]\cdot\pi_\theta(y_{i,t}\mid\cdot)/\mathrm{sg}[\pi_\theta(y_{i,t}\mid\cdot)], where sg[⋅]\mathrm{sg}[\cdot] takes the value but stops the gradient (detach in PyTorch). Its value equals sis_i and its gradient is sis_i times each token’s own advantage times ∇log⁡π\nabla\log\pi; when all tokens of a response have the same advantage, it coincides with GSPO in objective, clipping condition and theoretical gradient.

Hands-On: Gradient Formulas, Weight Ranges After Clipping, and Ratio Spread Against Length

The paper’s headline result is a set of training curves that I cannot reproduce, but its mathematical part can be checked. The script has three parts, in the same order as the output:

  1. On a toy policy, check the paper’s Equations 9, 10, 12 and 17 against real gradients from automatic differentiation, and see how differently GRPO and GSPO weight the tokens of the same responses. The toy policy is a 9×8 table of logits: the vocabulary has 8 tokens, and each token’s distribution depends only on the previous token (row 9 is the start symbol). The old policy is a random table, the current policy is the old one plus random perturbations with standard deviation 0.3; the 6 responses have lengths from 3 to 10, and the rewards are 0 and 1 that I picked by hand.
  2. For the token-level clipped objective (ε=0.2\varepsilon=0.2), read each token’s weight in the gradient by automatic differentiation and check the ranges the paper states.
  3. Assume independent numerical noise on every logit between the training engine and the inference engine (standard deviation 0.01, an illustrative value), and measure how the spread of three ratios changes with response length: the per-token ratio, the unnormalized sequence ratio (exponential of the sum of log ratios), and the length-normalized sequence ratio (GSPO’s sis_i).

Environment: CPU (Apple M2 Max), Python 3.14.3, PyTorch 2.10.0, float64 throughout, fixed random seeds, under 2 seconds for the whole script. In another environment the random quantities in part 3 will differ slightly.

import torch

torch.set_default_dtype(torch.float64)
torch.manual_seed(0)
V = 8  # vocabulary size; state V stands for the start symbol


def logps(table, ys):
    """Bigram policy: a token's log-probability depends only on the
    previous token. ys has shape (n, L)."""
    n, L = ys.shape
    prev = torch.cat([torch.full((n, 1), V), ys[:, :-1]], 1)
    lp = torch.log_softmax(table[prev], -1)
    return lp.gather(-1, ys.unsqueeze(-1)).squeeze(-1)


def sample(table, n, L):
    prev, out = torch.full((n,), V), []
    for _ in range(L):
        prev = torch.multinomial(torch.softmax(table[prev], -1), 1)[:, 0]
        out.append(prev)
    return torch.stack(out, 1)


# ---------- Part 1: check the paper's gradient formulas ----------
G, lens = 6, [3, 5, 8, 4, 10, 6]
old_table = torch.randn(V + 1, V)
ys = [y[:n] for y, n in zip(sample(old_table, G, max(lens)), lens)]
theta = (old_table + 0.3 * torch.randn(V + 1, V)).requires_grad_()
r = torch.tensor([1., 0., 0., 0., 1., 0.])
A = (r - r.mean()) / r.std(unbiased=False)  # group-normalized advantage, Eq (6)
old = [logps(old_table, y[None])[0] for y in ys]
new = [logps(theta, y[None])[0] for y in ys]
w = [(a - b).exp() for a, b in zip(new, old)]  # token-level ratios w_it
s = torch.stack([(a - b).mean().exp() for a, b in zip(new, old)])  # Eq (7)

J_grpo = sum(A[i] * w[i].mean() for i in range(G)) / G  # Eq (2), no clipping
J_gspo = (s * A).mean()  # Eq (5), no clipping
g_grpo = torch.autograd.grad(J_grpo, theta, retain_graph=True)[0]
g_gspo = torch.autograd.grad(J_gspo, theta, retain_graph=True)[0]
# per-token grad log pi, combined by hand as in Eqs (12) and (10)
tg = [[torch.autograd.grad(new[i][t], theta, retain_graph=True)[0]
       for t in range(lens[i])] for i in range(G)]
m_grpo = sum(A[i] * sum(w[i][t].detach() * g for t, g in enumerate(tg[i]))
             / lens[i] for i in range(G)) / G
m_gspo = sum(s[i].detach() * A[i] * sum(tg[i]) / lens[i]
             for i in range(G)) / G
# Eq (9): s_i A_i grad log s_i
m_log = sum(s[i].detach() * A[i] * torch.autograd.grad(
    (new[i] - old[i]).mean(), theta, retain_graph=True)[0]
    for i in range(G)) / G
# Eqs (13)(14): GSPO-token, each token may have its own advantage
At = [A[i] + 0.5 * torch.randn(lens[i]) for i in range(G)]
J_tok = sum((s[i].detach() * (new[i] - new[i].detach()).exp() * At[i]).mean()
            for i in range(G)) / G
g_tok = torch.autograd.grad(J_tok, theta, retain_graph=True)[0]
m_tok = sum(s[i].detach() * sum(At[i][t] * g for t, g in enumerate(tg[i]))
            / lens[i] for i in range(G)) / G
J_same = sum((s[i].detach() * (new[i] - new[i].detach()).exp() * A[i]).mean()
             for i in range(G)) / G
g_same = torch.autograd.grad(J_same, theta)[0]


def diff(a, b):
    return f"{(a - b).abs().max().item():.1e}"


print(f"{G} responses, lengths {lens}, advantages "
      + " ".join(f"{a:+.2f}" for a in A.tolist()))
print("max |autograd - formula| over the", theta.numel(), "parameters:")
print("  GRPO  vs eq (12):               ", diff(g_grpo, m_grpo))
print("  GSPO  vs eq (10):               ", diff(g_gspo, m_gspo))
print("  GSPO  vs eq (9), s_i A_i grad log s_i:", diff(g_gspo, m_log))
print("  GSPO-token vs eq (17):          ", diff(g_tok, m_tok))
print("  GSPO-token, equal A vs GSPO:    ", diff(g_same, g_gspo))
print(f"  gradient norms: GRPO {g_grpo.norm():.4f}, GSPO {g_gspo.norm():.4f}"
      f", difference {(g_grpo - g_gspo).norm():.4f}")
print("gradient weight on grad log pi, response 0 (A = %+.2f):" % A[0])
print("  GRPO  A*w/|y|:", " ".join(f"{A[0] * x / lens[0]:+.3f}"
                                  for x in w[0].tolist()))
print("  GSPO  A*s/|y|:", " ".join(f"{A[0] * s[0] / lens[0]:+.3f}"
                                  for _ in range(lens[0])))

# ---------- Part 2: GRPO token weights after clipping ----------
eps, n = 0.2, 200000
lw = (0.4 * torch.randn(n)).requires_grad_()  # token log ratios, illustrative
sign = torch.where(torch.rand(n) < 0.5, 1.0, -1.0)  # sign of the advantage
x = lw.exp()
obj = torch.minimum(x * sign, x.clamp(1 - eps, 1 + eps) * sign)
coef = torch.autograd.grad(obj.sum(), lw)[0] * sign  # weight of each token
x = x.detach()
for name, m in (("A > 0", sign > 0), ("A < 0", sign < 0)):
    c = coef[m]
    nz = c[c != 0]
    zero = (c == 0).double().mean()
    print(f"{name}: share of zero-gradient tokens {zero:.3f}, "
          f"weight min {nz.min():.3f} max {nz.max():.3f}")
print(f"eps = {eps}: bounds from the paper are (0, {1 + eps}] for A > 0 and"
      f" [{1 - eps}, inf) for A < 0")

# ---------- Part 3: spread of the ratios against length ----------
sigma = 0.01  # per-logit noise between engines, illustrative
N = 2000
print("\nper-logit noise sigma =", sigma, "| responses per length:", N)
print("    L  std(token)  std(sum)  std(mean) | outside 0.2: token  sum"
      " | outside 4e-4: mean")
for L in (8, 32, 128, 512):
    y = sample(old_table, N, L)
    lo = logps(old_table, y)
    prev = torch.cat([torch.full((N, 1), V), y[:, :-1]], 1)
    z = old_table[prev] + sigma * torch.randn(N, L, V)  # noisy training engine
    ln = torch.log_softmax(z, -1).gather(-1, y.unsqueeze(-1)).squeeze(-1)
    d = ln - lo  # token log ratios
    tok_out = ((d.exp() - 1).abs() > 0.2).double().mean()
    sum_out = ((d.sum(1).exp() - 1).abs() > 0.2).double().mean()
    mean_out = ((d.mean(1).exp() - 1).abs() > 4e-4).double().mean()
    print(f"{L:5d}  {d.std():9.5f}  {d.sum(1).std():8.5f}"
          f"  {d.mean(1).std():9.6f} |        {tok_out:7.4f} {sum_out:6.3f}"
          f" |            {mean_out:6.3f}")

The output:

6 responses, lengths [3, 5, 8, 4, 10, 6], advantages +1.41 -0.71 -0.71 -0.71 +1.41 -0.71
max |autograd - formula| over the 72 parameters:
  GRPO  vs eq (12):                2.8e-17
  GSPO  vs eq (10):                2.8e-17
  GSPO  vs eq (9), s_i A_i grad log s_i: 2.8e-17
  GSPO-token vs eq (17):           2.8e-17
  GSPO-token, equal A vs GSPO:     1.4e-17
  gradient norms: GRPO 0.2011, GSPO 0.1868, difference 0.0394
gradient weight on grad log pi, response 0 (A = +1.41):
  GRPO  A*w/|y|: +0.643 +0.542 +0.503
  GSPO  A*s/|y|: +0.559 +0.559 +0.559
A > 0: share of zero-gradient tokens 0.325, weight min 0.145 max 1.200
A < 0: share of zero-gradient tokens 0.289, weight min 0.800 max 5.177
eps = 0.2: bounds from the paper are (0, 1.2] for A > 0 and [0.8, inf) for A < 0

per-logit noise sigma = 0.01 | responses per length: 2000
    L  std(token)  std(sum)  std(mean) | outside 0.2: token  sum | outside 4e-4: mean
    8    0.00866   0.02435   0.003043 |         0.0000  0.000 |             0.897
   32    0.00863   0.04972   0.001554 |         0.0000  0.000 |             0.801
  128    0.00861   0.09645   0.000754 |         0.0000  0.042 |             0.596
  512    0.00860   0.19804   0.000387 |         0.0000  0.318 |             0.312

All the Gradient Formulas Hold

The first five lines of the output are the differences between the gradient from automatic differentiation and the hand-assembled formula (the largest difference among the 72 parameters):

Formula checkedLargest difference
GRPO gradient, Eq 122.8e-17
GSPO gradient, Eq 102.8e-17
GSPO gradient, Eq 9 (siA^i∇log⁡sis_i\hat A_i\nabla\log s_i)2.8e-17
GSPO-token gradient, Eq 172.8e-17
GSPO-token vs GSPO with equal advantages1.4e-17

The differences are at the level of float64 rounding error, so all four formulas hold. The two objectives do not have the same gradient: the norms are 0.2011 (GRPO) and 0.1868 (GSPO), and the norm of the difference is 0.0394. For the weight of each token in the first response (advantage +1.41, 3 tokens), A^⋅w/∣y∣\hat A\cdot w/|y| and A^⋅s/∣y∣\hat A\cdot s/|y|: GRPO gives +0.643, +0.542 and +0.503, three different values; GSPO gives +0.559 three times, one shared weight for the response.

Token Weights of GRPO After Clipping

This step uses 200,000 tokens whose log ratios are normally distributed with standard deviation 0.4 (an illustrative value, far larger than in real training, chosen so that every case occurs), with random positive or negative advantage signs:

Advantage signShare with zero gradientMin weightMax weightRange in the paper
A^>0\hat A>00.3250.1451.200(0, 1.2](0,\,1.2]
A^<0\hat A<00.2890.8005.177[0.8, +∞)[0.8,\,+\infty)

For A^>0\hat A>0, tokens whose ratio exceeds 1+ε1+\varepsilon are clipped and get zero gradient, and the others have a weight equal to the ratio itself, so the maximum is exactly 1.2. For A^<0\hat A<0, tokens whose ratio falls below 1−ε1-\varepsilon get zero gradient, the others have weight at least 0.8, and the upper end depends only on the ratio itself, reaching 5.177 in this sample. The last point is what the paper means by “not negligible”: a token in a negative-advantage response whose probability rose several times in this update also gets a several times larger weight in the gradient, with no cap.

How the Spread of the Ratios Changes With Length

For each length I sampled 2,000 responses; the two tables below come from the last part of the output. The first is the standard deviation of the logs of three ratios (the log ratio of a token; the sum of log ratios; the mean of log ratios, whose exponential is GSPO’s sis_i):

Length LPer tokenSum (unnormalized)Mean (normalized)
80.008660.024350.003043
320.008630.049720.001554
1280.008610.096450.000754
5120.008600.198040.000387

The second is the share of responses whose ratio falls outside “1 plus or minus the clipping width” (the share of per-token ratios outside ±0.2 is 0 at all four lengths and is not listed):

Length LSum, outside ±0.2Mean, outside ±4e-4
80.0000.897
320.0000.801
1280.0420.596
5120.3180.312
Spread of the importance ratios against response length Log-log chart: the horizontal axis is response length L (8 to 512 tokens) and the vertical axis is the standard deviation of the log ratio. The per-token ratio stays near 0.0086 whatever the length; the unnormalized sequence ratio (the sum) grows with the square root of the length, from about 0.024 to about 0.198; the length-normalized sequence ratio (the mean) shrinks with the square root of the length, from about 0.003 to about 0.0004. Two gray dashed lines mark GRPO's clip range 0.2 and GSPO's clip width 4e-4. 0.001 0.01 0.1 8 32 128 512 GRPO clip range 0.2 GSPO clip width 4e-4 response length L (tokens, log scale) std of the log ratio (log scale) per-token ratio: flat in L L=8: 0.00866, L=512: 0.00860 sequence ratio, sum: grows as √L L=8: 0.02435, L=512: 0.19804 sequence ratio, mean: shrinks as 1/√L L=8: 0.003043, L=512: 0.000387
Figure: spread of the logs of the three ratios against response length L, under independent noise (standard deviation 0.01 per logit), on log-log axes. The gray dashed lines are GRPO's clipping range 0.2 and GSPO's clipping width 4e-4. Drawn directly from the output above.

The three lines tell a clear story:

  • The per-token ratio does not depend on length. Its spread stays around 0.0086, every token’s ratio is within 1±0.21\pm0.2, and clipping at 0.2 almost never triggers, which agrees in direction with the paper’s Figure 2, where GRPO clips only 0.0013 of the tokens; but the paper’s ratios also contain real policy updates, so the two numbers are not directly comparable.
  • The unnormalized sequence ratio grows as L\sqrt L. From 0.02435 at L=8 to 0.19804 at L=512, about 8 times, exactly 64\sqrt{64}. With the same ±0.2 clipping, no short response is out of range, while 0.318 of the 512-token responses are, so one width means very different tightness at different lengths. This is the paper’s point that responses of different lengths would need different clipping ranges, and one reason for the length normalization.
  • The normalized sequence ratio shrinks as 1/L1/\sqrt L. From 0.003043 down to 0.000387, about 1/8. At L=512 its noise is 3.9e-4, the same order as the paper’s 3e-4 and 4e-4. This shows why the sequence ratio needs a much narrower clipping width than the token ratio: it averages the independent noise of the tokens away, leaving mostly overall, systematic change.
  • But normalization does not make the noise independent of length. With the same ±4e-4 width, pure noise puts 0.897 of the 8-token responses out of range and only 0.312 of the 512-token responses. Length normalization makes the signal part of the ratio (the systematic change averaged per token) independent of length, while the noise part still shrinks with length.

The noise size 0.01 is my choice; with 0.02 all spreads double. The noise here is also independent across tokens, which is the best case; real differences between training and inference engines, and MoE routing flips, are neither independent nor normal. So this section only shows how the ratio spread scales, not what the paper’s numbers look like on a real model.

What This Check Shows and What It Does Not

It shows:

  • The gradient formulas in Section 4 of the paper have no typos. Equations 9, 10, 12 and 17 all agree with automatic differentiation, and what it says about the range of GRPO’s token weights also holds.
  • In the gradient, the difference between GSPO and GRPO is the granularity of the weight. Tokens in the same response get their own weights under GRPO (with no upper cap for negative advantages) and one shared weight under GSPO.
  • The effect of length normalization can be seen under independent noise. Without normalization, both the spread and the effective tightness of clipping change with length; with it, the spread shrinks to the same order as the paper’s clipping width.

It does not show:

  • Whether GSPO is really more stable and efficient. That needs training real models, and the paper has only curves.
  • The effect of MoE routing fluctuations. The toy policy has no routing, so I cannot test the paper’s statements about 10% of experts flipping and about Routing Replay.
  • The mechanism of the paper’s “irreversible collapse”. That needs long training runs to observe.

Experiments and Conclusions in the Paper

The setup of Section 5 is below; results are given as curves, with no tables:

ItemThe paper’s setting
Modela cold-start model fine-tuned from Qwen3-30B-A3B-Base
Trainingeach batch of rollouts is split into 4 mini-batches for gradient updates
EvaluationAIME’24 (average Pass@1 over 32 samples), LiveCodeBench (October 2024 to February 2025, average Pass@1 over 8 samples), CodeForces (Elo)
GSPO clipping range3e-4 on the left, 4e-4 on the right
GRPO baselineclipping range 0.2 and 0.27 (the paper says carefully tuned), with Routing Replay
  • Training efficiency (Figure 1). At the same training compute and the same number of consumed queries, GSPO’s training reward and all three benchmark curves are above GRPO’s; the paper adds that GSPO keeps improving as training compute grows, the query set is refreshed and generation gets longer, and that it has been applied to the reinforcement learning of the latest Qwen3 models. The plots carry no exact values and the horizontal axis “Training Compute” has no tick values, so I do not repeat specific scores.
  • The curious clipping fraction (Figure 2). The average share of clipped tokens during training is 0.15 for GSPO and 0.0013 for GRPO, two orders of magnitude apart, and the paper says changing the clipping range does not change the gap in magnitude. Its reading: GSPO clips far more tokens and uses fewer of them to estimate the gradient, yet is more efficient, which suggests GRPO’s token-level gradient estimates are noisy and use samples poorly.
  • Benefit for MoE (Section 5.3, Figure 3). On the 48-layer Qwen3-30B-A3B-Base, after each gradient update roughly 10% of the experts activated for the same sample under the new policy differ from the old policy, more so in deeper models, which makes token-level ratios fluctuate and keeps GRPO from converging normally. Their earlier remedy was Routing Replay: cache the experts activated by the old policy and replay those routes when computing the new policy’s ratios, so numerator and denominator go through the same activated network; Figure 3 shows Routing Replay is essential for GRPO training of an MoE model to converge. The costs are extra memory and communication, and possibly a limit on the MoE’s effective capacity. GSPO looks only at sequence likelihood, and the paper says an MoE model keeps its language-modeling ability so sequence likelihood does not fluctuate drastically, hence Routing Replay is no longer needed.
  • Benefit for RL infrastructure (Section 5.4). Training engines (such as Megatron) and inference engines (such as SGLang and vLLM) differ in precision, so in practice the old policy’s likelihoods are recomputed with the training engine. The paper argues that sequence-level likelihoods tolerate precision differences better than token-level ones, so it may be possible to use the inference engine’s likelihoods directly and skip the recomputation, especially for partial rollouts, multi-turn reinforcement learning and disaggregated training and inference. This is the paper’s intuition and outlook; there is no experiment.

Limitations and What Came Next

  • The evidence is curves only. There are no tables, confidence intervals or seed-to-seed variation, and only one model (a cold-start Qwen3-30B-A3B-Base) and one setup. The gap between GSPO and GRPO in Figure 1 looks clear, but without repeated runs the noise is unknown.
  • No ablations. The contributions of length normalization, sequence-level clipping and sequence-level advantages cannot be separated; the only comparison is GRPO (and the one with Routing Replay at that), with no comparison against contemporaneous GRPO improvements such as DAPO (see the DAPO explainer, which goes the other way: it keeps the token-level loss and widens the upper clipping bound).
  • “Irreversible collapse” is narrative. The central motivation of Section 3 has no curve behind it; Figure 3 compares MoE training with and without Routing Replay, which is not the collapse itself.
  • The choice of clipping range is not explained. How 3e-4 and 4e-4 were chosen and how sensitive the results are is not said; this post’s toy experiment only shows that the magnitude is reasonable for the sequence ratio of long responses.
  • A sequence ratio averages differences away. This is my own conjecture, not the paper’s: a large change in the probability of a few key tokens is diluted by hundreds of other tokens in the mean log ratio, so GSPO is less sensitive to them, which is both a source of its stability and a possible reason it reacts slowly to updates on key tokens. The paper does not discuss it.
  • Another route taken at the same time. DeepSeek-V3.2 (December 2025, arXiv:2512.02556) faced the same off-policy problem in MoE reinforcement learning, kept GRPO, and added Keep Routing (reusing during training the expert paths used at sampling, in its pipeline since DeepSeek-V3-0324), masking of negative-advantage sequences whose policy divergence is too large, and an unbiased correction of the KL estimator. MoE reinforcement learning stability still had different solutions at the end of 2025, and GSPO is one of them.

What to Take Away From This Paper

  1. Look at the unit of the ratio first. The whole difference between GRPO and GSPO is wi,tw_{i,t} replaced by sis_i; group advantages, clipping and the absence of a value model are unchanged.
  2. Compare gradients rather than objectives. Equations 10 and 12 differ by one weight, and that weight decides whether each token’s gradient is enlarged or shrunk.
  3. Understand the MoE motivation. When routing changes, token-level ratios cannot be trusted, while sequence likelihood is far less affected by any single token’s routing. This is GSPO’s most convincing use case, and the same problem Routing Replay and Keep Routing address.
  4. Separate the layers of evidence. The derivations can be checked (this post does); more stable and more efficient training is an observation on curves; “irreversible collapse” and “more tolerant of precision differences” are narrative or intuition.
  5. Do not take a toy experiment for a conclusion. The code here shows that the formulas are free of typos and how the spread scales with length, but not that GSPO is better in real training.

Further Reading

FAQ

How does GSPO differ from GRPO?
Both use group-normalized advantages and PPO-style clipping, and neither needs a value model. The difference is the unit of the importance ratio. GRPO computes one ratio per token and clips token by token, so tokens in the same response get different weights in the gradient. GSPO computes one ratio per response, the ratio of the new and old sequence likelihoods raised to the power 1/length, and clips the whole response, so every token in a response gets the same weight. The paper's argument is that the reward is given to the whole response, so the off-policy correction should be applied to the whole response too.
Why does GSPO clip at 3e-4 and 4e-4 when GRPO clips at about 0.2?
The paper only says that the two ratios are defined differently, so their clipping ranges typically differ in order of magnitude; the GSPO runs use 3e-4 on the left and 4e-4 on the right, the GRPO baseline 0.2 and 0.27. The intuition is that a sequence ratio averages the log ratios of hundreds or thousands of tokens, so independent token noise cancels and its spread shrinks with the square root of the length, which makes a much narrower clip width meaningful. In this post's toy experiment, independent noise gives a spread of about 3.9e-4 at length 512 (the noise size is my own illustrative value), the same order as the paper's widths; real noise is not independent, so treat it as an illustration.
Why is GSPO especially useful for reinforcement learning of MoE models?
The paper reports that on the 48-layer Qwen3-30B-A3B-Base, after each gradient update roughly 10% of the experts activated for the same response differ from those under the old policy. That makes token-level ratios fluctuate wildly, and GRPO needed Routing Replay, which caches the experts the old policy activated and replays them in the new policy, to converge. GSPO looks only at the likelihood of the whole response and is insensitive to single-token changes; the paper says it no longer needs Routing Replay, which saves memory and communication and does not limit the capacity of the MoE model.
GSPO clips two orders of magnitude more tokens than GRPO, so why is it more efficient?
In the paper's Figure 2 the average share of clipped tokens during training is about 0.15 for GSPO and about 0.0013 for GRPO, and changing the clipping range does not change the gap in magnitude. The paper reads this as evidence that GRPO's token-level gradient estimates are noisy and use samples inefficiently, while GSPO's sequence-level signal is more reliable. That is an observation plus an interpretation: the paper has no ablation that separates the sequence-level ratio, the length normalization and the sequence-level clipping, so it cannot say which change does the work.
What is GSPO-token and when would I use it?
It is a token-level variant of GSPO that allows a different advantage for each token, for settings such as multi-turn reinforcement learning where a finer adjustment than the whole response is wanted. It writes the token ratio as the numerical value of the sequence ratio times a stop-gradient token probability ratio, so numerically it equals the sequence ratio. The paper shows that when all tokens of a response have the same advantage, GSPO-token and GSPO coincide in objective, clipping condition and theoretical gradient; the code in this post checks the gradient part.