[RFC] Logits numerical issues in convergence test
I maintainer di solito rispondono entro 3 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- testing-qa
Direzione di ricerca
Inizia da test/convergence/(bf16|fp32)/test_mini_models.py e verifica come il test di convergenza confronta attualmente i logits dopo le modifiche a FusedLinearCrossEntropy. Confronta gli approcci indicati per i controlli della log-probabilità e dell’output del modello, quindi definisci un confronto affidabile che distingua il rumore numerico dai bug di implementazione. Il lavoro è completato quando i test di convergenza gestiscono le differenze numeriche note senza mascherare i fallimenti reali.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
🐛 Describe the bug
This issue is to discuss how we should modify our convergence test to handle numerical issues of logits.
Context
In #704, we make FusedLinearCrossEntropy(flce) patched models have the freedom to switch between materializing logits and skipping logits. It allows us to compare logits from the last step again in flce convergence test, test/convergence/(bf16|fp32)/test_mini_models.py.
However, this change also exposed the hidden numerical issue that we didn't take care of.
The reasons why tests failed can be categorized into two types:
- numerical instability of floating points due to the limitation of bf16 representation, rounding errors, nonassociativity of floating point calculation, etc.
- actual bugs inside our implementation.
Ideally, we want to ignore type1 and handle type2 errors. But in reality, best we can do to ignore type1 errors is just increasing tolerences, which also increases the difficulty to capture type2 errors, the actual bugs in our kernels.
Existed methods
Before discussing how we can modify our convergence tests to address the issue, we can take a look of how other mainstream libraries handle it:
sglang
techniques:
calculate the ROUGE-L score
compare top logprobs
vllm
techniques:
compare logprob only when token id mismatch
verl
techniques:
set num_hidden_layers=1 to lower discrepancy
compare edit: it's more like cross entropy lossmean_of_logprob instead of top logprob only
Discussion
With above examples, we can see that instead of comparing raw logits, doing it in logprob space is more common. We should definitely do it without a doubt.
The other options are open for discussion:
- mean logprob or top logprob?
- setting num_hidden_layers=1 can speed up testing while minimizing the effect of numerical issue, but is one layer sufficient to represent model?
- forced to match top token?
Goal
A reliable convergence test with logits comparison, so we can distinguish whether the failure is due to numerical issue or actual bugs and no need to frequently adjust tolerances.
Known failure models (including passed models with relaxed tolerances, mark *)
Feel free to report as long as you find any model having logits mismatch. I'll add them to the list.
- gemma
- gemma2
- gemma3*
- granite3*
- qwen3_moe*
- qwen2_vl*
- qwen2_5_vl*
- mixtral (disabled for a long time)
cc @lancerts @yundai424 @qingquansong @shivam15s @shimizust @vaibhavjindal @austin362667
Reproduce
No response
Versions
liger_kernel==https://github.com/linkedin/Liger-Kernel/commit/4a2da9928b1a867079276467d03f4364c33ea673
- Lingua principale
- Python
- Stelle
- 6.7k
- Fork
- 673
- Merge medio
- 4g 20h
- PR unite (30g)
- 19
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 76/100
linkedin/Liger-Kernel#1693 ·
I maintainer di solito rispondono entro 3 giorni
-
[Bug] GroupNorm kernels overflow int32 sample offsets (`batch_idx * X_row_stride`) past 2^31 elementsForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
linkedin/Liger-Kernel#1692 ·
I maintainer di solito rispondono entro 3 giorni
-
[Bug] LigerGroupNormFunction.backward crashes on any 4D (N, C, H, W) tensor (H > 1) and hardcodes tl.bfloat16 for float16 inputsForse già presa @shotsan l’ha presa 2 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
linkedin/Liger-Kernel#1676 · 2 commenti ·
I maintainer di solito rispondono entro 3 giorni
-
[Bug] LigerFusedGateUpSiLUMulFunction.backward crashes with shape mismatch on any 3D (B, T, 2*H) input tensorForse già presa @shotsan l’ha presa 2 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
linkedin/Liger-Kernel#1675 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
[Bug] Silent backward gradient corruption in LigerCrossEntropy on non-contiguous logits (returns raw input logits as dL/dlogits)Forse già presa @shotsan l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
linkedin/Liger-Kernel#1674 ·
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di linkedin/Liger-Kernel
Issue simili
-
triage
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
kornia/kornia-rs#1416 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
PolicyEngine/ai-inequality#64 ·
I maintainer di solito rispondono entro 1 giorno
-
LinearGaussianStateSpace.dist splits states and observations wrongly when the transition varies over timeForse già presa @PabloRoque l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
pymc-devs/pymc-extras#839 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno