From a6c0faa23778402daf662e6e5f660dba1446db0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CElla?= Date: Fri, 31 Jul 2026 18:07:37 +0200 Subject: [PATCH 1/4] Unpin huggingface-hub<1.22 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 7ff3b6a92e..11b0753904 100644 --- a/setup.py +++ b/setup.py @@ -29,10 +29,10 @@ INSTALL_REQUIRE = [ "torch>=2.1", "safetensors<0.8.0", - "optimum@git+https://github.com/huggingface/optimum.git", + "optimum@git+https://github.com/huggingface/optimum.git@hf-hub", "transformers>=4.51,<5.6", "setuptools", - "huggingface-hub>=0.23.2,<1.22", + "huggingface-hub>=0.23.2,<2.0", "nncf>=2.19.0", "openvino>=2026.0", "openvino-tokenizers>=2026.0", From d489d2f792632d15073d1bc86515d1ca4eaa0e8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CElla?= Date: Fri, 31 Jul 2026 18:11:10 +0200 Subject: [PATCH 2/4] update setup --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 11b0753904..b6dab0baf7 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ INSTALL_REQUIRE = [ "torch>=2.1", "safetensors<0.8.0", - "optimum@git+https://github.com/huggingface/optimum.git@hf-hub", + "optimum@git+https://github.com/huggingface/optimum.git", "transformers>=4.51,<5.6", "setuptools", "huggingface-hub>=0.23.2,<2.0", From a0a17309255c92f9616edf2a5052f5c1825a0cf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CElla?= Date: Mon, 3 Aug 2026 16:57:51 +0200 Subject: [PATCH 3/4] fix model loading when offline --- optimum/intel/openvino/modeling_base.py | 5 ++--- optimum/intel/openvino/modeling_open_clip.py | 9 +++++---- optimum/intel/utils/modeling_utils.py | 12 +++++++++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/optimum/intel/openvino/modeling_base.py b/optimum/intel/openvino/modeling_base.py index 882e123c77..797551afe7 100644 --- a/optimum/intel/openvino/modeling_base.py +++ b/optimum/intel/openvino/modeling_base.py @@ -617,6 +617,7 @@ def from_pretrained( _maybe_register_remote_code_model(model_id, revision=revision, token=token, cache_dir=cache_dir) _export = export + model_dir = model_id try: if local_files_only: object_id = model_id.replace("/", "--") @@ -625,8 +626,6 @@ def from_pretrained( with open(refs_file) as f: revision = f.read() model_dir = os.path.join(cached_model_dir, "snapshots", revision) - else: - model_dir = model_id ov_files = _find_files_matching_pattern( model_dir, @@ -654,7 +653,7 @@ def from_pretrained( ) return super().from_pretrained( - model_id, + model_dir, export=_export, force_download=force_download, token=token, diff --git a/optimum/intel/openvino/modeling_open_clip.py b/optimum/intel/openvino/modeling_open_clip.py index 952f23a225..cf14dbc296 100644 --- a/optimum/intel/openvino/modeling_open_clip.py +++ b/optimum/intel/openvino/modeling_open_clip.py @@ -152,6 +152,7 @@ def from_pretrained( local_files_only = True _export = export + model_dir = model_id try: if local_files_only: object_id = model_id.replace("/", "--") @@ -160,8 +161,6 @@ def from_pretrained( with open(refs_file) as f: revision = f.read() model_dir = os.path.join(cached_model_dir, "snapshots", revision) - else: - model_dir = model_id ov_files = _find_files_matching_pattern( model_dir, @@ -190,8 +189,10 @@ def from_pretrained( if isinstance(model_id, Path): model_id = model_id.as_posix() + if isinstance(model_dir, Path): + model_dir = model_dir.as_posix() - config_path = config if isinstance(config, (str, os.PathLike)) else model_id + config_path = config if isinstance(config, (str, os.PathLike)) else model_dir config = cls._load_config( config_path, revision=revision, @@ -205,7 +206,7 @@ def from_pretrained( from_pretrained_method = cls._export if _export else cls._from_pretrained return from_pretrained_method( - model_id=model_id, + model_id=model_dir, config=config, revision=revision, cache_dir=cache_dir, diff --git a/optimum/intel/utils/modeling_utils.py b/optimum/intel/utils/modeling_utils.py index 76a5ab37f8..77d20bde6c 100644 --- a/optimum/intel/utils/modeling_utils.py +++ b/optimum/intel/utils/modeling_utils.py @@ -23,6 +23,7 @@ import torch from huggingface_hub import HfApi, get_token, hf_hub_download from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE +from huggingface_hub.errors import OfflineModeIsEnabled from huggingface_hub.hf_api import file_exists from transformers import CLIPConfig, PretrainedConfig, PreTrainedModel @@ -135,7 +136,16 @@ def _find_files_matching_pattern( files_ = [p for p in files_ if re.search(pattern, str(p))] files.extend(files_) else: - repo_files = map(Path, HfApi().list_repo_files(model_name_or_path, revision=revision, token=token)) + hf_api = HfApi() + try: + repo_files = map(Path, hf_api.list_repo_files(model_name_or_path, revision=revision, token=token)) + except (ConnectionError, OfflineModeIsEnabled): + snapshot_path = hf_api.snapshot_download(repo_id=str(model_name_or_path), revision=revision, token=token) + repo_files = [ + Path(os.path.relpath(os.path.join(dirpath, file), snapshot_path)) + for dirpath, _, filenames in os.walk(snapshot_path) + for file in filenames + ] files = [Path(p) for p in repo_files if re.match(pattern, str(p)) and str(p.parent) in subfolders] return files From 74b45f8dd386d037282acbb43f1ca706c27224f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CElla?= Date: Fri, 7 Aug 2026 17:09:47 +0200 Subject: [PATCH 4/4] remove un needed --- optimum/intel/openvino/modeling_open_clip.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/optimum/intel/openvino/modeling_open_clip.py b/optimum/intel/openvino/modeling_open_clip.py index cf14dbc296..494678c7e6 100644 --- a/optimum/intel/openvino/modeling_open_clip.py +++ b/optimum/intel/openvino/modeling_open_clip.py @@ -187,8 +187,6 @@ def from_pretrained( f"Could not infer whether the model was already converted or not to the OpenVINO IR, keeping `export={export}`.\n{exception}" ) - if isinstance(model_id, Path): - model_id = model_id.as_posix() if isinstance(model_dir, Path): model_dir = model_dir.as_posix()