Skip to content

fix(openai,mmlupro,vllm): handle multi-EOS lists, SDK request fields, and tokenizer outputs (#4014) - #4029

Merged
Qubitium merged 1 commit into
ModelCloud:mainfrom
Prajwal7-2002:fix/openai-server-mmlupro-compat
Nov 14, 2026
Merged

Qubitium merged 1 commit into
ModelCloud:mainfrom
Prajwal7-2002:fix/openai-server-mmlupro-compat

Conversation

@Prajwal7-2002

Copy link
Copy Markdown
Contributor

Summary

Fixes #4014

Addresses the audit findings identified on main:

  1. MMLU-Pro prompt length calculation crashed with TypeError on Hugging Face tokenizers returning 1D list[int].
  2. OpenAI server dropped the model's multi-EOS list from generation_config.eos_token_id (e.g. Llama-3 <|eom_id|> and <|end_of_text|>) in favor of a single tokenizer scalar, and _sequence_end only checked a single token ID.
  3. OpenAI SDK request fields (max_completion_tokens, stream, seed) were silently ignored or defaulted, and OpenAiRequest accepted unknown fields without validation.
  4. serve(host="::1") was rejecting all loopback IPv6 requests due to bracketed Host: [::1] check in Starlette's TrustedHostMiddleware.
  5. In addition, stop_strings was dropped when vLLM / SGLang generation adapters were invoked.

What Changed

  • gptqmodel/utils/mmlupro.py:
    • Robustly compute prompt length whether tokenizer output input_ids is a Python 1D list of ints, a nested list of lists, or a PyTorch tensor.
  • gptqmodel/utils/openai_server.py:
    • Added _resolve_eos_token_ids to collect the complete EOS list from generation_config.eos_token_id and tokenizer.
    • Updated _sequence_end to check membership against the full EOS set (int or collection) so sequences stop cleanly on special tokens like <|eom_id|>.
    • Added max_completion_tokens: int | None = None to OpenAiRequest, aliasing to max_tokens (falling back to 256 default).
    • Validated temperature >= 0.0 and enforced model_config = {"extra": "forbid"} to reject unexpected fields with HTTP 422.
    • Rejected stream=True with HTTP 400 ("Streaming is not currently supported.").
    • Honored seed with torch.manual_seed and forwarded to runtime adapters when present.
    • Added bracketed "[::1]" to _allowed_hosts_for to permit IPv6 loopback requests through TrustedHostMiddleware.
  • gptqmodel/utils/vllm.py & gptqmodel/utils/sglang.py:
    • Forwarded stop_strings into the stop sampling parameter so prompt delimiters (such as "Question:") stop generation when using external runtime adapters.
  • Tests:
    • tests/test_mmlupro_prompt_budget.py: Updated _FixedTokenizer to return a Python list[int] by default and added parameterized test verifying both list and tensor tokenizers pass without TypeError.
    • tests/test_openai_server_contract.py: Added regression tests for stream=True rejection (400), max_completion_tokens aliasing, negative temperature (422), extra="forbid" (422), seed, multi-EOS lists stopping on <|eom_id|>, and bracketed IPv6 loopback host "[::1]".
    • tests/test_vllm_generate_alignment.py & tests/test_sglang_utils.py: Added tests verifying stop_strings is correctly converted into stop.

Tests

  • Unit tests have been executed and passed, or the reason they are not applicable is documented.
  • I added a new simple/fast unit test for this change, or documented why that is not applicable.
pytest tests/test_mmlupro_prompt_budget.py tests/test_openai_server_contract.py tests/test_vllm_generate_alignment.py tests/test_sglang_utils.py
# 98 passed in 9.42s

Linting:

ruff check gptqmodel/utils/mmlupro.py gptqmodel/utils/openai_server.py gptqmodel/utils/sglang.py gptqmodel/utils/vllm.py tests/test_mmlupro_prompt_budget.py tests/test_openai_server_contract.py tests/test_sglang_utils.py tests/test_vllm_generate_alignment.py
# All checks passed!

Model Support / Module Plan

Not applicable (bug fix and API server compatibility; no new model architecture added).

Logic Flow Documentation

Not applicable (preserves existing routing while fixing EOS token set checking, host validation, and request parsing).

Review Requirements

  • Reviewed this PR.
  • Checked that the code matches existing project structure, APIs, and conventions.
  • Avoided unnecessary monkeypatching and used the project's normal extension points where possible.
  • Minimized and compacted the impacted code surface.
  • Considered and eliminated potential regressions.

Kernel Accuracy Requirements

Not applicable (no changes to quantization or dequantization kernels).

Notes

None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants