check the legality of config
(self)
| 2039 | logger.error(f"Failed to extract local devices or ports. Servers may not be able to start properly. {e}") |
| 2040 | |
| 2041 | def check(self): |
| 2042 | """ |
| 2043 | check the legality of config |
| 2044 | """ |
| 2045 | assert self.scheduler_config.max_num_seqs <= 256, ( |
| 2046 | "The parameter `max_num_seqs` is not allowed to exceed 256, " |
| 2047 | f"but now it's {self.scheduler_config.max_num_seqs}." |
| 2048 | ) |
| 2049 | assert self.nnode >= 1, f"nnode: {self.nnode} should no less than 1" |
| 2050 | assert ( |
| 2051 | self.model_config.max_model_len >= 16 |
| 2052 | ), f"max_model_len: {self.model_config.max_model_len} should be larger than 16" |
| 2053 | assert ( |
| 2054 | self.scheduler_config.max_num_seqs >= 1 |
| 2055 | ), f"max_num_seqs: {self.scheduler_config.max_num_seqs} should be larger than 1" |
| 2056 | assert self.scheduler_config.max_num_batched_tokens >= self.scheduler_config.max_num_seqs, ( |
| 2057 | f"max_num_batched_tokens: {self.scheduler_config.max_num_batched_tokens} " |
| 2058 | f"should be larger than or equal to max_num_seqs: {self.scheduler_config.max_num_seqs}" |
| 2059 | ) |
| 2060 | assert ( |
| 2061 | self.scheduler_config.max_num_batched_tokens |
| 2062 | <= self.model_config.max_model_len * self.scheduler_config.max_num_seqs |
| 2063 | ), ( |
| 2064 | f"max_num_batched_tokens: {self.scheduler_config.max_num_batched_tokens} should be less " |
| 2065 | f"than or equal to max_num_seqs: {self.scheduler_config.max_num_seqs} * max_model_len: {self.model_config.max_model_len}" |
| 2066 | ) |
| 2067 | assert ( |
| 2068 | self.max_num_partial_prefills >= 1 |
| 2069 | ), f"max_num_partial_prefills: {self.max_num_partial_prefills} should be larger than or equal to 1" |
| 2070 | |
| 2071 | assert ( |
| 2072 | self.max_long_partial_prefills >= 1 |
| 2073 | ), f"max_long_partial_prefills: {self.max_long_partial_prefills} should be larger than or equal to 1" |
| 2074 | assert self.max_long_partial_prefills <= self.max_num_partial_prefills, ( |
| 2075 | f"max_long_partial_prefills: {self.max_long_partial_prefills} should " |
| 2076 | f"be less than or equal to max_num_partial_prefills: {self.max_num_partial_prefills}" |
| 2077 | ) |
| 2078 | assert self.scheduler_config.splitwise_role in ["mixed", "prefill", "decode"] |
| 2079 | |
| 2080 | if not self.cache_config.enable_chunked_prefill: |
| 2081 | if not envs.ENABLE_V1_KVCACHE_SCHEDULER: |
| 2082 | assert self.scheduler_config.max_num_batched_tokens >= self.model_config.max_model_len, ( |
| 2083 | f"max_num_batched_tokens: {self.scheduler_config.max_num_batched_tokens} " |
| 2084 | f"should be larger than or equal to max_model_len: {self.model_config.max_model_len}" |
| 2085 | ) |
| 2086 | else: |
| 2087 | assert self.scheduler_config.max_num_batched_tokens >= self.cache_config.block_size, ( |
| 2088 | f"max_num_batched_tokens: {self.scheduler_config.max_num_batched_tokens} " |
| 2089 | f"should be larger than or equal to block_size: {self.cache_config.block_size}" |
| 2090 | ) |
| 2091 | |
| 2092 | if self.max_num_partial_prefills > 1: |
| 2093 | assert ( |
| 2094 | self.cache_config.enable_chunked_prefill is True |
| 2095 | ), "Chunked prefill must be enabled to set max_num_partial_prefills > 1" |
| 2096 | assert self.long_prefill_token_threshold < self.model_config.max_model_len, ( |
| 2097 | f"long_prefill_token_threshold: {self.long_prefill_token_threshold} should be less than" |
| 2098 | f" max_model_len: {self.model_config.max_model_len}" |