Monolithic fused head-loss kernel for combinable losses + metrics
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 12/100
- Tipo di issue
- Refactoring
- Chiarezza
- Da chiarire
- Stato di attività
- Tranquilla
- Stack tecnologico
- pytorch
- Ambito
- machine-learning, performance
Direzione di ricerca
The redundant softmax passes live in fused_grpo_loss_forward_backward, compute_policy_gradient_metrics, the fused_cross_entropy_base_from* helpers and fused_softmax_base, with the entropy chunking from PR #494. Start by reading those functions to map where sum_exp_logits and the tensor-parallel all-reduces are computed. The issue defers the design, so done needs an agreed design with the maintainers before any implementation.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
Each language-model head loss/metric runs its own softmax pass over the full vocab. When losses are combined, the work is duplicated:
- cross-entropy + z-loss — both compute
sum_exp_logitsover the same logits. - cross-entropy + distillation — both compute the student softmax (and additionally the teacher softmax for distillation).
- GRPO + extra metrics (PR #494) —
fused_grpo_loss_forward_backwardcomputeslogits_norm,exp_logits,sum_exp_logits, andpredicted_logits;compute_policy_gradient_metricsthen recomputes all of them on the same logits. Withcompute_entropy_metric=True, a third softmax pass runs on top.
Each pass also issues its own tensor-parallel all-reduces on logits_max / sum_exp_logits, multiplying the comm cost.
@torch.compile does not fuse across separate decorated functions, so the redundant work is real both in compute and memory.
Proposed direction
A single "monolithic" head-loss kernel (torch.compile and/or triton) that:
- Takes a config / flag-set describing which losses and metrics to emit (CE, z-loss, distillation, GRPO clipped objective, GRPO ratio/KL/clamp/advantage stats, entropy, ...).
- Runs softmax (and TP all-reduce) once over the logits.
- Emits all requested scalars and the combined gradient in one pass.
This subsumes fused_grpo_loss_forward_backward, _fused_cross_entropy_base_from_*, fused_softmax_base, compute_policy_gradient_metrics, and the entropy chunking in PR #494.
Out of scope
- Implementation details (triton vs torch.compile, kernel layout) — left for the design phase.
- The current PRs that hit this redundancy (notably #494) are not blocked on this issue and should land with their existing structure; this is the longer-term consolidation.
Motivation
Surfaced during review of #494, but the underlying redundancy predates it.
- Lingua principale
- Python
- Stelle
- 337
- Fork
- 52
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ServiceNow/Fast-LLM
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
ServiceNow/Fast-LLM#556 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
ServiceNow/Fast-LLM#538 ·
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 12/100
ServiceNow/Fast-LLM#533 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
ServiceNow/Fast-LLM#510 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
ServiceNow/Fast-LLM#500 ·
Tutte le issue di ServiceNow/Fast-LLM
Issue simili
-
Admin member of a research group cannot see the HX2 allocation until they've been added to itAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
developmentseed/titiler-cmr#278 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 2 giorni