IPv6 support (#3949)
Signed-off-by: Brayden Zhong <b8zhong@uwaterloo.ca>
This commit is contained in:
@@ -24,6 +24,7 @@ from typing import List, Optional
|
||||
from sglang.srt.hf_transformers_utils import check_gguf_file
|
||||
from sglang.srt.reasoning_parser import ReasoningParser
|
||||
from sglang.srt.utils import (
|
||||
configure_ipv6,
|
||||
get_amdgpu_memory_capacity,
|
||||
get_device,
|
||||
get_hpu_memory_capacity,
|
||||
@@ -52,7 +53,7 @@ class ServerArgs:
|
||||
dtype: str = "auto"
|
||||
kv_cache_dtype: str = "auto"
|
||||
quantization: Optional[str] = None
|
||||
quantization_param_path: nullable_str = None
|
||||
quantization_param_path: Optional[str] = None
|
||||
context_length: Optional[int] = None
|
||||
device: Optional[str] = None
|
||||
served_model_name: Optional[str] = None
|
||||
@@ -140,7 +141,7 @@ class ServerArgs:
|
||||
|
||||
# Double Sparsity
|
||||
enable_double_sparsity: bool = False
|
||||
ds_channel_config_path: str = None
|
||||
ds_channel_config_path: Optional[str] = None
|
||||
ds_heavy_channel_num: int = 32
|
||||
ds_heavy_token_num: int = 256
|
||||
ds_heavy_channel_type: str = "qk"
|
||||
@@ -173,7 +174,7 @@ class ServerArgs:
|
||||
enable_memory_saver: bool = False
|
||||
allow_auto_truncate: bool = False
|
||||
enable_custom_logit_processor: bool = False
|
||||
tool_call_parser: str = None
|
||||
tool_call_parser: Optional[str] = None
|
||||
enable_hierarchical_cache: bool = False
|
||||
hicache_ratio: float = 2.0
|
||||
enable_flashinfer_mla: bool = False
|
||||
@@ -1205,8 +1206,12 @@ class PortArgs:
|
||||
# DP attention. Use TCP + port to handle both single-node and multi-node.
|
||||
if server_args.nnodes == 1 and server_args.dist_init_addr is None:
|
||||
dist_init_addr = ("127.0.0.1", server_args.port + ZMQ_TCP_PORT_DELTA)
|
||||
elif server_args.dist_init_addr.startswith("["): # ipv6 address
|
||||
port_num, host = configure_ipv6(server_args.dist_init_addr)
|
||||
dist_init_addr = (host, str(port_num))
|
||||
else:
|
||||
dist_init_addr = server_args.dist_init_addr.split(":")
|
||||
|
||||
assert (
|
||||
len(dist_init_addr) == 2
|
||||
), "please provide --dist-init-addr as host:port of head node"
|
||||
|
||||
@@ -1630,6 +1630,38 @@ def is_valid_ipv6_address(address: str) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def configure_ipv6(dist_init_addr):
|
||||
addr = dist_init_addr
|
||||
end = addr.find("]")
|
||||
if end == -1:
|
||||
raise ValueError("invalid IPv6 address format: missing ']'")
|
||||
|
||||
host = addr[: end + 1]
|
||||
|
||||
# this only validates the address without brackets: we still need the below checks.
|
||||
# if it's invalid, immediately raise an error so we know it's not formatting issues.
|
||||
if not is_valid_ipv6_address(host[1:end]):
|
||||
raise ValueError(f"invalid IPv6 address: {host}")
|
||||
|
||||
port_str = None
|
||||
if len(addr) > end + 1:
|
||||
if addr[end + 1] == ":":
|
||||
port_str = addr[end + 2 :]
|
||||
else:
|
||||
raise ValueError("received IPv6 address format: expected ':' after ']'")
|
||||
|
||||
if not port_str:
|
||||
raise ValueError(
|
||||
"a port must be specified in IPv6 address (format: [ipv6]:port)"
|
||||
)
|
||||
|
||||
try:
|
||||
port = int(port_str)
|
||||
except ValueError:
|
||||
raise ValueError(f"invalid port in IPv6 address: '{port_str}'")
|
||||
return port, host
|
||||
|
||||
|
||||
def rank0_print(msg: str):
|
||||
from sglang.srt.distributed import get_tensor_model_parallel_rank
|
||||
|
||||
|
||||
Reference in New Issue
Block a user