[chore]: improve time tracing of model loading process (#15426)

Co-authored-by: Michael Shin <mmshin@nvidia.com>
Co-authored-by: ishandhanani <82981111+ishandhanani@users.noreply.github.com>
This commit is contained in:
Zhongdongming Dai
2026-01-26 19:04:25 -08:00
committed by GitHub
co-authored by Michael Shin ishandhanani
parent 3ad3268e06
commit 1b56a886bb
2 changed files with 21 additions and 1 deletions
@@ -700,6 +700,7 @@ class ModelRunner(ModelRunnerKVCacheMixin):
)
def init_torch_distributed(self):
tic = time.perf_counter()
logger.info("Init torch distributed begin.")
try:
@@ -807,11 +808,13 @@ class ModelRunner(ModelRunnerKVCacheMixin):
logger.warning(msg)
logger.info(
f"Init torch distributed ends. mem usage={(before_avail_memory - local_gpu_memory):.2f} GB"
f"Init torch distributed ends. elapsed={time.perf_counter() - tic:.2f} s, "
f"mem usage={(before_avail_memory - local_gpu_memory):.2f} GB"
)
return min_per_gpu_memory
def load_model(self):
tic_total = time.perf_counter()
before_avail_memory = get_available_gpu_memory(self.device, self.gpu_id)
logger.info(
f"Load weight begin. avail mem={get_available_gpu_memory(self.device, self.gpu_id):.2f} GB"
@@ -957,6 +960,7 @@ class ModelRunner(ModelRunnerKVCacheMixin):
self.weight_load_mem_usage = before_avail_memory - after_avail_memory
logger.info(
f"Load weight end. "
f"elapsed={time.perf_counter() - tic_total:.2f} s, "
f"type={type(self.model).__name__}, "
f"dtype={self.dtype}, "
f"avail mem={after_avail_memory:.2f} GB, "
@@ -1604,6 +1608,8 @@ class ModelRunner(ModelRunnerKVCacheMixin):
def init_attention_backend(self):
"""Init attention kernel backend."""
tic = time.perf_counter()
logger.info("Init attention backend begin.")
if self.server_args.enable_pdmux:
self.attn_backend = self._get_attention_backend(init_new_workspace=True)
self.decode_attn_backend_group = []
@@ -1614,6 +1620,9 @@ class ModelRunner(ModelRunnerKVCacheMixin):
self.attn_backend = TboAttnBackend.init_new(self._get_attention_backend)
else:
self.attn_backend = self._get_attention_backend()
logger.info(
f"Init attention backend end. elapsed={time.perf_counter() - tic:.2f} s"
)
def _get_attention_backend(self, init_new_workspace: bool = False):
"""Init attention kernel backend."""