[Mypy] Better fixes for the mypy issues in vllm/config (#37902)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
+9
-14
@@ -246,15 +246,15 @@ OPTIMIZATION_LEVEL_TO_CONFIG = {
|
||||
}
|
||||
|
||||
|
||||
@config(config=ConfigDict(arbitrary_types_allowed=True)) # type: ignore[arg-type,misc]
|
||||
class VllmConfig: # type: ignore[misc]
|
||||
@config(config=ConfigDict(arbitrary_types_allowed=True))
|
||||
class VllmConfig:
|
||||
"""Dataclass which contains all vllm-related configuration. This
|
||||
simplifies passing around the distinct configurations in the codebase.
|
||||
"""
|
||||
|
||||
# TODO: use default_factory once default constructing ModelConfig doesn't
|
||||
# try to download a model
|
||||
model_config: ModelConfig = Field(default=None) # type: ignore[assignment]
|
||||
model_config: ModelConfig = None # type: ignore[assignment]
|
||||
"""Model configuration."""
|
||||
cache_config: CacheConfig = Field(default_factory=CacheConfig)
|
||||
"""Cache configuration."""
|
||||
@@ -912,7 +912,8 @@ class VllmConfig: # type: ignore[misc]
|
||||
|
||||
tp_size = self.parallel_config.tensor_parallel_size
|
||||
hidden_size = self.model_config.get_hidden_size()
|
||||
element_size = self.model_config.dtype.itemsize # type: ignore[union-attr]
|
||||
assert isinstance(self.model_config.dtype, torch.dtype)
|
||||
element_size = self.model_config.dtype.itemsize
|
||||
pass_config.sp_min_token_num = get_sequence_parallelism_threshold(
|
||||
hidden_size, tp_size, element_size
|
||||
)
|
||||
@@ -1246,14 +1247,6 @@ class VllmConfig: # type: ignore[misc]
|
||||
)
|
||||
self.compilation_config.debug_dump_path = env_path
|
||||
|
||||
def has_blocked_weights(): # type: ignore[no-redef]
|
||||
if self.quant_config is not None:
|
||||
if hasattr(self.quant_config, "weight_block_size"):
|
||||
return self.quant_config.weight_block_size is not None
|
||||
elif hasattr(self.quant_config, "has_blocked_weights"):
|
||||
return self.quant_config.has_blocked_weights()
|
||||
return False
|
||||
|
||||
# Enable quant_fp8 CUDA ops (TODO disable in follow up)
|
||||
# On H100 the CUDA kernel is faster than
|
||||
# native implementation
|
||||
@@ -1502,9 +1495,10 @@ class VllmConfig: # type: ignore[misc]
|
||||
tp_size = self.parallel_config.tensor_parallel_size
|
||||
max_size = compilation_config.pass_config.flashinfer_max_size(tp_size)
|
||||
if max_size is not None:
|
||||
assert isinstance(self.model_config.dtype, torch.dtype)
|
||||
max_token_num = max_size // (
|
||||
self.model_config.get_hidden_size()
|
||||
* self.model_config.dtype.itemsize # type: ignore[union-attr]
|
||||
* self.model_config.dtype.itemsize
|
||||
)
|
||||
if compile_range_end is not None and max_token_num < compile_range_end:
|
||||
computed_compile_ranges_endpoints.append(max_token_num)
|
||||
@@ -1527,7 +1521,8 @@ class VllmConfig: # type: ignore[misc]
|
||||
|
||||
tp_size = self.parallel_config.tensor_parallel_size
|
||||
hidden_size = self.model_config.get_hidden_size()
|
||||
element_size = self.model_config.dtype.itemsize # type: ignore[union-attr]
|
||||
assert isinstance(self.model_config.dtype, torch.dtype)
|
||||
element_size = self.model_config.dtype.itemsize
|
||||
pass_config.sp_min_token_num = get_sequence_parallelism_threshold(
|
||||
hidden_size, tp_size, element_size
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user