[BUG] set_to_eval calls Llama.eval() on llama.cpp models, so latency/energy/memory metrics log a warning on every run
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 74/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- machine-learning
Línea de trabajo
La llamada problemática está en set_to_eval en pruna/engine/utils.py, que invoca model.eval() siempre que pasa la comprobación hasattr(model, 'eval'). Lee esa función y la rama get_nn_modules que está junto a ella, y luego confirma que llama_cpp.Llama.eval requiere un argumento tokens. Está terminado cuando un modelo envuelto con llama.cpp ya no dispara la advertencia en las métricas de latencia, energía y memoria, y los modelos torch.nn.Module siguen recibiendo la llamada a eval() como antes. Revisa los tests existentes de set_to_eval antes de cambiar la guarda.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
set_to_eval in pruna/engine/utils.py calls model.eval() whenever the model has an eval attribute. For a model compressed with the llama_cpp algorithm, the wrapped object is a llama_cpp.Llama, and its eval(tokens) is not a train/eval switch but "process these tokens". The call fails with a TypeError, which is caught and logged, so every metric that goes through PrunaModel.set_to_eval (latency, energy, memory) logs a warning on every run.
The metric still runs, so this is noise rather than a crash. But it reads like an error, and a wrapper whose eval() takes no arguments and does something else would actually be called.
What I did
Smashed Qwen2.5-Coder-1.5B-Instruct with
SmashConfig({"llama_cpp": {"quantization_method": "q4_k_m", "n_gpu_layers": 0}}, device="cpu"),
loaded it with PrunaModel.from_pretrained and ran EvaluationAgent with the latency metric:
Could not set model to evaluation mode: Llama.eval() missing 1 required positional argument: 'tokens'
Expected behavior
No eval() call on objects where eval is not a train/eval switch. A llama.cpp model has nothing to switch, so no warning.
A possible fix: call model.eval() only when model is a torch.nn.Module, and otherwise use the existing get_nn_modules branch, which should find no torch modules in a llama.cpp model and do nothing. I have not tested this change yet, and I have not checked which other wrappers rely on the hasattr branch, so I would like to hear whether you want it before opening a PR.
Environment
- pruna version: 0.3.5 (
set_to_evalis unchanged on main today) - python version: 3.12.16
- llama-cpp-python: 0.3.36
- Operating System: Ubuntu (GitHub-hosted runner), CPU only
Additional context
Found while benchmarking Qwen2.5-Coder-1.5B through pruna's llama_cpp algorithm at four precisions: https://github.com/zuhalsicim/sql-under-compression. pruna's EvaluationAgent with a custom metric agreed with my own scoring on all 800 answers of the 200-question run.
- Lenguaje dominante
- Python
- Estrellas
- 1.4k
- Forks
- 129
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una 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 PrunaAI/pruna
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
[FEATURE] Add speculative decoding to the decoder algorithm familyPosiblemente ocupada @mohityadav8 la tomó hace 6 días. Abiertoenhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
-
[BUG] kvpress algorithm: KVzipPress and FastKVzipPress never compress during generateQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertostale
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
Todos los issues de PrunaAI/pruna
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Rose22/openlumara#166 ·
-
documentation good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días
-
enhancement feature/signals self-driving team/self-driving
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
PostHog/posthog#144208 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
good first issue help wanted tests
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
LMPrado-DZ23/open_notas_br#14 ·
Los mantenedores suelen responder en 1 día