Multiple calls to create_chat_completion() fail with "llama_decode: failed to decode, ret = -1"
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 55/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- python
- Bereich
- ai, backend-api-design
Rechercherichtung
Das Issue betrifft die Methode create_chat_completion der Klasse llama_cpp.Llama. Sieh dir den Quellcode dieser Methode und die zugrunde liegenden C++-Bindings an, um zu sehen, wie der Kontext und der KV cache zwischen Aufrufen verwaltet werden. Der Benutzer hat festgestellt, dass llm.reset() oder llm._ctx.kv_cache_clear() funktioniert, daher beinhaltet die Lösung wahrscheinlich das automatische Zurücksetzen des Zustands nach einer Completion. Prüfe die Testsuite auf ähnliche Muster. „Erledigt“ ist die Aufgabe, wenn zwei aufeinanderfolgende Aufrufe von create_chat_completion ohne manuelles Zurücksetzen erfolgreich sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Prerequisites
Please answer the following questions for yourself before submitting an issue.
- I am running the latest code. Development is very rapid so there are no tagged versions as of now.
- I carefully followed the README.md.
- I searched using keywords relevant to my issue to make sure that I am creating a new issue that is not already open (or closed).
- I reviewed the Discussions, and have a new bug or useful enhancement to share.
Expected Behavior
I am running LiquidAI's LFM2.5-1.2B-Instruct model. Calling create_chat_completion() multiple times should not throw error.
Current Behavior
When trying to call create_chat_completion twice in a row, the model throws error "llama_decode: failed to decode, ret = -1"
Environment and Context
I am using llama-cpp-python v0.3.16. Python version is 3.13.9.
- Windows 11
Failure Information (for bugs)
On tracing back the issue, it looks like there needs to be a context and cache reset after each chat_completion call, which isn't happening yet.
Steps to Reproduce
from pathlib import Path
from llama_cpp import Llama
llm = Llama(
model_path=str(Path.home() / "AppData/Local/llama.cpp/LiquidAI_LFM2.5-1.2B-Instruct-GGUF_LFM2.5-1.2B-Instruct-Q4_K_M.gguf"),
n_ctx=1000
)
system_prompt = """
\nYou are a helpful assistant
"""
prompt = """
suggest me places to visit during winter season
"""
response = llm.create_chat_completion(
messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": prompt}],
)
print(response)
# llm.reset() # Using this works
# llm._ctx.kv_cache_clear() # Using this works
response = llm.create_chat_completion(
messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": prompt}],
)
print(response)
Failure Logs
init: the tokens of sequence 0 in the input batch have inconsistent sequence positions:
- the last position stored in the memory module of the context (i.e. the KV cache) for sequence 0 is X = 519
- the tokens for sequence 0 in the input batch have a starting position of Y = 29
it is required that the sequence positions remain consecutive: Y = X + 1
decode: failed to initialize batch
llama_decode: failed to decode, ret = -1
- Vorherrschende Sprache
- Python
- Sterne
- 10.6k
- Forks
- 1.5k
- Ø Merge
- 3 Std. 57 Min.
- Gemergte PRs (30 T.)
- 4
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus abetlen/llama-cpp-python
-
Seven llama_sampler_init_* bindings admit keyword arguments that the ctypes function object silently dropsEvtl. vergeben @Belal0066 hat das vor 20 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
abetlen/llama-cpp-python#2371 ·
Maintainer antworten meist innerhalb von 1 Tag
-
uv add llama-cpp-python wheels fails for versions above 0.3.30Evtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
abetlen/llama-cpp-python#2352 · 1 Kommentar · 2 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
-
Docs: consolidate build-from-source and GPU backend guideEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
abetlen/llama-cpp-python#2314 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Llama.embed() calls LlamaBatch.add_sequence with old 3-arg signature; missing logits_arrayEvtl. wieder frei @lxcxjxhx hat das vor 97 Tagen übernommen, und es ist kein Pull Request offen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
abetlen/llama-cpp-python#2211 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Llama() silently accepts and discards `embedding` kwarg; .embed() then raises confusinglyEvtl. vergeben @Anai-Guo hat das vor 38 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
abetlen/llama-cpp-python#2210 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in abetlen/llama-cpp-python
Ähnliche Issues
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 88/100
gradio-app/gradio#13964 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 93/100
BSData/horus-heresy-3rd-edition#3232 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
jbacalso24/mimry#123 ·
Maintainer antworten meist innerhalb von 1 Tag
-
p:3-mid pydanty:bug pydanty:is-working
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
pydantic/pydantic-ai#10153 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
good first issue priority: medium size: S testing
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
cubrid-lab/cubrid-cookbook-python#316 ·
Maintainer antworten meist innerhalb von 1 Tag