Repository navigation
Conversation
22d35b3 to
c01a427
Compare
e8e80ca to
22becd0
Compare
d7f3b60 to
14b56c9
Compare
|
This PR fixes reproducable (endless?) loops I get on Nemotron-3.5-Lightning-30B-A3B. EDIT: The PR title implies this is related to ngram-mod but even with only MTP I get loops that are fixed by the changes here. |
Mitigation for a freeze where ngram-mod enters an infinite verification loop. Does not fix the underlying state leak. ggml-org#23268
14b56c9 to
e96c2a4
Compare
|
Same for Qwen3.x models, using ngram-mod. Would be great to have a fix merged. |
|
FWIW, as just another user I like to confirm that this fixes (at least in the sense of working around the issue) the repeated, sporadic hangs I had with llama-server. It was quite hard to hit this issue, so maybe a couple keywords for the search engines: "llama-server hangs, llama-server infinite-loop, llama-server stuck, ngram-mod, speculative decoding causes hangs". It helped me for ngram-mod. |
…misurano — KV cache decisa da llama-fit-params, decodifica speculativa a n-grammi, un motore morto non aspetta più il timeout BC-13, owner 12/09: «rendere il motore di llm locale estremamente rapido e meglio dei competitor». Banco: Qwen3-4B-Q4_K_M, RX 9070 XT Vulkan, preambolo 11.022 token, 3 ripetizioni, mediane dai timings del server. Prima → dopo: primo token a freddo 4.212 → 2.991 ms (−29 %); generazione nel compito d'agente 123,5 → 445,5 t/s (×3,6); chiamata intera primo turno 6.285 → 3.566 ms (−43 %); turno con cache calda 2.374 → 710 ms (−70 %); memoria di picco 4.378 → 6.060 MB. Le tre cure (solo llama-server-supervisor.mjs e il suo test): 1. Il tipo della KV cache non è più fisso a q8_0 (costava il 39 % del primo token su un modello vero: la misura del 03/09 era sul giocattolo da 0,6B). Si chiede a llama-fit-params, spedito nella stessa build: f16 se entra tutto, altrimenti q8_0, e q8_0 se il fitter non risponde. Tre modelli, tre esiti diversi (4B/16k → f16, 4B/128k → q8_0, 27B/16k → q8_0), ognuno con il suo perché su stderr. Nessun modello predefinito: la regola vale per un GGUF qualunque. 2. Decodifica speculativa a n-grammi (--spec-type ngram-mod): non vuole un secondo modello; uscita identica byte per byte su 3 domande su 3; accesa solo se il --help del binario la dichiara; interruttore in un posto solo per il difetto aperto ggml-org/llama.cpp#25819; al contrario costa fino a −10,5 % sulla prima chiamata e si ripaga dalla seconda. 3. Un motore già morto non diventa pronto: il ciclo guardava solo entry.failure; il 27B muore in 4,9 s dicendo cosa non va e il supervisore aspettava 245 s. Ora fallisce subito con le ultime righe del motore. Scartate perché misurate: -b/-ub (±1,7 %, rumore), --cache-reuse 256 (6.873 vs 6.906 ms). La cache del prefisso funziona già (11.140 su 11.157 token riusati al secondo turno). Test 17/17 nel supervisore (8 nuovi nei due versi: la leva che si accende e quella che NON si accende quando il binario non la offre), 52 nei test vicini del runtime locale. NON verificato: il 27B dell'owner non si carica su questa macchina oggi (VRAM occupata da dwm e da tre Chrome di altre sessioni): nessun prima/dopo sul modello vero; confronto con LM Studio/Ollama documentario (LM Studio senza GGUF, Ollama non installato); aggiornamento b10517 → b10921 non misurato; #25819 non cercato apposta. Fonti (lette il 12/09/2026, fonti primarie: WebSearch esaurita): --help del binario b10517; ggml-org/llama.cpp tools/server README e docs (cache_prompt, --cache-reuse, --spec-type ngram-mod, llama-fit-params); ggml-org/llama.cpp#25819 (17/07/2026); LM Studio docs (speculative decoding a due modelli); Ollama docs (nessuna speculativa); Hermes Agent (nessun motore locale spedito: «Use any model you want»). Rapporto: .claude/RAPPORTO-BC13-MOTORE-LOCALE-2026-09-12.md · misure: .claude/banco-bc13/
❗ This is WiP and a mitigation PR, not an actual fix.
Overview
When ngram-mod speculative decoding fails verification,
spec_draftis set to the accepted tokens (including the correction token) and the checkpoint is restored. On the next iteration the draft is reused instead of regenerated and sometimes fails again, creating a loop with non-deterministic end condition.This PRs adds logs to diagnose the problem, and a "band-aid" mitigation - it detects loop, and breaks out of it. However, the root cause of the loop is not yet clear.
Logs
Here are the logs that shows the issue:
Additional information
Requirements