vLLM Configuration in MinerU#
MinerU's VLM backend (-b vlm-engine) supports two vLLM inference modes: vllm-engine (synchronous vllm.LLM) and vllm-async-engine (asynchronous vllm.AsyncLLM). Both are initialized inside ModelSingleton.get_model(), which applies device-specific overrides, sets conservative defaults, and passes all remaining kwargs directly to the vLLM engine.
Key Source Files#
| File | Role |
|---|---|
mineru/backend/vlm/vlm_analyze.py | Engine initialization, ModelSingleton, kwargs routing |
mineru/backend/vlm/utils.py | mod_kwargs_by_device_type(), set_default_gpu_memory_utilization(), enable_custom_logits_processors() |
mineru/model/vlm/vllm_server.py | vLLM server launcher wrapping vllm serve |
mineru/utils/cli_parser.py | Parses arbitrary CLI flags into Python kwargs |
Initialization Flow#
When ModelSingleton.get_model() runs for a vLLM backend :
- Strip non-vLLM kwargs —
batch_size,max_concurrency,http_timeout,server_headers,max_retries,retry_backoff_factorare removed before reaching vLLM . - Apply device-type overrides —
mod_kwargs_by_device_type()injects hardware-specific params driven by theMINERU_VLLM_DEVICEenv var. - Set defaults —
gpu_memory_utilizationandmodelpath are injected if absent . - Inject logits processors —
enable_custom_logits_processors()conditionally addsMinerULogitsProcessor. - Forward to vLLM — remaining kwargs go directly to
vllm.LLM(**kwargs)orAsyncEngineArgs(**kwargs).
Device-Specific Parameters (MINERU_VLLM_DEVICE)#
_get_device_config() maps the MINERU_VLLM_DEVICE environment variable to a config dict applied via mod_kwargs_by_device_type(). Overrides are only injected if the caller has not already set the key.
MINERU_VLLM_DEVICE | Parameters Injected |
|---|---|
corex | compilation_config: cudagraph_mode=FULL_DECODE_ONLY, level=0 |
kxpu | compilation_config (custom splitting_ops), block_size=128, dtype=float16, distributed_executor_backend=mp, enable_chunked_prefill=False, enable_prefix_caching=False |
In server mode (vllm_server.py), False boolean overrides for enable-chunked-prefill and enable-prefix-caching are translated to --no-<flag> CLI arguments .
For async_engine, compilation_config is converted from a dict to a CompilationConfig object ; for sync_engine it is passed as a plain dict.
GPU Memory Utilization Default#
set_default_gpu_memory_utilization() returns :
- 0.5 — default for most configurations
- 0.7 — when vLLM ≥ 0.11.0 and VRAM ≤ 8 GB
Applied to all vLLM backends and vllm_server.py unless the caller supplies gpu_memory_utilization explicitly .
Prefix Caching and Sampling Determinism#
Prefix caching is on by default in vLLM and MinerU does not disable it globally — only the kxpu device config opts out .
Known determinism issue: In long-lived API deployments using vLLM 0.11.0 V1 engine on NVIDIA GPU, the first request for a given PDF returns correct output, but subsequent identical requests produce inconsistent results (e.g., missing images in table HTML). Disabling prefix caching restores per-request consistency .
MinerU does not set vLLM sampling parameters (temperature, seed, use_beam_search, etc.) — these are fully delegated to vLLM's defaults.
Custom Logits Processors#
enable_custom_logits_processors() enables MinerULogitsProcessor when all of the following hold :
- A CUDA/NPU/GCU/MUSA/MLU/SDAA device is available
VLLM_USE_V1 != 0- vLLM ≥ 0.10.1
- Compute capability ≥ 8.0, or vLLM ≥ 0.10.2 (which relaxes the CC requirement)
Set VLLM_USE_V1=0 to force-disable custom logits processors.
Passing Custom kwargs to vLLM#
Any valid vllm.LLM constructor parameter can be forwarded through three entry points:
- Python API: Pass kwargs to
ModelSingleton().get_model(),doc_analyze(), oraio_doc_analyze(). - CLI / FastAPI: Unknown flags (e.g.,
--enable-prefix-caching false,--gpu-memory-utilization 0.8) are parsed byparse_unknown_args(), which normalizes dashes to underscores and coerces values tobool | int | float | str. - vLLM server:
vllm_server.pyintercepts--model,--port,--gpu-memory-utilization, and--logits-processors, then passes everything else tovllm serve.
Known Issues#
| Issue | Context | Workaround |
|---|---|---|
| Parsing hangs at "Layout Predict: 0%" on Ascend 910B NPU | Prefix caching + chunked prefill require block_size=128; not set automatically for Ascend | Set MINERU_VLLM_DEVICE=kxpu or manually pass enable_prefix_caching=False block_size=128 |
| Non-deterministic results on repeated requests | vLLM prefix caching (v0.11.0 V1 engine, NVIDIA GPU) causes inconsistent outputs after first request | Pass --enable-prefix-caching false (server) or enable_prefix_caching=False (engine) |