﻿# vLLM Profiler: admission-time instrumentation and worker traces

The openshift-psap profiler injects a worker hook when Kubernetes creates a pod. Check call windows, vLLM import compatibility and instrumentation cost before interpreting traces.

Author: Retrivium editorial team
Updated: 2026-11-05
Canonical URL: https://retrivium.ai/journal/vllm-profiler-admission-hook-worker-trace-boundaries/
Language: en

The [openshift-psap/vllm-profiler repository](https://github.com/openshift-psap/vllm-profiler) describes a concrete way to collect CPU and CUDA activity inside Kubernetes vLLM workers. A mutating admission webhook supplies an import hook rather than requiring an edited vLLM image. The important boundary is pod creation: this mechanism should not be described as retroactively attaching instrumentation to every already-running process.

## Admission determines which workers receive the hook

The documented webhook handles Pod CREATE operations, selects a namespace and labels, and mounts profiling material from a ConfigMap. Python loads the injected `sitecustomize.py`, which intercepts relevant imports and wraps `Worker.execute_model`. Several configured target labels use OR logic, so matching any of them can select a pod.

That selection rule belongs in the experiment record. Otherwise an operator may compare a traced worker with an apparently equivalent worker that never received the hook. The README also says existing pods need restarting to pick up changed configuration. “No application source changes” does not imply that any existing process immediately adopts a new profiling setup.

## A call window is not a request window

The [implementation](https://github.com/openshift-psap/vllm-profiler/blob/main/sitecustomize.py) tracks configured ranges of calls to the wrapped method and exports Chrome trace JSON. Rank and process identity help distinguish distributed worker artifacts. Multiple windows can select different intervals rather than recording the entire run.

A serving iteration may involve work for several requests, while one request can span many iterations. Consequently, a method-call counter cannot be interpreted as a count of completed requests or output tokens. The [PyTorch schedule guide](/journal/guide-perf-pytorch-profiler-schedule/) explains why the application unit needs an explicit mapping. A trace also needs evidence that the intended window was reached; silence before its start is not evidence of idle execution.

## Compatibility depends on actual import targets

The checked code lists `vllm.v1.worker.gpu_worker` for the newer path associated with 0.12 and later, and `vllm.worker.worker` for 0.11.x. Those comments describe the project’s intended compatibility paths, not a guarantee that every future vLLM release retains the same class and method.

The code checks whether the target class and method exist and logs successful wrapping or warnings. Preserve those logs alongside the exact container and vLLM version. A healthy inference endpoint alone does not prove that the hook intercepted the worker. This matters particularly when an engine update moves implementation details while preserving its public serving API.

## Trace collection needs its own cost boundary

The README describes an integration test using `facebook/opt-125m`, a single request generating 200 tokens and verification of profiler output in logs. That is useful instrumentation acceptance, not a reported production overhead or model-accuracy comparison. It does not establish how a large distributed workload behaves under detailed collection.

The [PyTorch reference](https://docs.pytorch.org/docs/2.15/profiler.html) warns that shape and stack collection add overhead; retaining tensor references for shapes can affect optimizations and copies. A proposed local comparison should therefore preserve activity selection, shapes, stacks, memory settings, export behavior and call ranges, then compare equivalent uninstrumented and instrumented traffic. Disabling file export does not remove all profiling work. Following the [inference benchmark protocol](/journal/inference-benchmark-method/) keeps diagnostic artifacts separate from claims about ordinary serving performance. The repository provides a collection mechanism whose coverage and cost remain properties of the specific deployment.
