Skip to content

Commit fe7cd43

Browse files
authored
Reduce number of compilations when dynamic shapes is used (#90)
It fixes the issue with to many compilation for Pytorch dynamic shapes ( when VLLM_T_COMPILE_DYNAMIC_SHAPES=1) It allows making dynamic shapes for registered buffers (see UnspecializedParamBufferSource in PyTorch) by setting dynamo config. It also enables dynamic_shapes_compilation by default. --------- Signed-off-by: Andrzej Kotłowski <[email protected]>
1 parent 50f7d8b commit fe7cd43

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

vllm_gaudi/extension/features.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def get_features():
7878
ValueFromList('bucketing_strategy', bucketing_strategies),
7979
Value('defrag', False),
8080
Value('regional_compilation', True, env_var='VLLM_T_COMPILE_REGIONAL_COMPILATION', env_var_type=boolean),
81-
Value('dynamic_shapes_compilation', False, env_var='VLLM_T_COMPILE_DYNAMIC_SHAPES', env_var_type=boolean),
81+
Value('dynamic_shapes_compilation', True, env_var='VLLM_T_COMPILE_DYNAMIC_SHAPES', env_var_type=boolean),
8282
Value('fullgraph_compilation', False, env_var='VLLM_T_COMPILE_FULLGRAPH', env_var_type=boolean),
8383
]
8484
return split_values_and_flags(features)

vllm_gaudi/v1/worker/hpu_model_runner.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,6 +2337,9 @@ def _maybe_compile(self, *args, **kwargs):
23372337
"""Entrypoint for a torch.compilation of the model"""
23382338
if (not is_fake_hpu() and not htorch.utils.internal.is_lazy()
23392339
and not self.vllm_config.model_config.enforce_eager):
2340+
# force_parameter_static_shapes = False alows to use dynamic
2341+
# shapes on tensors added to module via register_buffer()
2342+
torch._dynamo.config.force_parameter_static_shapes = False
23402343
self.compile_config = HPUCompileConfig()
23412344
if self.compile_config.regional_compilation:
23422345
self._compile_methods()

0 commit comments

Comments
 (0)