From 1785f6d35c2c28cf5d6740afb60aa3469f46a37c Mon Sep 17 00:00:00 2001 From: eaidova Date: Wed, 26 Jun 2024 12:19:18 +0400 Subject: [PATCH] fix model patcher --- optimum/exporters/openvino/model_patcher.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/optimum/exporters/openvino/model_patcher.py b/optimum/exporters/openvino/model_patcher.py index 4e983476d0..f278075ff0 100644 --- a/optimum/exporters/openvino/model_patcher.py +++ b/optimum/exporters/openvino/model_patcher.py @@ -528,8 +528,8 @@ def __enter__(self): # llama/gemma has some accuracy issues with bf16 with transformers >= 4.39 # fill causal mask in slightly different way for avoid overflow on some platforms + max_positions = self._model.config.max_position_embeddings if is_transformers_version(">=", "4.39.0"): - max_positions = self._model.config.max_position_embeddings self._model.model.register_buffer( "bias", torch.tril(torch.ones((max_positions, max_positions), dtype=torch.bool)).view( @@ -552,9 +552,10 @@ def create_sinusoidal_positions(num_pos: int, dim: int, base: int = 10000) -> to return torch.cat((torch.sin(emb), torch.cos(emb)), dim=1) base = self._model.model.layers[0].self_attn.rotary_emb.base + dim = self._model.model.layers[0].self_attn.rotary_emb.dim self._model.model.register_buffer( "embed_positions", - create_sinusoidal_positions(max_positions, self._model.config.head_dim, self._model.config, base), + create_sinusoidal_positions(max_positions, dim, base), ) # init cos/sin for torchscript tracing