LiteLLMChatAPIのignore_seedがset_random_seed経由のseedを無視しない問題を修正 - #294
Open
kiakiraki wants to merge 1 commit into
Open
LiteLLMChatAPIのignore_seedがset_random_seed経由のseedを無視しない問題を修正#294kiakiraki wants to merge 1 commit into
kiakiraki wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
kiakiraki
marked this pull request as ready for review
July 19, 2026 01:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
問題
LiteLLMChatAPIのignore_seedオプションは docstring で「default_gen_kwargs に指定された seed を無視する」と明言していますが、実装は per-call のkwargsから seed を除去するだけで、以下の2経路が漏れていました。set_random_seed(seed)がignore_seedを無視して無条件にdefault_gen_kwargs["seed"]を書き込むdefault_gen_kwargsに最初から"seed"が入っている場合も除去されないflexeval の標準評価経路(
eval_setups.py)は必ずlanguage_model.set_random_seed()を呼ぶため、seed 非対応プロバイダ(docstring が名指しする anthropic/claude など)ではignore_seed=Trueを指定していても全 API コールがエラーになります。リトライ枯渇後はEMPTY_RESPONSEにフォールバックするため、全出力が空文字列のまま評価が「成功」してしまう危険がありました。修正内容
set_random_seed()をignore_seed=Trueのとき no-op に変更__init__でignore_seed=Trueのときdefault_gen_kwargsから"seed"を除去テスト
以下の3テストを追加しました(既存の
test_if_ignore_seedと同じ mock パターン)。ignore_seed=Trueのときset_random_seed(42)が no-op であることdefault_gen_kwargsの seed が除去されることset_random_seed()呼び出し後のgenerate_chat_response()で seed が API に渡らないこと🤖 Generated with Claude Code