Multiple calls to create_chat_completion() fail with "llama_decode: failed to decode, ret = -1"
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- ai, backend-api-design
Línea de trabajo
El issue está en el método create_chat_completion de la clase llama_cpp.Llama. Revisa el código fuente de ese método y los bindings subyacentes de C++ para ver cómo se gestionan el contexto y la caché KV entre llamadas. El usuario descubrió que llamar a llm.reset() o llm._ctx.kv_cache_clear() funciona, por lo que la solución probablemente implique restablecer automáticamente el estado después de una completion. Revisa la suite de tests en busca de patrones similares. «Hecho» es cuando dos llamadas consecutivas a create_chat_completion tienen éxito sin un restablecimiento manual.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Python
- Estrellas
- 10.6k
- Forks
- 1.5k
- Merge medio
- 3 h 57 min
- PR fusionados (30 d)
- 4
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de abetlen/llama-cpp-python
-
Seven llama_sampler_init_* bindings admit keyword arguments that the ctypes function object silently dropsPosiblemente ocupada @Belal0066 la tomó hace 18 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
abetlen/llama-cpp-python#2371 ·
Los mantenedores suelen responder en 1 día
-
uv add llama-cpp-python wheels fails for versions above 0.3.30Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
abetlen/llama-cpp-python#2352 · 1 comentario · 2 reacciones ·
Los mantenedores suelen responder en 1 día
-
Docs: consolidate build-from-source and GPU backend guidePosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
abetlen/llama-cpp-python#2314 ·
Los mantenedores suelen responder en 1 día
-
Llama.embed() calls LlamaBatch.add_sequence with old 3-arg signature; missing logits_arrayQuizá libre de nuevo @lxcxjxhx la tomó hace 95 días y no hay ningún pull request abierto. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
abetlen/llama-cpp-python#2211 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Llama() silently accepts and discards `embedding` kwarg; .embed() then raises confusinglyPosiblemente ocupada @Anai-Guo la tomó hace 36 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
abetlen/llama-cpp-python#2210 ·
Los mantenedores suelen responder en 1 día
Todos los issues de abetlen/llama-cpp-python
Issues similares
-
[BUG] Container scenario crashes without expected_recovery_time, kube DNS example uses retry_waitAbiertoneeds-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
krkn-chaos/krkn#1627 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
NousResearch/hermes-agent#136483 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
[BUG] LazyStackedTensorDictStore zeroes the last byte of a new key set on the last elementPosiblemente ocupada @peterdsharpe la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
pytorch/tensordict#2307 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día