[BUG] set_to_eval calls Llama.eval() on llama.cpp models, so latency/energy/memory metrics log a warning on every run
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 74/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
問題の呼び出しは pruna/engine/utils.py の set_to_eval にあり、hasattr(model, 'eval') のチェックが通ると model.eval() を呼び出しています。この関数と、その隣にある get_nn_modules の分岐を読み、llama_cpp.Llama.eval が tokens 引数を必要とすることを確認してください。llama.cpp でラップされたモデルがレイテンシ、エネルギー、メモリの各メトリクスで警告を出さなくなり、torch.nn.Module のモデルには従来どおり eval() が呼ばれることを確認できれば完了です。ガード条件を変更する前に、set_to_eval の既存テストを確認してください。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Python
- スター
- 1.4k
- フォーク
- 129
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
PrunaAI/pruna のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
[FEATURE] Add speculative decoding to the decoder algorithm family対応中かも @mohityadav8 が 6 日前に担当しました。 オープンenhancement
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
-
[BUG] kvpress algorithm: KVzipPress and FastKVzipPress never compress during generate再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンstale
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Rose22/openlumara#166 ·
-
documentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信
-
enhancement feature/signals self-driving team/self-driving
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
PostHog/posthog#144208 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
good first issue help wanted tests
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
LMPrado-DZ23/open_notas_br#14 ·
メンテナーはふだん 1 日以内に返信