Skip to content

Commit 1f23539

Browse files
committed
refactor applying code style with preserve logic for olmo
1 parent 8273de7 commit 1f23539

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

optimum/intel/openvino/modeling_decoder.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,8 @@ def prepare_inputs(
386386
inputs = {}
387387
if not self.stateful:
388388
if past_key_values is not None:
389-
if (
390-
self.config.model_type not in MULTI_QUERY_ATTN_MODELS
391-
or self.config.model_type == "falcon"
392-
and self.config.new_decoder_architecture
389+
if self.config.model_type not in MULTI_QUERY_ATTN_MODELS or (
390+
self.config.model_type == "falcon" and self.config.new_decoder_architecture
393391
):
394392
if self._pkv_precision == Type.bf16:
395393
# numpy does not support bf16, pretending f16, should change to bf16
@@ -499,10 +497,8 @@ def forward(
499497
if self.use_cache:
500498
# Tuple of length equal to : number of layer * number of past_key_value per decoder layer (2 corresponds to the self-attention layer)
501499
past_key_values = tuple(self.request.get_tensor(key).data for key in self.key_value_output_names)
502-
if (
503-
self.config.model_type not in MULTI_QUERY_ATTN_MODELS
504-
or self.config.model_type == "falcon"
505-
and self.config.new_decoder_architecture
500+
if self.config.model_type not in MULTI_QUERY_ATTN_MODELS or (
501+
self.config.model_type == "falcon" and self.config.new_decoder_architecture
506502
):
507503
# Tuple of tuple of length `n_layers`, with each tuple of length equal to 2 (k/v of self-attention)
508504
past_key_values = tuple(

tests/openvino/test_modeling.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
from optimum.intel.openvino import OV_DECODER_NAME, OV_DECODER_WITH_PAST_NAME, OV_ENCODER_NAME, OV_XML_FILE_NAME
8181
from optimum.intel.openvino.modeling_seq2seq import OVDecoder, OVEncoder
8282
from optimum.intel.openvino.modeling_timm import TimmImageProcessor
83-
from optimum.intel.openvino.utils import _print_compiled_model_properties
8483
from optimum.intel.utils.import_utils import is_openvino_version
8584
from optimum.utils import (
8685
DIFFUSION_MODEL_TEXT_ENCODER_SUBFOLDER,
@@ -876,7 +875,7 @@ def test_beam_search(self, model_arch):
876875
transformers_model.config.eos_token_id = None
877876

878877
for gen_config in gen_configs:
879-
if gen_config.do_sample and model_arch == "baichuan2-13b":
878+
if gen_config.do_sample and model_arch in ["baichuan2-13b", "olmo"]:
880879
continue
881880
transformers_outputs = transformers_model.generate(**tokens, generation_config=gen_config)
882881
ov_stateful_outputs = ov_model_stateful.generate(**tokens, generation_config=gen_config)

0 commit comments

Comments
 (0)