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:
+17
-3
@@ -375,8 +375,22 @@ def report_usage_stats(
|
||||
})
|
||||
|
||||
|
||||
_PROFILER_FUNC = None
|
||||
|
||||
|
||||
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:
|
||||
return record_function(name)
|
||||
else:
|
||||
return contextlib.nullcontext()
|
||||
func = record_function
|
||||
elif envs.VLLM_NVTX_SCOPES_FOR_PROFILING:
|
||||
import nvtx
|
||||
func = nvtx.annotate
|
||||
|
||||
_PROFILER_FUNC = func
|
||||
return func(name)
|
||||
|
||||
Reference in New Issue
Block a user