global_config.py 1.46 KB
Newer Older
Lianmin Zheng's avatar
Lianmin Zheng committed
1
2
"""Global configurations"""

3
4
import os

Lianmin Zheng's avatar
Lianmin Zheng committed
5
6

class GlobalConfig:
7
8
9
10
11
12
13
    """
    Store some global constants.

    See also python/sglang/srt/managers/schedule_batch.py::global_server_args_dict, which stores
    many global runtime arguments as well.
    """

Lianmin Zheng's avatar
Lianmin Zheng committed
14
15
16
17
18
19
    def __init__(self):
        # Verbosity level
        # 0: do not output anything
        # 2: output final text after every run
        self.verbosity = 0

20
        # Default backend of the language
Lianmin Zheng's avatar
Lianmin Zheng committed
21
22
        self.default_backend = None

23
        # Runtime constants: New generation token ratio estimation
24
25
26
27
28
29
30
31
32
        self.default_init_new_token_ratio = float(
            os.environ.get("SGLANG_INIT_NEW_TOKEN_RATIO", 0.7)
        )
        self.default_min_new_token_ratio_factor = float(
            os.environ.get("SGLANG_MIN_NEW_TOKEN_RATIO_FACTOR", 0.14)
        )
        self.default_new_token_ratio_decay_steps = float(
            os.environ.get("SGLANG_NEW_TOKEN_RATIO_DECAY_STEPS", 600)
        )
33

Mingyi's avatar
Mingyi committed
34
        # Runtime constants: others
Liangsheng Yin's avatar
Liangsheng Yin committed
35
        self.retract_decode_steps = 20
36
37
38
        self.flashinfer_workspace_size = os.environ.get(
            "FLASHINFER_WORKSPACE_SIZE", 384 * 1024 * 1024
        )
39
40

        # Output tokenization configs
Lianmin Zheng's avatar
Lianmin Zheng committed
41
        self.skip_special_tokens_in_output = True
42
        self.spaces_between_special_tokens_in_out = True
Lianmin Zheng's avatar
Lianmin Zheng committed
43

44
        # Language frontend interpreter optimization configs
45
        self.enable_precache_with_tracing = True
Lianmin Zheng's avatar
Lianmin Zheng committed
46
47
        self.enable_parallel_encoding = True

48

Lianmin Zheng's avatar
Lianmin Zheng committed
49
global_config = GlobalConfig()