Rename: --hooks to --forward-hooks (#13994)
This commit is contained in:
@@ -8,9 +8,9 @@ import torch.nn as nn
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def register_hooks(model: nn.Module, hook_specs: List[dict[str, Any]]) -> None:
|
||||
def register_forward_hooks(model: nn.Module, hook_specs: List[dict[str, Any]]) -> None:
|
||||
"""
|
||||
hook_specs is a list of dicts from server_args.hooks.
|
||||
hook_specs is a list of dicts from server_args.forward_hooks.
|
||||
Attaches forward hooks to the matching modules.
|
||||
"""
|
||||
name_to_module = dict(model.named_modules())
|
||||
|
||||
@@ -122,7 +122,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.hook_manager import register_forward_hooks
|
||||
from sglang.srt.model_executor.npu_graph_runner import NPUGraphRunner
|
||||
from sglang.srt.model_executor.piecewise_cuda_graph_runner import (
|
||||
PiecewiseCudaGraphRunner,
|
||||
@@ -535,8 +535,8 @@ class ModelRunner:
|
||||
self.graph_mem_usage = 0
|
||||
self.init_attention_backend()
|
||||
|
||||
if server_args.hooks:
|
||||
register_hooks(self.model, server_args.hooks)
|
||||
if server_args.forward_hooks:
|
||||
register_forward_hooks(self.model, server_args.forward_hooks)
|
||||
|
||||
# auxiliary hidden capture mode. TODO: expose this to server args?
|
||||
if self.spec_algorithm.is_eagle3() and not self.is_draft_worker:
|
||||
|
||||
@@ -588,7 +588,7 @@ class ServerArgs:
|
||||
mm_enable_dp_encoder: bool = False
|
||||
|
||||
# For forward hooks
|
||||
hooks: Optional[List[dict[str, Any]]] = None
|
||||
forward_hooks: Optional[List[dict[str, Any]]] = None
|
||||
|
||||
def __post_init__(self):
|
||||
"""
|
||||
@@ -3870,10 +3870,10 @@ class ServerArgs:
|
||||
|
||||
# For registering hooks
|
||||
parser.add_argument(
|
||||
"--hooks",
|
||||
"--forward-hooks",
|
||||
type=json_list_type,
|
||||
default=None,
|
||||
help="The hooks to be attached.",
|
||||
default=ServerArgs.forward_hooks,
|
||||
help="JSON-formatted forward hook specifications to attach to the model.",
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user