Skip to content

Commit 52436e8

Browse files
committed
fix for bulk run with litellm backend
1 parent ae497af commit 52436e8

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

klaudbiusz/cli/bulk_run.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@
88
from pathlib import Path
99
from typing import TypedDict
1010

11-
# Disable LiteLLM's async logging to avoid event loop issues with joblib
12-
import litellm
11+
from litellm_multiprocess_fix import patch_litellm_for_multiprocessing
12+
13+
patch_litellm_for_multiprocessing()
14+
1315
from codegen import ClaudeAppBuilder
1416
from codegen import GenerationMetrics as ClaudeGenerationMetrics
1517
from codegen_multi import LiteLLMAppBuilder
1618
from dotenv import load_dotenv
1719
from joblib import Parallel, delayed
1820
from prompts_databricks import PROMPTS as DATABRICKS_PROMPTS
1921

20-
litellm.turn_off_message_logging = True
21-
litellm.drop_params = True # silently drop unsupported params instead of warning
22-
2322
# Unified type for metrics from both backends
2423
GenerationMetrics = ClaudeGenerationMetrics
2524

@@ -48,12 +47,9 @@ def run_single_generation(
4847
suppress_logs: bool = True,
4948
mcp_binary: str | None = None,
5049
) -> RunResult:
51-
# Ensure LiteLLM is configured fresh in each worker process
50+
# re-apply litellm patch in worker process (joblib uses spawn/fork)
5251
if backend == "litellm":
53-
import litellm
54-
55-
litellm.turn_off_message_logging = True
56-
litellm.drop_params = True
52+
patch_litellm_for_multiprocessing()
5753

5854
def timeout_handler(signum, frame):
5955
raise TimeoutError("Generation timed out after 1200 seconds")

klaudbiusz/cli/codegen_multi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ def cli(
347347
app_name: str | None = None,
348348
model: str = "openrouter/minimax/minimax-m2", # other good options: "openrouter/moonshotai/kimi-k2-thinking", "gemini/gemini-2.5-pro",
349349
# some open-weights platform provide openai/anthropic-like API that can be used like
350+
# OPENAI_API_KEY=$DATABRICKS_TOKEN OPENAI_API_BASE=https://$DATABRICKS_HOST/serving-endpoints uv run cli/single_run.py "..." --backend=litellm --model="openai/databricks-gpt-oss-120b"
350351
# OPENAI_API_BASE="https://api.minimax.io/v1" OPENAI_API_KEY="$MINIMAX_API_KEY" uv run cli/single_run.py "..."" --backend=litellm --model="openai/MiniMax-M2"
351352
# ANTHROPIC_BASE_URL="https://api.minimax.io/anthropic" ANTHROPIC_API_KEY="$MINIMAX_API_KEY" uv run cli/single_run.py "..." --backend=litellm --model="anthropic/MiniMax-M2"
352353
suppress_logs: bool = False,

0 commit comments

Comments
 (0)