[perf]Add fused Kimi image preprocessing (#47416)

Signed-off-by: Kevin-XiongC <kevin_xiong1997@outlook.com>
Signed-off-by: Kevin_Xiong <kevin_xiong1997@outlook.com>
Signed-off-by: Isotr0py <Isotr0py@outlook.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Isotr0py <2037008807@qq.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Isotr0py <mozf@mail2.sysu.edu.cn>
Co-authored-by: Isotr0py <Isotr0py@outlook.com>
This commit is contained in:
Kevin_Xiong
2026-07-06 08:46:32 -07:00
committed by GitHub
co-authored by Codex Isotr0py mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Isotr0py Isotr0py
parent f70caef48b
commit 5ad11172b7
5 changed files with 402 additions and 2 deletions
+31 -1
View File
@@ -20,9 +20,10 @@ Currently monitors:
(via ``knobs.runtime.jit_post_compile_hook``)
"""
import contextlib
import functools
import os
from collections.abc import Mapping
from collections.abc import Iterator, Mapping
from typing import Literal
from vllm.logger import init_logger
@@ -287,3 +288,32 @@ def _setup_cutedsl_jit_hook() -> None:
cute.compile = _compile_with_monitor
_cutedsl_hook_installed = True
@contextlib.contextmanager
def numba_workqueue_threading_layer() -> Iterator[None]:
"""Force numba's fork-safe `workqueue` threading layer for this block.
GNU OpenMP (numba's default `omp` threading layer) aborts the process
if a forked child re-enters an OpenMP-active runtime. vLLM forks the
EngineCore subprocess from a process that may already have launched
numba's parallel accelerator, so the first call to any
`@njit(parallel=True)` function must happen under `workqueue` instead.
The threading layer choice is sticky for the life of the process once
launched, so restoring the config on exit does not undo the effect.
"""
import numba
key = "NUMBA_THREADING_LAYER"
previous_env = os.environ.get(key)
previous_config = numba.config.THREADING_LAYER
os.environ[key] = "workqueue"
numba.config.THREADING_LAYER = "workqueue"
try:
yield
finally:
if previous_env is None:
os.environ.pop(key, None)
else:
os.environ[key] = previous_env
numba.config.THREADING_LAYER = previous_config