From 87a266f21ae9c2189a70ba46cc5dec38b6459bd0 Mon Sep 17 00:00:00 2001 From: anthonypizzolato-abacus Date: Mon, 3 Aug 2026 13:12:09 +0000 Subject: [PATCH] Add Qwen3.8 Max to live bench runs --- lcb_runner/lm_styles.py | 8 +++ lcb_runner/prompts/code_generation.py | 2 +- lcb_runner/runner/qwen_runner.py | 70 +++++++++++++++++++++++++++ lcb_runner/runner/runner_utils.py | 4 ++ 4 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 lcb_runner/runner/qwen_runner.py diff --git a/lcb_runner/lm_styles.py b/lcb_runner/lm_styles.py index 66988366..da99eb79 100644 --- a/lcb_runner/lm_styles.py +++ b/lcb_runner/lm_styles.py @@ -12,6 +12,7 @@ class LMStyle(Enum): CohereCommand = "CohereCommand" DataBricks = "DataBricks" DeepSeekAPI = "DeepSeekAPI" + QwenAPI = "QwenAPI" GenericBase = "GenericBase" @@ -544,6 +545,13 @@ def __hash__(self) -> int: datetime(2024, 3, 31), link="https://huggingface.co/qwen/Qwen1.5-72B-Chat/", ), + LanguageModel( + "qwen3.8-max", + "Qwen3.8-Max", + LMStyle.QwenAPI, + datetime(2026, 8, 2), + link="https://qwen.ai/blog?id=qwen3.8", + ), LanguageModel( "abacusai/Smaug-2-72B", "Smaug-2-72B ", diff --git a/lcb_runner/prompts/code_generation.py b/lcb_runner/prompts/code_generation.py index 020d4617..d617b381 100644 --- a/lcb_runner/prompts/code_generation.py +++ b/lcb_runner/prompts/code_generation.py @@ -206,7 +206,7 @@ def get_example_prompt(example): def format_prompt_generation( question: CodeGenerationProblem, LanguageModelStyle: LMStyle ) -> str: - if LanguageModelStyle in [LMStyle.OpenAIChat, LMStyle.DeepSeekAPI]: + if LanguageModelStyle in [LMStyle.OpenAIChat, LMStyle.DeepSeekAPI, LMStyle.QwenAPI]: chat_messages = [ { "role": "system", diff --git a/lcb_runner/runner/qwen_runner.py b/lcb_runner/runner/qwen_runner.py new file mode 100644 index 00000000..39c571f4 --- /dev/null +++ b/lcb_runner/runner/qwen_runner.py @@ -0,0 +1,70 @@ +import os +from time import sleep + +try: + import openai + from openai import OpenAI +except ImportError as e: + pass + +from lcb_runner.runner.base_runner import BaseRunner + + +class QwenRunner(BaseRunner): + client = OpenAI( + api_key=os.getenv("DASHSCOPE_API"), + base_url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1", + ) + + def __init__(self, args, model): + super().__init__(args, model) + self.client_kwargs: dict[str | str] = { + "model": args.model, + "temperature": args.temperature, + "max_tokens": args.max_tokens, + "top_p": args.top_p, + "frequency_penalty": 0, + "presence_penalty": 0, + "n": 1, + "timeout": args.openai_timeout, + # "stop": args.stop, --> stop is only used for base models currently + } + + def _run_single(self, prompt: list[dict[str, str]]) -> list[str]: + assert isinstance(prompt, list) + + def __run_single(counter): + try: + response = self.client.chat.completions.create( + messages=prompt, + **self.client_kwargs, + ) + content = response.choices[0].message.content + return content + except ( + openai.APIError, + openai.RateLimitError, + openai.InternalServerError, + openai.OpenAIError, + openai.APIStatusError, + openai.APITimeoutError, + openai.InternalServerError, + openai.APIConnectionError, + ) as e: + print("Exception: ", repr(e)) + print("Sleeping for 30 seconds...") + print("Consider reducing the number of parallel processes.") + sleep(30) + return QwenRunner._run_single(prompt) + except Exception as e: + print(f"Failed to run the model for {prompt}!") + print("Exception: ", repr(e)) + raise e + + outputs = [] + try: + for _ in range(self.args.n): + outputs.append(__run_single(10)) + except Exception as e: + raise e + return outputs diff --git a/lcb_runner/runner/runner_utils.py b/lcb_runner/runner/runner_utils.py index a6aa6ee2..c1bb2e2d 100644 --- a/lcb_runner/runner/runner_utils.py +++ b/lcb_runner/runner/runner_utils.py @@ -30,6 +30,10 @@ def build_runner(args, model: LanguageModel): from lcb_runner.runner.deepseek_runner import DeepSeekRunner return DeepSeekRunner(args, model) + if model.model_style == LMStyle.QwenAPI: + from lcb_runner.runner.qwen_runner import QwenRunner + + return QwenRunner(args, model) elif model.model_style in []: raise NotImplementedError( f"Runner for language model style {model.model_style} not implemented yet"