OpenLLM developer on retainer: runner.async_generate() ignores per-request llm_config in vLLM backend — SamplingParams built from startup defaults not caller config — all tenants receive temperature=0.7 regardless — $68,000 — 2 months

OpenLLM 0.4.0; vLLM 0.3.2; Python 3.11; CUDA 12.3; 4× A10G 24GB; Mistral-7B-Instruct-v0.2; runner.async_generate(prompt, llm_config=config) constructs SamplingParams from self.llm.config.generation_config (startup defaults) not from per-request llm_config; sync runner.generate() works correctly; three-tenant API (creative: temp=0.9; factual: temp=0.1; code: temp=0.2) silently collapses to temp=0.7 for all; fix: use sync generate() or upgrade to OpenLLM 0.5.x • Greenfield OpenLLM API Ltd. (5-person; 2 months; 2.0h)

Greenfield OpenLLM API Ltd. is a 5-person AI startup that built a multi-tenant LLM inference API on top of OpenLLM 0.4.0 with the vLLM backend. Their product serves three tenant categories — creative writing agencies, factual research analysts, and code-assist integrations — each with distinct quality requirements. Creative writing tenants need high-temperature, exploratory output (temperature=0.9, max_new_tokens=1024, top_p=0.95). Factual research analysts need low-temperature, deterministic output (temperature=0.1, max_new_tokens=256, top_p=0.5). Code completion integrations need conservative sampling (temperature=0.2, max_new_tokens=512, top_p=0.6). The team built their API service using OpenLLM’s Python runner API, using runner.async_generate(prompt, llm_config=tenant_config) to serve all three categories from a single Mistral-7B-Instruct-v0.2 deployment across 4× A10G 24GB GPUs. The vLLM continuous batching backend was chosen for its throughput at 400+ concurrent requests per hour.

Two months after launch, three creative writing clients canceled, citing “repetitive, predictable output.” The factual research team was generating outputs with plausible-sounding but incorrect numbers at a rate higher than expected from a 7B model. Code completions had a 23% higher syntax error rate than the team’s internal benchmarks predicted. The team spent two months investigating: they rewrote prompts, tried different system message formats, tested an alternative 13B model, and switched from fp16 to int8 quantization. Nothing improved. All three problems persisted with equal severity regardless of model size or precision.

The root cause: runner.async_generate() in OpenLLM 0.4.0’s vLLM backend path constructs vllm.SamplingParams from the LLMRunner’s cached generation_config attribute — set at server startup from openllm start --temperature 0.7 --max-new-tokens 512 (or the model card defaults if no flags were specified). The llm_config argument passed per-request is accepted by the method signature and forwarded through the BentoML runner serialization layer, but it is never used to override the SamplingParams before the vLLM engine call. The synchronous runner.generate() path correctly calls llm_config.to_generation_config().to_vllm_sampling_params() and passes those parameters to the engine. The async path — introduced with vLLM’s AsyncLLMEngine integration in the 0.4.0 refactor — uses a separate code route where this forwarding was not implemented.

# api_service.py — Greenfield OpenLLM API Ltd.
# OpenLLM 0.4.0; vLLM 0.3.2; Python 3.11

import openllm
from openllm import LLMConfig

llm = openllm.LLM(
    "mistralai/Mistral-7B-Instruct-v0.2",
    backend="vllm",
    generation_config=LLMConfig(temperature=0.7, max_new_tokens=512),  # server defaults
)
runner = llm.to_runner()

# Per-tenant generation configs
TENANT_CONFIGS = {
    "creative": LLMConfig(temperature=0.9, max_new_tokens=1024, top_p=0.95),
    "factual":  LLMConfig(temperature=0.1, max_new_tokens=256,  top_p=0.5),
    "code":     LLMConfig(temperature=0.2, max_new_tokens=512,  top_p=0.6),
}

# Async streaming endpoint — used for all three tenant categories
async def stream_response(tenant_id: str, prompt: str):
    config = TENANT_CONFIGS[tenant_id]

    # Bug: OpenLLM 0.4.0 async path ignores llm_config argument
    # Internally: sampling_params = SamplingParams(**runner.llm.config.generation_config.model_dump())
    # → temperature=0.7, max_new_tokens=512, top_p=1.0 (server startup values)
    # llm_config argument is serialized and transmitted to runner but never
    # used to construct SamplingParams before engine.generate() is called
    async for chunk in runner.async_generate(prompt, llm_config=config):
        yield chunk.text

# Effective behavior for all three tenants:
#   temperature=0.7    (creative wanted 0.9 — too deterministic, repetitive)
#   max_new_tokens=512 (factual wanted 256  — verbose, over-generates)
#   top_p=1.0          (all wanted lower top_p — nucleus too wide)
#
# Sync path works correctly (not used here because streaming was required):
#   result = runner.generate(prompt, llm_config=config)
#   # → SamplingParams(temperature=config.temperature, max_tokens=config.max_new_tokens)
#   # → vLLM receives correct per-request params

During the retainer engagement, the diagnostic required only one test: calling the async endpoint with temperature=0.01 (nearly deterministic) and running the same open-ended creative prompt ten times. All ten responses were nearly identical — a correctly operating temperature=0.01. Then the same prompt was sent via the sync runner.generate() endpoint with temperature=0.01 — also deterministic. Then the async endpoint was tested with temperature=1.4 — outputs were still fluent and coherent, confirming the high temperature was not reaching vLLM. A temporary patch added print logging inside the async runner’s SamplingParams construction: the printed SamplingParams showed temperature=0.7 for every request regardless of the caller’s config. The llm_config argument arrived correctly at the runner (confirmed by printing it at the method entry point), but was dropped before the vLLM engine call.

Fix: use sync generate() or upgrade to OpenLLM 0.5.x

# Fix 1: Replace async_generate() with sync generate() per request
# (sacrifices streaming but gets correct per-request sampling params)

def handle_request_sync(tenant_id: str, prompt: str) -> str:
    config = TENANT_CONFIGS[tenant_id]
    # Sync path correctly calls llm_config.to_generation_config().to_vllm_sampling_params()
    return runner.generate(prompt, llm_config=config)

# Fix 2: Upgrade to OpenLLM >= 0.5.x
# openllm >= 0.5.0 async path:
#   _generate_stream() now extracts SamplingParams from the per-request llm_config:
#   sampling_params = request_llm_config.to_generation_config().to_vllm_sampling_params()
#   engine.generate(prompt, sampling_params, request_id=uuid4().hex)

# Fix 3: Bypass OpenLLM runner; call vLLM directly with per-request SamplingParams
from vllm import AsyncLLMEngine, SamplingParams as VllmSamplingParams
from uuid import uuid4

async def stream_vllm_direct(tenant_id: str, prompt: str, engine: AsyncLLMEngine):
    cfg = TENANT_CONFIGS[tenant_id]
    sp = VllmSamplingParams(
        temperature=cfg.temperature,
        max_tokens=cfg.max_new_tokens,
        top_p=cfg.top_p,
    )
    request_id = uuid4().hex
    async for output in engine.generate(prompt, sp, request_id=request_id):
        yield output.outputs[0].text

# Fix 4: Verification — add per-request assertions before shipping
import logging
logger = logging.getLogger(__name__)

async def stream_with_verification(tenant_id: str, prompt: str):
    config = TENANT_CONFIGS[tenant_id]
    expected_temp = config.temperature
    # In OpenLLM >= 0.5.x: log the actual SamplingParams used for the first request
    # to verify per-request forwarding is working
    logger.info(f"Requesting temperature={expected_temp} for tenant {tenant_id}")
    async for chunk in runner.async_generate(prompt, llm_config=config):
        yield chunk.text

# Results after switching to Fix 3 (vLLM direct):
#   creative tenant: temperature=0.9 (was 0.7) — 3 canceled clients reinstated
#   factual tenant:  temperature=0.1 (was 0.7) — incorrect number rate dropped 78%
#   code tenant:     temperature=0.2 (was 0.7) — syntax error rate normalized
#
#   5 engineers × 2 months × $6,800/month = $68,000

Related retainer posts


Track retainer hours without a client portal

HourTab turns your time-tracker CSV into a public URL your client bookmarks. No login. No portal. CSV in, URL out.

See pricing →