[Env] centralize hicache vars in environ.py (#17204)

This commit is contained in:
shuwenn
2026-02-14 10:02:31 +08:00
committed by GitHub
parent dcea74d63f
commit bd39de7d5e
3 changed files with 6 additions and 3 deletions

View File

@@ -268,6 +268,8 @@ class Envs:
# Hi-Cache
SGLANG_HICACHE_HF3FS_CONFIG_PATH = EnvStr(None)
SGLANG_HICACHE_FILE_BACKEND_STORAGE_DIR = EnvStr(None)
SGLANG_HICACHE_NIXL_BACKEND_STORAGE_DIR = EnvStr(None)
# Mooncake KV Transfer
SGLANG_MOONCAKE_CUSTOM_MEM_POOL = EnvStr(None)

View File

@@ -7,6 +7,7 @@ from typing import Any, List, Optional
import torch
from sglang.srt.environ import envs
from sglang.srt.mem_cache.memory_pool_host import HostKVCache
logger = logging.getLogger(__name__)
@@ -186,7 +187,7 @@ class HiCacheFile(HiCacheStorage):
def __init__(
self, storage_config: HiCacheStorageConfig, file_path: str = "/tmp/hicache"
):
self.file_path = os.getenv("SGLANG_HICACHE_FILE_BACKEND_STORAGE_DIR", file_path)
self.file_path = envs.SGLANG_HICACHE_FILE_BACKEND_STORAGE_DIR.get() or file_path
tp_rank, tp_size, model_name, is_mla_model = (
storage_config.tp_rank,

View File

@@ -1,11 +1,11 @@
import logging
import os
import time
import uuid
from typing import Any, List, Optional, Union
import torch
from sglang.srt.environ import envs
from sglang.srt.mem_cache.hicache_storage import HiCacheStorage, HiCacheStorageConfig
from .nixl_utils import (
@@ -44,7 +44,7 @@ class HiCacheNixl(HiCacheStorage):
plugin = nixlconfig.get_specified_plugin()
# Might be better to be unified across HiCache backends and moved to HiCacheController
file_path = os.getenv("SGLANG_HICACHE_NIXL_BACKEND_STORAGE_DIR", file_path)
file_path = envs.SGLANG_HICACHE_NIXL_BACKEND_STORAGE_DIR.get() or file_path
self.file_manager = (
NixlFileManager(file_path)
if plugin not in NixlBackendSelection.OBJ_PLUGINS