cross_entropy=True rebinds torch.nn.functional.cross_entropy process-wide, so unrelated 3-D or soft-target calls fail
I maintainer di solito rispondono entro 3 giorni
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 65/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- backend, machine-learning
Direzione di ricerca
Start by tracing the 20 apply_liger_kernel_to_* functions that assign nn.functional.cross_entropy, then inspect liger_cross_entropy and its tests. Compare scoping the patch to the model's loss module with falling back to the original function for unsupported inputs, such as 3-D inputs or floating-point targets. Done means unrelated valid cross-entropy calls continue to work after a model is patched, with regression coverage for the reported cases.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
apply_liger_kernel_to_<model>(cross_entropy=True) replaces torch.nn.functional.cross_entropy for the whole process, not only inside the patched model. Any later F.cross_entropy call in the same process goes to Liger, including calls Liger's kernel doesn't support, and those raise:
import torch, torch.nn.functional as F
from liger_kernel.transformers import apply_liger_kernel_to_granite
x3, y3 = torch.randn(2, 7, 5), torch.randint(0, 7, (2, 5)) # (N, C, d) input: valid for F.cross_entropy
x2, soft = torch.randn(4, 7), torch.softmax(torch.randn(4, 7), -1) # probability targets: also valid
print(F.cross_entropy(x3, y3), F.cross_entropy(x2, soft)) # both fine
apply_liger_kernel_to_granite(rope=False, rms_norm=False, swiglu=False, cross_entropy=True)
print(F.cross_entropy.__module__) # liger_kernel.transformers.functional
F.cross_entropy(x3, y3) # ValueError: too many values to unpack (expected 2)
F.cross_entropy(x2, soft) # raises here on CPU; we did not check what it does on GPU
(CPU, Liger main.) 36 of the 45 apply_liger_kernel_to_* functions set nn.functional.cross_entropy = liger_cross_entropy, so an unrelated loss in the same training script, say a distillation loss with soft targets, breaks once a model is patched.
Patching only the patched model's module reference, or having liger_cross_entropy fall back to the original function for inputs it doesn't handle (more than 2 dims, floating-point targets), would avoid it. Found in Halo, which scopes its Liger cross entropy to transformers' loss module for this reason.
- Lingua principale
- Python
- Stelle
- 6.7k
- Fork
- 668
- Merge medio
- 4g 12h
- PR unite (30g)
- 27
Preparare l'ambiente
- Nessun Dockerfile né 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 linkedin/Liger-Kernel
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
linkedin/Liger-Kernel#1658 ·
I maintainer di solito rispondono entro 3 giorni
-
LigerPolyNorm defaults to in_place=True (docstring says False) and overwrites shared gradientsForse già presa @nazek52 l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
linkedin/Liger-Kernel#1647 ·
I maintainer di solito rispondono entro 3 giorni
-
[Bug] Experimental embedding kernels overflow int32 row offsets (illegal memory access past 2^31 output elements)Forse già presa @0xDexe l’ha presa 8 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
linkedin/Liger-Kernel#1570 · 3 commenti ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
linkedin/Liger-Kernel#1661 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
linkedin/Liger-Kernel#1660 ·
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di linkedin/Liger-Kernel
Issue simili
-
Internal ErrorApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
frappe/frappe_docker#2071 ·
I maintainer di solito rispondono entro 1 giorno
-
bug python
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
traceloop/openllmetry#4717 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
The-Pocket/PocketFlow#161 ·
-
[Bug]: Webapp workspace fails to render in Safari — "Can't find variable: requestIdleCallback"Apertacomp/desktop P2 type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NousResearch/hermes-agent#157702 ·
I maintainer di solito rispondono entro 1 giorno
-
scibench_physics / scibench_chemistry: a correct answer scores 0 when the unit has a power of tenForse già presa @BahaaMattar l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
EvolvingLMMs-Lab/lmms-eval#1699 ·
I maintainer di solito rispondono entro 1 giorno