Eval bug: deepseek4 file with no ratio-4 (CSA) layer crashes with integer division by zero in the llama_kv_cache constructor
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Inizia in src/llama-kv-cache.cpp, nella configurazione della rotazione attention del costruttore di llama_kv_cache, e segui come l'override DeepSeek gestisce una cache senza layer. Proteggi la configurazione della rotazione o il loop da una larghezza della head pari a zero; il lavoro è completato quando il caricamento del modello DeepSeek4 descritto, senza un layer ratio-4, non va più in crash durante la creazione del contesto. Il report fornisce un comando di riproduzione, ma non indica alcun test specifico.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Name and Version
Reproduced on a CPU-only Windows build (MSVC) of commit 5676dfbe0. The code involved is unchanged on master at c7518dbec5.
Operating systems
Windows (the arithmetic is not platform-specific; on Linux this should surface as SIGFPE)
GGML backends
CPU
Models
A deepseek4 GGUF whose compress_ratios contain no ratio-4 layer, i.e. only ratio 0, or ratio 0 and ratio 128. These were small synthetic test files. The published DeepSeek-V4-Flash file has ratio-4 layers and is not affected.
Problem description & steps to reproduce
Loading a deepseek4 model that has no ratio-4 (CSA) layer crashes while the context is created, before any token is evaluated:
llama-debug -m <deepseek4 file without a ratio-4 layer> -p "..." --save-logits -ngl 0 --no-warmup
The process exits with 0xC0000094 (STATUS_INTEGER_DIVIDE_BY_ZERO).
The cause is in the llama_kv_cache constructor (src/llama-kv-cache.cpp), in the branch that sets up the attention rotation:
bool attn_rot_k =
!attn_rot_disable &&
n_embd_head_k_all > 0 &&
ggml_is_quantized(type_k) &&
hparams.n_embd_head_k() % 64 == 0;
// always create Hadamard rotation tensors for DeepSeek lightning indexers
if ((model.arch == LLM_ARCH_DEEPSEEK32 || model.arch == LLM_ARCH_DEEPSEEK4 || ...) &&
hparams.n_embd_head_k_full == hparams.indexer_head_size) {
attn_rot_k = true;
}
if (attn_rot_k) {
n_rot_k = 64;
while (n_embd_head_k_all % (2*n_rot_k) == 0) {
n_rot_k *= 2;
}
}
The first condition requires n_embd_head_k_all > 0, but the DeepSeek override sets attn_rot_k = true without that check. For a deepseek4 model with no ratio-4 layer, the lightning-indexer (LID) cache is constructed with no layers, so its n_embd_head_k_all is 0. Then 0 % (2*n_rot_k) == 0 is always true, n_rot_k doubles until the uint32_t wraps to 0, and the next evaluation of the loop condition computes 0 % 0.
Expected behaviour
A cache with no layers should not get a rotation: either the DeepSeek override should also require n_embd_head_k_all > 0, or the loop should be guarded against a zero head width.
Workaround
Giving the file one ratio-4 layer avoids the crash. In the test files this was a trailing layer with an all-zero attn_output_b, so that it contributes nothing.
First Bad Commit
Not bisected.
Relevant log output
No log line is printed for the affected cache before the crash; the n_rot_k = ... line that follows the loop is never reached.
- Lingua principale
- C++
- Stelle
- 136k
- Fork
- 25.7k
- Merge medio
- 2g 1h
- PR unite (30g)
- 524
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 ggml-org/llama.cpp
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno
-
bug-unconfirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
Misc. bug: Hexagon: test-backend-ops POOL_2D fails for 128-wide kernels with padding on HTP0 (v73)Apertabug-unconfirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
ggml-org/llama.cpp#32598 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Llama chat webui. bug: scrollbar disappears when the mouse hovers near the top of the code blockForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug-unconfirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ggml-org/llama.cpp#32465 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di ggml-org/llama.cpp
Issue simili
-
[UBSan] spawn_simulator passes null child_options.args to uv_spawn (execvp nonnull violation)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
tenstorrent/tt-umd#4017 ·
I maintainer di solito rispondono entro 3 giorni
-
difficulty:easy func:gui prio:low type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
NatronGitHub/Natron#1538 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
hyprwm/hyprsunset#103 · 1 commento ·
-
Feature request
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
qbittorrent/qBittorrent#25338 ·
I maintainer di solito rispondono entro 2 giorni
-
Needs: Attention Needs: Version Info Platform: Android Platform: tvOS
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
react/react-native#60180 · 3 commenti ·
I maintainer di solito rispondono entro 2 giorni