Skip to content

Commit

Permalink
Inc on vLLM -Change RMS norm to BF16
Browse files Browse the repository at this point in the history
  • Loading branch information
nirda7 committed Aug 13, 2024
1 parent ed81599 commit 3b34893
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions vllm/model_executor/layers/layernorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,16 @@ def forward_hpu(
if HPUFusedRMSNorm is None:
return self.forward_native(x, residual)
if residual is not None:
orig_dtype = x.dtype
orig_shape = x.shape
residual += x.view(residual.shape)
# Note: HPUFusedRMSNorm requires 3D tensors as inputs
x = HPUFusedRMSNorm.apply(residual.float(), self.weight.float(),
x = HPUFusedRMSNorm.apply(residual, self.weight,
self.variance_epsilon)
return x.to(orig_dtype).view(orig_shape), residual
return x.view(orig_shape), residual

orig_dtype = x.dtype
x = HPUFusedRMSNorm.apply(x.float(), self.weight.float(),
x = HPUFusedRMSNorm.apply(x, self.weight,
self.variance_epsilon)
return x.to(orig_dtype)
return x

def forward_xpu(
self,
Expand Down

0 comments on commit 3b34893

Please sign in to comment.