Add Triton recompile detection (#45631)

Signed-off-by: Thien Tran <gau.nernst@yahoo.com.sg>
This commit is contained in:
Thien Tran
2026-06-16 18:25:28 +08:00
committed by GitHub
parent 3f1ff1ff14
commit b2cfae777d
6 changed files with 81 additions and 15 deletions
+4
View File
@@ -76,6 +76,10 @@ class ObservabilityConfig:
This includes number of context/generation requests and tokens
and the elapsed cpu time for the iteration."""
jit_monitor_verbose: bool = False
"""Log every Triton JIT compile with its dispatch key. This can emit many
logs and add overhead, so it is intended for debugging."""
@cached_property
def collect_model_forward_time(self) -> bool:
"""Whether to collect model forward time for the request."""
+6
View File
@@ -637,6 +637,7 @@ class EngineArgs:
enable_logging_iteration_details: bool = (
ObservabilityConfig.enable_logging_iteration_details
)
jit_monitor_verbose: bool = ObservabilityConfig.jit_monitor_verbose
enable_mm_processor_stats: bool = ObservabilityConfig.enable_mm_processor_stats
scheduling_policy: SchedulerPolicy = SchedulerConfig.policy
scheduler_cls: str | type[object] | None = SchedulerConfig.scheduler_cls
@@ -1357,6 +1358,10 @@ class EngineArgs:
"--enable-logging-iteration-details",
**observability_kwargs["enable_logging_iteration_details"],
)
observability_group.add_argument(
"--jit-monitor-verbose",
**observability_kwargs["jit_monitor_verbose"],
)
# Scheduler arguments
scheduler_kwargs = get_kwargs(SchedulerConfig)
@@ -2202,6 +2207,7 @@ class EngineArgs:
enable_mfu_metrics=self.enable_mfu_metrics,
enable_mm_processor_stats=self.enable_mm_processor_stats,
enable_logging_iteration_details=self.enable_logging_iteration_details,
jit_monitor_verbose=self.jit_monitor_verbose,
)
# Compilation config overrides
+30 -8
View File
@@ -8,6 +8,10 @@ event indicates a cache miss or unexpected input shape that causes a
latency spike. This module registers hooks in the Triton runtime to
detect and log such events so they can be investigated.
Set ``--jit-monitor-verbose`` to log every Triton JIT compile with its
dispatch key. This is intentionally opt-in because it can emit many logs and
add overhead.
Currently monitors:
- Triton ``@triton.autotune`` cache misses (via ``knobs.autotuning.print``)
- Triton ``@triton.jit`` first-time compilations
@@ -22,6 +26,7 @@ from vllm.triton_utils.importing import HAS_TRITON
logger = init_logger(__name__)
_active: bool = False
_verbose: bool = False
def is_active() -> bool:
@@ -29,7 +34,7 @@ def is_active() -> bool:
return _active
def activate() -> None:
def activate(*, verbose: bool = False) -> None:
"""Enable JIT compilation monitoring after warmup.
Call once per worker process at the end of
@@ -43,10 +48,11 @@ def activate() -> None:
their environment, autotuning printing is left disabled; the JIT
compilation hook is still registered regardless.
"""
global _active
global _active, _verbose
if _active:
return
_active = True
_verbose = verbose
_setup_triton_autotuning_print()
_setup_triton_jit_hook()
@@ -84,6 +90,27 @@ def _setup_triton_autotuning_print() -> None:
# ------------------------------------------------------------------
def _log_jit_compile(fn_name: str, kwargs) -> None:
if _verbose:
compile_info = kwargs.get("compile")
if not isinstance(compile_info, dict):
compile_info = {}
logger.warning(
"Triton %sJIT compilation during inference: %s (key=%s).",
"autotune/warmup candidate " if kwargs.get("warmup") else "kernel ",
fn_name,
compile_info.get("key") or kwargs.get("key"),
)
return
logger.warning_once(
"Triton kernel JIT compilation during inference: %s. "
"This causes a latency spike; consider extending warmup "
"to cover this shape/config.",
fn_name,
)
def _setup_triton_jit_hook() -> None:
"""Register a ``jit_post_compile_hook`` that warns on compilation."""
if not HAS_TRITON:
@@ -100,12 +127,7 @@ def _setup_triton_jit_hook() -> None:
# pre-existing hook unchanged.
fn = kwargs.get("fn")
fn_name = getattr(fn, "name", "<unknown>")
logger.warning_once(
"Triton kernel JIT compilation during inference: %s. "
"This causes a latency spike; consider extending warmup "
"to cover this shape/config.",
fn_name,
)
_log_jit_compile(fn_name, kwargs)
if existing_hook is not None:
return existing_hook(**kwargs)
return None
+3 -1
View File
@@ -737,7 +737,9 @@ class Worker(WorkerBase):
activate as activate_triton_jit_monitor,
)
activate_triton_jit_monitor()
activate_triton_jit_monitor(
verbose=self.observability_config.jit_monitor_verbose
)
# Freeze the worker heap so the GC won't scan static objects
# (model weights, KV caches, CUDA graphs) during inference.