Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Distributed group_mean casts group ids to float32, losing precision vs non-distributed path

Aperta Adatta ai principianti
#1,102 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@OnePunchMonk ci sta già lavorando.

Dal 3/10/2026.

  • #1103 di @OnePunchMonk — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python, pytorch

Direzione di ricerca

Inizia in src/art/megatron/context_parallel/loss_inputs.py, in ContextParallelLossInputs._distributed_group_mean, quindi confrontalo con art.utils.group_aggregate.group_aggregate e con il percorso group_mean di AlignedLossInputs. Mantieni il dtype nativo di by attraverso unique e searchsorted e verifica che il raggruppamento distribuito conservi le stesse garanzie di precisione del percorso non distribuito.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

`ContextParallelLossInputs._distributed_group_mean` in `src/art/megatron/context_parallel/loss_inputs.py` casts the grouping key (`by`) to `float32` before `torch.unique`/`torch.searchsorted`:

```python
flat_by = by.reshape(-1).to(dtype=torch.float32)
```

The non-distributed path (`art.utils.group_aggregate.group_aggregate`, used by the base `AlignedLossInputs.group_mean`) preserves the tensor's native dtype instead, and explicitly documents that "any dtype accepted by `torch.unique` is supported."

Failure scenario

`float32` cannot represent all integers exactly once they exceed 2**24 (16,777,216). If a grouping key ever carries a value past that range (e.g. a UID-based or otherwise large-range grouping key), two distinct group ids can collapse to the same float32 value, or get mis-bucketed by `searchsorted` against the globally-gathered sorted ids. This would silently merge two groups' values into the same mean/denominator on context-parallel ranks, corrupting the loss without raising any error.

This is low-probability today since group ids used in practice are small, but it's a real, silent discrepancy between the distributed and non-distributed code paths that should use the same precision guarantees.

Fix

Keep `by`'s native dtype through `unique`/`searchsorted` instead of forcing a float32 round-trip (matching `group_aggregate`'s contract). PR incoming.

Lingua principale
Python
Stelle
10.8k
Fork
1k
Merge medio
15h 31m
PR unite (30g)
166

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OpenPipe/ART

Tutte le issue di OpenPipe/ART

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.