BatchNorm1d / Reduce: float32 sums over batch×time use one sequential accumulator
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 54/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- c
- Ambito
- machine-learning
Direzione di ricerca
Read meanOverTrailingAxesFloat32 and varianceBiasedOverTrailingAxesFloat32 in src/arithmetic/Reduce.c, then inspect bnBackward in src/layer/BatchNorm1d.c. Compare pairwise or blocked float32 summation approaches and check the existing BatchNorm and Reduce tests against their current tolerances; done means the sums use the chosen approach while those tests still pass.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
BatchNorm1d sums over batch × time with one float32 accumulator, element by element:
- forward statistics:
meanOverTrailingAxesFloat32andvarianceBiasedOverTrailingAxesFloat32insrc/arithmetic/Reduce.c(onefloat accper channel); - backward:
sumDy/sumDyXhatinsrc/layer/BatchNorm1d.c(bnBackward, same pattern).
For a TC-ResNet8 stem on 12-class keyword spotting (batch 100, T = 98) that is N = 9,800 terms per channel. The rounding error of a running float32 sum grows with N (worst case ~N·ε, typically ~√N·ε), while a pairwise or blocked sum grows with log N.
Evidence
Same start, C vs a PyTorch float32 twin of the same model (identical initial weights, data order, Dropout off):
- step 1 losses agree to < 1e-4 relative;
- the per-step loss then drifts above 1e-4 relative at step 4–13 (4 seeds), while PyTorch float32 vs float64 drifts only at step 7–61;
- a PyTorch twin that copies C's sequential BN summation reproduces C's departure steps, so the BN sums are the main source.
The effect on final accuracy is within seed noise (10-seed comparison), so this is precision, not a correctness bug.
Options
- Pairwise (or fixed-size blocked) summation in the Reduce float32 kernels and the BN backward sums. Same op count, a small stack or loop change; helps every Reduce user (LayerNorm, GroupNorm, PPCA replay).
- Kahan summation: ~4× the adds per element; costly on an MCU.
- Leave as is and document it.
Option 1 looks like the right cost/benefit for an MCU. Any change re-captures no goldens by itself; the existing BN/Reduce tests must stay within their tolerances.
- Lingua principale
- C
- Stelle
- 2
- Fork
- 3
- Merge medio
- 13h 6m
- PR unite (30g)
- 9
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun 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 es-ude/OnDeviceTraining
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
es-ude/OnDeviceTraining#549 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
es-ude/OnDeviceTraining#547 ·
I maintainer di solito rispondono entro 1 giorno
-
arithmetic: addSymInt32Tensors / Sub twin swap the tensor arguments on the unequal-scale pathApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
es-ude/OnDeviceTraining#536 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
es-ude/OnDeviceTraining#478 ·
I maintainer di solito rispondono entro 1 giorno
-
bug documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
es-ude/OnDeviceTraining#459 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di es-ude/OnDeviceTraining
Issue simili
-
issue: bug report
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 2 giorni
-
AI/LLM documentation Professional Contributors Only
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 2 giorni
-
severity: low
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
luainkernel/lunatik#2752 ·
I maintainer di solito rispondono entro 1 giorno
-
feature:config kind:docs os:windows toolchain:cmake triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
BasedHardware/omi#26486 ·
I maintainer di solito rispondono entro 1 giorno