Skip to content

Commit

Permalink
fix phi3 conversion (#440)
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova authored May 14, 2024
1 parent 2bc9a7f commit 234ad87
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions llm_bench/python/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ def ts_patched_forward(
remote_code = False
pt_model = None
try:
config = AutoConfig.from_pretrained(args.model_id)
config = AutoConfig.from_pretrained(args.model_id, trust_remote_code=False)
except Exception:
config = AutoConfig.from_pretrained(args.model_id, trust_remote_code=True)
remote_code = True
Expand Down Expand Up @@ -1215,14 +1215,13 @@ def convert_falcon(args):
def convert_phi(args):
trust_remote_code = False
try:
config = AutoConfig.from_pretrained(args.model_id)
config = AutoConfig.from_pretrained(args.model_id, trust_remote_code=False)
except Exception:
config = AutoConfig.from_pretrained(args.model_id, trust_remote_code=True)
trust_remote_code = True
cuda, post_init = patch_gptq(config)
model_kwargs = {}
if trust_remote_code:
model_kwargs["trust_remote_code"] = trust_remote_code
model_kwargs["trust_remote_code"] = trust_remote_code
precision = args.precision
compression_only = (
args.compress_weights
Expand All @@ -1238,7 +1237,7 @@ def convert_phi(args):
if not compression_only:
pt_model = AutoModelForCausalLM.from_pretrained(
args.model_id,
config=AutoConfig.from_pretrained(args.model_id),
config=config,
**model_kwargs,
)
pt_model.config.use_cache = True
Expand Down
2 changes: 1 addition & 1 deletion llm_bench/python/utils/ov_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def create_text_gen_model(model_path, device, **kwargs):
else:
remote_code = False
try:
model_config = AutoConfig.from_pretrained(model_path)
model_config = AutoConfig.from_pretrained(model_path, trust_remote_code=False)
except Exception:
model_config = AutoConfig.from_pretrained(model_path, trust_remote_code=True)
remote_code = True
Expand Down

0 comments on commit 234ad87

Please sign in to comment.