Exceed the model's maximum context length
In SQL generation, I met the following error in some instances. Have you ever met it?
{'object': 'error', 'message': "This model's maximum context length is 32768 tokens. However, you requested 41648 tokens (37552 in the messages, 4096 in the completion). Please reduce the length of the messages or completion. None", 'type': 'BadRequestError', 'param': None, 'code': 400}
You can reduce max_tokens to 2048 in the config yaml.
Alternatively, you can add --max-model-len and --repo-scaling when you start vllm:
CUDA_VISIBLE_DEVICES=0,1,2,3 vllm serve Qwen/Qwen2.5-Coder-32B-Instruct --served-model-name Qwen/Qwen2.5-Coder-32B-Instruct --port 9999 -tp 4 --rope-scaling '{"rope_type":"yarn","factor":4.0,"original_max_position_embeddings":32768}' --max-model-len 131072
I have tried both methods, but neither works. The number of message tokens is 37,552, which already exceeds the token limit of Qwen/Qwen2.5-Coder-32B-Instruct. Is there any method to reduce the length of messages? Could you provide insights into why the message token count remains fixed across several runs?
Qwen/Qwen2.5-Coder-32B-Instruct actually support 128K window size, details in HuggingFace Processing Long Texts section.
However, in paper experimental settings, 32K window size is already enough. Could you leave more details about how do you run vllm server? And which step did the error raise (exception stack)?
I have 8 H100s. I ran it using 'CUDA_VISIBLE_DEVICES=0,1,2,3 vllm serve Qwen/Qwen2.5-Coder-32B-Instruct --gpu-memory-utilization 0.95 --served-model-name Qwen/Qwen2.5-Coder-32B-Instruct --port 9999 -tp 4 --rope-scaling '{"rope_type":"yarn","factor":4.0,"original_max_position_embeddings":32768}' --max-model-len 131072', I also tried 'CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 vllm serve Qwen/Qwen2.5-Coder-32B-Instruct --served-model-name Qwen/Qwen2.5-Coder-32B-Instruct --port 9999 -tp 8'.
When running 'bash script/qwen32b_bird_dev_exp.sh', it raises an exception:
Traceback (most recent call last): File "/Alpha-SQL/alphasql/runner/mcts_runner.py", line 60, in run_one_task mcts_solver.solve() File "/Alpha-SQL/alphasql/algorithm/mcts/mcts.py", line 120, in solve self.expand(leaf_node) File "/Alpha-SQL/alphasql/algorithm/mcts/mcts.py", line 43, in expand action_nodes = action.create_children_nodes(node, self.llm_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Alpha-SQL/alphasql/algorithm/mcts/mcts_action.py", line 200, in create_children_nodes responses = call_openai(prompt, **llm_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Alpha-SQL/alphasql/llm_call/openai_llm.py", line 78, in call_openai raise e File "/Alpha-SQL/alphasql/llm_call/openai_llm.py", line 38, in call_openai response = client.chat.completions.create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Alpha-SQL/alphasql_env/lib/python3.11/site-packages/openai/_utils/_utils.py", line 287, in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Alpha-SQL/alphasql_env/lib/python3.11/site-packages/openai/resources/chat/completions/completions.py", line 1087, in create return self._post( ^^^^^^^^^^^ File "/Alpha-SQL/alphasql_env/lib/python3.11/site-packages/openai/_base_client.py", line 1249, in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Alpha-SQL/alphasql_env/lib/python3.11/site-packages/openai/_base_client.py", line 1037, in request raise self._make_status_error_from_response(err.response) from None openai.BadRequestError: Error code: 400 - {'object': 'error', 'message': "This model's maximum context length is 32768 tokens. However, you requested 39695 tokens (37647 in the messages, 2048 in the completion). Please reduce the length of the messages or completion. None", 'type': 'BadRequestError', 'param': None, 'code': 400}
Out of 1,534 examples, I encountered failures on about 130 of them. Even after rerunning the bash script/qwen32b_bird_dev_exp.sh script multiple times, the error persists.
It seems that the vllm 128K context window is not set successfully. Can you provide the output log after the vllm serve command is started? It should contain the max tokens information of the deployed LLM, which will help solve the above problem.
CUDA_VISIBLE_DEVICES=0,1,2,3 vllm serve Qwen/Qwen2.5-Coder-32B-Instruct --gpu-memory-utilization 0.95 --served-model-name Qwen/Qwen2.5-Coder-32B-Instruct --port 9999 -tp 4 --rope-scaling '{"rope_type":"yarn","factor":4.0,"original_max_position_embeddings":32768}' --max-model-len 131072
INFO 07-05 22:47:38 [init.py:244] Automatically detected platform cuda. INFO 07-05 22:47:49 [api_server.py:1287] vLLM API server version 0.9.1 INFO 07-05 22:47:50 [cli_args.py:309] non-default args: {'port': 9999, 'model': 'Qwen/Qwen2.5-Coder-32B-Instruct', 'rope_scaling': {'rope_type': 'yarn', 'factor': 4.0, 'original_max_position_embeddings': 32768}, 'max_model_len': 131072, 'served_model_name': ['Qwen/Qwen2.5-Coder-32B-Instruct'], 'tensor_parallel_size': 4, 'gpu_memory_utilization': 0.95} INFO 07-05 22:47:50 [config.py:533] Overriding HF config with {'rope_scaling': {'rope_type': 'yarn', 'factor': 4.0, 'original_max_position_embeddings': 32768}} INFO 07-05 22:48:04 [config.py:823] This model supports multiple tasks: {'embed', 'score', 'reward', 'generate', 'classify'}. Defaulting to 'generate'. INFO 07-05 22:48:04 [config.py:1946] Defaulting to use mp for distributed inference INFO 07-05 22:48:04 [config.py:2195] Chunked prefill is enabled with max_num_batched_tokens=8192. WARNING 07-05 22:48:07 [env_override.py:17] NCCL_CUMEM_ENABLE is set to 0, skipping override. This may increase memory overhead with cudagraph+allreduce: https://github.com/NVIDIA/nccl/issues/1234 INFO 07-05 22:48:12 [init.py:244] Automatically detected platform cuda. INFO 07-05 22:48:17 [core.py:455] Waiting for init message from front-end. INFO 07-05 22:48:17 [core.py:70] Initializing a V1 LLM engine (v0.9.1) with config: model='Qwen/Qwen2.5-Coder-32B-Instruct', speculative_config=None, tokenizer='Qwen/Qwen2.5-Coder-32B-Instruct', skip_tokenizer_init=False, tokenizer_mode=auto, revision=None, override_neuron_config={}, tokenizer_revision=None, trust_remote_code=False, dtype=torch.bfloat16, max_seq_len=32768, download_dir=None, load_format=LoadFormat.AUTO, tensor_parallel_size=4, pipeline_parallel_size=1, disable_custom_all_reduce=False, quantization=None, enforce_eager=False, kv_cache_dtype=auto, device_config=cuda, decoding_config=DecodingConfig(backend='auto', disable_fallback=False, disable_any_whitespace=False, disable_additional_properties=False, reasoning_backend=''), observability_config=ObservabilityConfig(show_hidden_metrics_for_version=None, otlp_traces_endpoint=None, collect_detailed_traces=None), seed=0, served_model_name=Qwen/Qwen2.5-Coder-32B-Instruct, num_scheduler_steps=1, multi_step_stream_outputs=True, enable_prefix_caching=True, chunked_prefill_enabled=True, use_async_output_proc=True, pooler_config=None, compilation_config={"level":3,"debug_dump_path":"","cache_dir":"","backend":"","custom_ops":["none"],"splitting_ops":