Skip to content

Commit 8b766f8

Browse files
authored
Merge pull request vllm-project#29 from intel-sandbox/fix_linear_prepack_acc_bf16
fix linear init impacts on generation
2 parents 76db283 + b454101 commit 8b766f8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

vllm/model_executor/layers/linear.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
from typing import Dict, List, Optional, Tuple
33

44
import torch
5+
from torch.nn.utils import skip_init
6+
7+
58
import torch.nn.functional as F
69
from torch.nn.parameter import Parameter
7-
810
from vllm.distributed import (divide, get_tensor_model_parallel_rank,
911
get_tensor_model_parallel_world_size,
1012
split_tensor_along_last_dim,
@@ -102,13 +104,12 @@ def create_weights(self, layer: torch.nn.Module,
102104
set_weight_attrs(weight, {"input_dim": 1, "output_dim": 0})
103105
layer.register_parameter("weight", weight)
104106
set_weight_attrs(weight, extra_weight_attrs)
105-
106107
def apply(self,
107108
layer: torch.nn.Module,
108109
x: torch.Tensor,
109110
bias: Optional[torch.Tensor] = None) -> torch.Tensor:
110111
if not hasattr(layer, "ipex_linear"):
111-
linear = torch.nn.Linear(layer.weight.shape[1], layer.weight.shape[0], bias=True if bias is not None else False)
112+
linear = skip_init(torch.nn.Linear, layer.weight.shape[1], layer.weight.shape[0], bias=True if bias is not None else False)
112113
linear.weight = layer.weight
113114
if bias is not None:
114115
linear.bias = bias

0 commit comments

Comments
 (0)