Adding user defined hooks support (#13217)

This commit is contained in:
Carlo Mussolini
2025-11-17 15:07:37 +00:00
committed by GitHub
parent 15db5497d3
commit df56139226
7 changed files with 554 additions and 1 deletions

View File

@@ -22,7 +22,7 @@ import logging
import os
import random
import tempfile
from typing import Dict, List, Literal, Optional, Union
from typing import Any, Dict, List, Literal, Optional, Union
import orjson
@@ -391,6 +391,7 @@ class ServerArgs:
speculative_token_map: Optional[str] = None
speculative_attention_mode: str = "prefill"
speculative_moe_runner_backend: Optional[str] = None
# For ngram only
speculative_ngram_min_match_window_size: int = 1
speculative_ngram_max_match_window_size: int = 12
@@ -577,6 +578,9 @@ class ServerArgs:
decrypted_config_file: Optional[str] = None
decrypted_draft_config_file: Optional[str] = None
# For forward hooks
hooks: Optional[List[dict[str, Any]]] = None
def __post_init__(self):
"""
Orchestrates the handling of various server arguments, ensuring proper configuration and validation.
@@ -3725,6 +3729,14 @@ class ServerArgs:
help="The path of the decrypted draft config file.",
)
# For registering hooks
parser.add_argument(
"--hooks",
type=json_list_type,
default=None,
help="The hooks to be attached.",
)
@classmethod
def from_cli_args(cls, args: argparse.Namespace):
args.tp_size = args.tensor_parallel_size