[torch.compile] Adding torch compile annotations to some models (#9641)

Signed-off-by: youkaichao <youkaichao@gmail.com>
Co-authored-by: youkaichao <youkaichao@gmail.com>
This commit is contained in:
Yongzao
2024-10-24 09:31:42 -07:00
committed by GitHub
co-authored by youkaichao
parent de662d32b5
commit d27cfbf791
7 changed files with 21 additions and 11 deletions
+3
View File
@@ -27,6 +27,7 @@ from torch import nn
from transformers import PretrainedConfig
from vllm.attention import Attention, AttentionMetadata
from vllm.compilation.decorators import support_torch_compile
from vllm.config import CacheConfig, LoRAConfig
from vllm.distributed import get_pp_group, get_tensor_model_parallel_world_size
from vllm.model_executor.layers.activation import SiluAndMul
@@ -220,6 +221,7 @@ class XverseDecoderLayer(nn.Module):
return hidden_states, residual
@support_torch_compile
class XverseModel(nn.Module):
def __init__(
@@ -266,6 +268,7 @@ class XverseModel(nn.Module):
residual = None
else:
hidden_states = intermediate_tensors["hidden_states"]
residual = intermediate_tensors["residual"]
for i in range(self.start_layer, self.end_layer):
layer = self.layers[i]
hidden_states, residual = layer(