Low-precision rollout normalization can overflow its divisor and erase advantages
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- machine-learning
Research direction
Start with normalize_advantages_by_rollout in agentlightning/verl/per_rollout_loss.py and trace how it builds the divisor and accumulates token counts. Reproduce the float16 example from the issue, then check the listed float16, bfloat16, float32, float64, and gradient cases on CPU. Done when counts remain exact, the divisor and division use at least float32, the caller’s output dtype is preserved, and the rollout grouping and trained-row divisor are unchanged.
Written by the indexing model from the issue text.
Description
normalize_advantages_by_rollout constructs the rollout divisor in advantages.dtype. With float16 advantages, a representable normalized result can become zero because the intermediate divisor overflows. Token counts are also converted to the advantage dtype before accumulation, which rounds counts such as 257 in bfloat16.
Reproduced on main 05c7fe133175653e48c990546a3509e52dc56512, Python 3.12.2, torch 2.13.0+cpu, VERL 0.8.0, with the locked verl-cpu development environment:
import torch
from agentlightning.verl.per_rollout_loss import normalize_advantages_by_rollout
mask = torch.ones(2, 1024, dtype=torch.long)
advantages = torch.ones(2, 1024, dtype=torch.float16)
scaled = normalize_advantages_by_rollout(
advantages, mask, ["A", "A"], num_trained_rows=64
)
print(scaled.float().sum().item()) # 0.0; expected 1 / 64 == 0.015625
The divisor is 2048 * 64 = 131072, which becomes infinity in float16, while each correctly normalized advantage (1 / 131072) is representable. This can erase the policy-gradient contribution before the loss function sees it. This is separate from reward conversion before GRPO (#639/#640): the input here is an already nonzero advantage tensor.
Expected: retain exact token counts and evaluate the existing divisor and division in at least float32, then preserve the caller's output dtype. The rollout grouping and the existing trained-row divisor stay the same. A focused patch can cover float16 overflow, bfloat16 token-count rounding, float32/float64 controls, and gradient propagation on CPU.
This is a numerical reproduction, not a model-training or GPU-quality result. Codex assisted the investigation.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 1.7k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 10
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/agent-lightning
-
RayPPOTrainer._dump_generations() missing gts argument in _train_step callPossibly taken @yunkai-yyk claimed this 252 days ago. Openbug v0.x verl
Difficulty 1/5 Under an hour Newbie friendliness 68/100
microsoft/agent-lightning#492 ·
Maintainers usually reply within 2 days
-
enhancement store v0.x
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
microsoft/agent-lightning#372 · 10 comments ·
Maintainers usually reply within 2 days
-
Terminal rollout projection drops numeric dataset ID zeroPossibly taken @notoufa claimed this 2 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
microsoft/agent-lightning#659 ·
Maintainers usually reply within 2 days
-
Gateway loses model-request events for malformed or non-object upstream JSONPossibly taken @JianhaoYu-AI claimed this 3 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 20/100
microsoft/agent-lightning#655 ·
Maintainers usually reply within 2 days
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
microsoft/agent-lightning#650 · 1 comment ·
Maintainers usually reply within 2 days
All issues in microsoft/agent-lightning
Similar issues
-
area/profiles comp/cli P3 type/feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NousResearch/hermes-agent#146372 ·
Maintainers usually reply within 1 day
-
[BUG] OpenAI-compatible embedding model alias breaks embedder constructionPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
[oblt-aw][autodoc] Document obs-aw-automerge contract and fix automerge doc inconsistenciesPossibly taken @github-actions claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
GeoSeries scale and skew tests fail with pytest 9.2.0Possibly taken @jiayuasu claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
admission-deferred priority: medium status: ready work-class: scoped
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
melodic-software/claude-code-plugins#10887 · 4 comments ·
Maintainers usually reply within 1 day