Monolithic fused head-loss kernel for combinable losses + metrics
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 12/100
- Tipo de issue
- Refactorización
- Claridad
- Necesita aclaración
- Estado de actividad
- Tranquilo
- Stack tecnológico
- pytorch
- Área
- machine-learning, performance
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 337
- Forks
- 52
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ServiceNow/Fast-LLM
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
ServiceNow/Fast-LLM#556 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
ServiceNow/Fast-LLM#538 ·
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 12/100
ServiceNow/Fast-LLM#533 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
ServiceNow/Fast-LLM#510 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
ServiceNow/Fast-LLM#500 ·
Todos los issues de ServiceNow/Fast-LLM
Issues similares
-
enhancement help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Git-Hospital/githealthcheck#61 ·
Los mantenedores suelen responder en 1 día
-
changelog investigate
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
ramnes/notion-sdk-py#433 ·
-
Partial method descriptors raise on class accessPosiblemente ocupada @Gambit-Checkmate la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 19 días
-
docs pkg:core
Dificultad 1/5 Menos de una hora Aptitud para principiantes 84/100
pydantic/pydantic-ai#11929 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
intake/intake-esm#789 ·