Adding user defined hooks support (#13217)

This commit is contained in:
Carlo Mussolini
2025-11-17 23:07:37 +08:00
committed by GitHub
parent 15db5497d3
commit df56139226
7 changed files with 554 additions and 1 deletions
@@ -112,6 +112,7 @@ from sglang.srt.mem_cache.memory_pool import (
from sglang.srt.model_executor.cpu_graph_runner import CPUGraphRunner
from sglang.srt.model_executor.cuda_graph_runner import CudaGraphRunner
from sglang.srt.model_executor.forward_batch_info import ForwardBatch, PPProxyTensors
from sglang.srt.model_executor.hook_manager import register_hooks
from sglang.srt.model_executor.npu_graph_runner import NPUGraphRunner
from sglang.srt.model_executor.piecewise_cuda_graph_runner import (
PiecewiseCudaGraphRunner,
@@ -497,6 +498,9 @@ class ModelRunner:
self.graph_mem_usage = 0
self.init_attention_backend()
if server_args.hooks:
register_hooks(self.model, server_args.hooks)
# auxiliary hidden capture mode. TODO: expose this to server args?
if self.spec_algorithm.is_eagle3() and not self.is_draft_worker:
# load draft config