[BUG] FlopsProfiler reports 0 MACs for nn.RNN / nn.GRU / nn.LSTM and their Cell variants
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Ambito
- machine-learning, performance
Direzione di ricerca
Read _rnn_forward_hook and _rnn_cell_forward_hook in DeepSpeed's FlopsProfiler, along with MODULE_HOOK_MAPPING and the existing tests for RNN modules. Check how hooks update __flops__ and __macs__, then run the relevant profiler tests. Done means MAC totals and per-module MACs include the gate matrix multiplications for all six module types, including bidirectional and cell variants; a linked pull request is already open.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
get_model_profile() and FlopsProfiler.get_total_macs() report 0 MACs for nn.RNN, nn.GRU, nn.LSTM, nn.RNNCell, nn.GRUCell and nn.LSTMCell, though FLOPs for the same modules are counted
These modules are handled by _rnn_forward_hook / _rnn_cell_forward_hook (via MODULE_HOOK_MAPPING) instead of the patched functionals, and register_module_hooks returns early for them. The hooks add to __flops__ but never to __macs__, so it stays at the 0 set in reset_profile
Nothing warns about this. In a model that mixes an LSTM with other layers, the MAC total silently includes only the non-RNN layers, and the per-module MACs in the printed profile are wrong the same way
#3816 / #3833 corrected the FLOPs of these hooks, but MACs were never counted for them
To Reproduce
import torch
from deepspeed.profiling.flops_profiler import get_model_profile
model = torch.nn.LSTM(8, 16, num_layers=2, batch_first=True)
flops, macs, params = get_model_profile(model, input_shape=(4, 5, 8),
print_profile=False, as_string=False)
print(flops, macs)
Output on master (489c20a48): 149760 0
Expected behavior
AMACs should count the gate matmuls, the same way Linear is counted: one MAC per weight element of weight_ih and weight_hh per cell step, times batch × sequence length, times 2 if bidirectional.
For the model above:
- layer 0: 4·16·(8+16) = 1536
- layer 1: 4·16·(16+16) = 2048
- total: (1536 + 2048) × 4 × 5 = 71680 MACs
System info
- DeepSpeed: master @ 489c20a48
- torch 2.15.0, CPU only, macOS arm64
- Python: 3.12.0
Additional context
I have a fix with tests for all six module types (RNN/GRU/LSTM, including bidirectional, plus the three Cell variants) and will open a PR referencing this issue.
It touches _rnn_forward_hook near the lines changed by #8507 (PackedSequence crash), but it's an independent bug, and the two changes merge cleanly in either order. Once both land, the new MAC count also covers packed inputs, because it scales by the same batch_size * seq_length that #8507 corrects
- Lingua principale
- Python
- Stelle
- 43.3k
- Fork
- 5.1k
- Merge medio
- 5g 10h
- PR unite (30g)
- 85
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 deepspeedai/DeepSpeed
-
[Bug] DeepSpeedEngine.step leaves _running_engine_step=True permanently on exception, corrupting is_gradient_accumulation_boundary()Forse già presa @its-amann l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
deepspeedai/DeepSpeed#9190 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
[Bug] PipelineEngine._exec_reduce_grads and _exec_optimizer_step leave _force_grad_boundary=True permanently after any exceptionForse già presa @bantianyue l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
deepspeedai/DeepSpeed#9183 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
deepspeedai/DeepSpeed#9019 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
fp16 `hysteresis: 0` (or negative) makes DynamicLossScaler never lower the loss scale, so every overflowing step is skipped foreverForse già presa @damienen l’ha presa 26 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
deepspeedai/DeepSpeed#8982 ·
I maintainer di solito rispondono entro 2 giorni
-
[BUG] OneCycle applies the minimum momentum to the first Adam updateForse già presa @ai-yang l’ha presa 30 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
deepspeedai/DeepSpeed#8951 ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di deepspeedai/DeepSpeed
Issue simili
-
area/auth comp/agent P3 type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
NousResearch/hermes-agent#161417 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
Dao-AILab/flash-attention#3251 ·
I maintainer di solito rispondono entro 2 giorni
-
[New Check]: sqlserver_public_network_access_disabledForse già presa @pouria-l l’ha presa oggi. Apertafeature-request status/needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
prowler-cloud/prowler#13607 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
external langchain
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
langchain-ai/docs#8184 ·
I maintainer di solito rispondono entro 1 giorno