Skip to content

Commit

Permalink
apply review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova committed Jun 6, 2024
1 parent d2a25ff commit 0c0cedb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
7 changes: 1 addition & 6 deletions optimum/exporters/openvino/model_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,13 @@ def __exit__(self, exc_type, exc_value, traceback):

class ArcticModelPatcher(MixtralModelPatcher):
def __enter__(self):
super().__enter__()
# model initialize some weights for matrix multiplication in bfloat16, that lead to inconsistency of dtype
try:
self._model.to(torch.float32)
except Exception:
pass

for layer in self._model.model.layers:
layer.block_sparse_moe._unpatched_forward = layer.block_sparse_moe.forward
layer.block_sparse_moe.forward = types.MethodType(
_mixtral_sparse_moe_block_forward, layer.block_sparse_moe
)
super().__enter__()


def _chatglm_transformer_forward(
Expand Down
8 changes: 4 additions & 4 deletions tests/openvino/test_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ class OVModelForCausalLMIntegrationTest(unittest.TestCase):
"dbrx",
"qwen2-moe",
"jais",
"snowflake",
"arctic",
)
GENERATION_LENGTH = 100
REMOTE_CODE_MODELS = (
Expand All @@ -583,7 +583,7 @@ class OVModelForCausalLMIntegrationTest(unittest.TestCase):
"xverse",
"internlm",
"codegen2",
"snowflake",
"arctic",
)

@parameterized.expand(SUPPORTED_ARCHITECTURES)
Expand Down Expand Up @@ -625,7 +625,7 @@ def test_compare_to_transformers(self, model_arch):

set_seed(SEED)
transformers_model = AutoModelForCausalLM.from_pretrained(model_id, **model_kwargs)
if model_arch in ["qwen", "snowflake"]:
if model_arch in ["qwen", "arctic"]:
transformers_model.to(torch.float32)

with torch.no_grad():
Expand Down Expand Up @@ -873,7 +873,7 @@ def test_beam_search(self, model_arch):
)
transformers_model = AutoModelForCausalLM.from_pretrained(model_id, **model_kwargs)

if model_arch == "snowflake":
if model_arch == "arctic":
transformers_model.to(torch.float32)
tokenizer.pad_token_id = tokenizer.eos_token_id
tokens = tokenizer(["Today is a nice day and I am longer", "This is me"], return_tensors="pt", padding=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/openvino/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"latent-consistency": "echarlaix/tiny-random-latent-consistency",
"sew": "hf-internal-testing/tiny-random-SEWModel",
"sew_d": "asapp/sew-d-tiny-100k-ft-ls100h",
"snowflake": "katuni4ka/tiny-random-snowflake",
"arctic": "katuni4ka/tiny-random-snowflake",
"swin": "hf-internal-testing/tiny-random-SwinModel",
"t5": "hf-internal-testing/tiny-random-t5",
"trocr": "microsoft/trocr-small-handwritten",
Expand Down

0 comments on commit 0c0cedb

Please sign in to comment.