[BUG] set_to_eval calls Llama.eval() on llama.cpp models, so latency/energy/memory metrics log a warning on every run
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 74/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- machine-learning
Hướng nghiên cứu
Lệnh gọi có vấn đề nằm trong set_to_eval ở pruna/engine/utils.py, hàm này gọi model.eval() bất cứ khi nào kiểm tra hasattr(model, 'eval') thành công. Hãy đọc hàm đó và nhánh get_nn_modules nằm cạnh nó, rồi xác nhận rằng llama_cpp.Llama.eval yêu cầu tham số tokens. Công việc hoàn tất khi một mô hình được bọc bằng llama.cpp không còn kích hoạt cảnh báo trong các chỉ số độ trễ, năng lượng và bộ nhớ, còn các mô hình torch.nn.Module vẫn được gọi eval() như trước. Kiểm tra các test hiện có của set_to_eval trước khi thay đổi điều kiện bảo vệ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 1.4k
- Fork
- 129
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của PrunaAI/pruna
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
[FEATURE] Add speculative decoding to the decoder algorithm familyCó thể đã có người làm @mohityadav8 đã nhận 6 ngày trước. Đang mởenhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
-
[BUG] kvpress algorithm: KVzipPress and FastKVzipPress never compress during generateCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởstale
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
Tất cả issue của PrunaAI/pruna
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Rose22/openlumara#166 ·
-
documentation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement feature/signals self-driving team/self-driving
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
PostHog/posthog#144208 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue help wanted tests
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
LMPrado-DZ23/open_notas_br#14 ·
Maintainer thường phản hồi trong vòng 1 ngày