mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-05-25 16:31:18 +08:00
Add VLLM_NVTX_SCOPES_FOR_PROFILING=1 to enable nvtx.annotate scopes (#25501)
Signed-off-by: Corey Lowman <clowman1993@gmail.com>
This commit is contained in:
parent
abad204be6
commit
c85d75cf08
@ -187,6 +187,7 @@ if TYPE_CHECKING:
|
|||||||
VLLM_DISABLE_PAD_FOR_CUDAGRAPH: bool = False
|
VLLM_DISABLE_PAD_FOR_CUDAGRAPH: bool = False
|
||||||
VLLM_GPT_OSS_HARMONY_SYSTEM_INSTRUCTIONS: bool = False
|
VLLM_GPT_OSS_HARMONY_SYSTEM_INSTRUCTIONS: bool = False
|
||||||
VLLM_CUSTOM_SCOPES_FOR_PROFILING: bool = False
|
VLLM_CUSTOM_SCOPES_FOR_PROFILING: bool = False
|
||||||
|
VLLM_NVTX_SCOPES_FOR_PROFILING: bool = False
|
||||||
VLLM_KV_EVENTS_USE_INT_BLOCK_HASHES: bool = True
|
VLLM_KV_EVENTS_USE_INT_BLOCK_HASHES: bool = True
|
||||||
VLLM_OBJECT_STORAGE_SHM_BUFFER_NAME: str = "VLLM_OBJECT_STORAGE_SHM_BUFFER"
|
VLLM_OBJECT_STORAGE_SHM_BUFFER_NAME: str = "VLLM_OBJECT_STORAGE_SHM_BUFFER"
|
||||||
VLLM_DEEPEP_BUFFER_SIZE_MB: int = 1024
|
VLLM_DEEPEP_BUFFER_SIZE_MB: int = 1024
|
||||||
@ -1387,6 +1388,10 @@ environment_variables: dict[str, Callable[[], Any]] = {
|
|||||||
"VLLM_CUSTOM_SCOPES_FOR_PROFILING":
|
"VLLM_CUSTOM_SCOPES_FOR_PROFILING":
|
||||||
lambda: bool(int(os.getenv("VLLM_CUSTOM_SCOPES_FOR_PROFILING", "0"))),
|
lambda: bool(int(os.getenv("VLLM_CUSTOM_SCOPES_FOR_PROFILING", "0"))),
|
||||||
|
|
||||||
|
# Add optional nvtx scopes for profiling, disable to avoid overheads
|
||||||
|
"VLLM_NVTX_SCOPES_FOR_PROFILING":
|
||||||
|
lambda: bool(int(os.getenv("VLLM_NVTX_SCOPES_FOR_PROFILING", "0"))),
|
||||||
|
|
||||||
# Represent block hashes in KV cache events as 64-bit integers instead of
|
# Represent block hashes in KV cache events as 64-bit integers instead of
|
||||||
# raw bytes. Defaults to True for backward compatibility.
|
# raw bytes. Defaults to True for backward compatibility.
|
||||||
"VLLM_KV_EVENTS_USE_INT_BLOCK_HASHES":
|
"VLLM_KV_EVENTS_USE_INT_BLOCK_HASHES":
|
||||||
|
|||||||
@ -375,8 +375,22 @@ def report_usage_stats(
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
_PROFILER_FUNC = None
|
||||||
|
|
||||||
|
|
||||||
def record_function_or_nullcontext(name: str) -> AbstractContextManager:
|
def record_function_or_nullcontext(name: str) -> AbstractContextManager:
|
||||||
|
global _PROFILER_FUNC
|
||||||
|
|
||||||
|
# fast path assume it is set
|
||||||
|
if _PROFILER_FUNC is not None:
|
||||||
|
return _PROFILER_FUNC(name)
|
||||||
|
|
||||||
|
func = contextlib.nullcontext
|
||||||
if envs.VLLM_CUSTOM_SCOPES_FOR_PROFILING:
|
if envs.VLLM_CUSTOM_SCOPES_FOR_PROFILING:
|
||||||
return record_function(name)
|
func = record_function
|
||||||
else:
|
elif envs.VLLM_NVTX_SCOPES_FOR_PROFILING:
|
||||||
return contextlib.nullcontext()
|
import nvtx
|
||||||
|
func = nvtx.annotate
|
||||||
|
|
||||||
|
_PROFILER_FUNC = func
|
||||||
|
return func(name)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user