Skip to content

Commit

Permalink
added token argument
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyasMoutawwakil committed Apr 23, 2024
1 parent 7db4c7e commit 8fca1d6
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 7 deletions.
3 changes: 3 additions & 0 deletions optimum/exporters/openvino/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def main_export(
force_download: bool = False,
local_files_only: bool = False,
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
model_kwargs: Optional[Dict[str, Any]] = None,
custom_export_configs: Optional[Dict[str, "OnnxConfig"]] = None,
fn_get_submodels: Optional[Callable] = None,
Expand Down Expand Up @@ -196,6 +197,7 @@ def main_export(
revision=revision,
cache_dir=cache_dir,
use_auth_token=use_auth_token,
token=token,
local_files_only=local_files_only,
force_download=force_download,
trust_remote_code=trust_remote_code,
Expand Down Expand Up @@ -268,6 +270,7 @@ class StoreAttr(object):
revision=revision,
cache_dir=cache_dir,
use_auth_token=use_auth_token,
token=token,
local_files_only=local_files_only,
force_download=force_download,
trust_remote_code=trust_remote_code,
Expand Down
7 changes: 6 additions & 1 deletion optimum/intel/generation/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ def _from_pretrained(
cls,
model_id: Union[str, Path],
config: PretrainedConfig,
use_auth_token: Optional[Union[bool, str, None]] = None,
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[Union[str, None]] = None,
force_download: bool = False,
cache_dir: Optional[str] = None,
Expand All @@ -376,6 +377,7 @@ def _from_pretrained(
repo_id=model_id,
filename=file_name,
use_auth_token=use_auth_token,
token=token,
revision=revision,
cache_dir=cache_dir,
force_download=force_download,
Expand All @@ -398,6 +400,7 @@ def _from_transformers(
model_id: str,
config: PretrainedConfig,
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
force_download: bool = False,
cache_dir: Optional[str] = None,
Expand All @@ -414,6 +417,7 @@ def _from_transformers(
model_kwargs = {
"revision": revision,
"use_auth_token": use_auth_token,
"token": token,
"cache_dir": cache_dir,
"subfolder": subfolder,
"local_files_only": local_files_only,
Expand All @@ -436,6 +440,7 @@ def _from_transformers(
config=config,
use_cache=use_cache,
use_auth_token=use_auth_token,
token=token,
revision=revision,
force_download=force_download,
cache_dir=cache_dir,
Expand Down
6 changes: 5 additions & 1 deletion optimum/intel/ipex/modeling_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def _from_transformers(
config: PretrainedConfig,
use_cache: bool = True,
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
force_download: bool = False,
cache_dir: Optional[str] = None,
Expand All @@ -166,6 +167,7 @@ def _from_transformers(
model_kwargs = {
"revision": revision,
"use_auth_token": use_auth_token,
"token": token,
"cache_dir": cache_dir,
"subfolder": subfolder,
"local_files_only": local_files_only,
Expand All @@ -187,7 +189,8 @@ def _from_pretrained(
cls,
model_id: Union[str, Path],
config: PretrainedConfig,
use_auth_token: Optional[Union[bool, str, None]] = None,
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[Union[str, None]] = None,
force_download: bool = False,
cache_dir: Optional[str] = None,
Expand All @@ -211,6 +214,7 @@ def _from_pretrained(
repo_id=model_id,
filename=file_name,
use_auth_token=use_auth_token,
token=token,
revision=revision,
cache_dir=cache_dir,
force_download=force_download,
Expand Down
5 changes: 4 additions & 1 deletion optimum/intel/neural_compressor/modeling_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def _from_pretrained(
cls,
model_id: Union[str, Path],
config: PretrainedConfig,
use_auth_token: Optional[Union[bool, str, None]] = None,
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[Union[str, None]] = None,
force_download: bool = False,
cache_dir: Optional[str] = None,
Expand All @@ -126,6 +127,7 @@ def _from_pretrained(
filename=file_name,
subfolder=subfolder,
use_auth_token=use_auth_token,
token=token,
revision=revision,
cache_dir=cache_dir,
force_download=force_download,
Expand All @@ -149,6 +151,7 @@ def _from_pretrained(
return _BaseQBitsAutoModelClass.from_pretrained(
pretrained_model_name_or_path=model_id,
use_auth_token=use_auth_token,
token=token,
revision=revision,
force_download=force_download,
cache_dir=cache_dir,
Expand Down
4 changes: 3 additions & 1 deletion optimum/intel/neural_compressor/quantization.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,8 @@ def get_calibration_dataset(
dataset_split: str = "train",
preprocess_function: Optional[Callable] = None,
preprocess_batch: bool = True,
use_auth_token: bool = False,
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
) -> Dataset:
"""
Create the calibration `datasets.Dataset` to use for the post-training static quantization calibration step.
Expand Down Expand Up @@ -475,6 +476,7 @@ def get_calibration_dataset(
name=dataset_config_name,
split=dataset_split,
use_auth_token=use_auth_token,
token=token,
)

if num_samples is not None:
Expand Down
3 changes: 3 additions & 0 deletions optimum/intel/openvino/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ def load_textual_inversion(
proxies = kwargs.pop("proxies", None)
local_files_only = kwargs.pop("local_files_only", HF_HUB_OFFLINE)
use_auth_token = kwargs.pop("use_auth_token", None)
token = kwargs.pop("token", None)
revision = kwargs.pop("revision", None)
subfolder = kwargs.pop("subfolder", None)
weight_name = kwargs.pop("weight_name", None)
Expand Down Expand Up @@ -320,6 +321,7 @@ def load_textual_inversion(
proxies=proxies,
local_files_only=local_files_only,
use_auth_token=use_auth_token,
token=token,
revision=revision,
subfolder=subfolder,
user_agent=user_agent,
Expand All @@ -341,6 +343,7 @@ def load_textual_inversion(
proxies=proxies,
local_files_only=local_files_only,
use_auth_token=use_auth_token,
token=token,
revision=revision,
subfolder=subfolder,
user_agent=user_agent,
Expand Down
4 changes: 4 additions & 0 deletions optimum/intel/openvino/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ def _from_transformers(
model_id: str,
config: PretrainedConfig,
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
force_download: bool = False,
cache_dir: Optional[str] = None,
Expand Down Expand Up @@ -450,6 +451,7 @@ def _from_transformers(
revision=revision,
cache_dir=cache_dir,
use_auth_token=use_auth_token,
token=token,
local_files_only=local_files_only,
force_download=force_download,
trust_remote_code=trust_remote_code,
Expand Down Expand Up @@ -583,6 +585,7 @@ def from_pretrained(
export: bool = False,
config: Optional["PretrainedConfig"] = None,
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
force_download: bool = False,
cache_dir: Optional[str] = None,
Expand Down Expand Up @@ -621,6 +624,7 @@ def from_pretrained(
config=config,
export=export,
use_auth_token=use_auth_token,
token=token,
revision=revision,
force_download=force_download,
cache_dir=cache_dir,
Expand Down
10 changes: 9 additions & 1 deletion optimum/intel/openvino/modeling_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ def _from_pretrained(
cls,
model_id: Union[str, Path],
config: PretrainedConfig,
use_auth_token: Optional[Union[bool, str, None]] = None,
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[Union[str, None]] = None,
force_download: bool = False,
cache_dir: Optional[str] = None,
Expand Down Expand Up @@ -215,6 +216,7 @@ def _from_pretrained(
model_cache_path = cls._cached_file(
model_path=model_path,
use_auth_token=use_auth_token,
token=token,
revision=revision,
force_download=force_download,
cache_dir=cache_dir,
Expand Down Expand Up @@ -260,6 +262,7 @@ def _set_ov_config_parameters(self):
def _cached_file(
model_path: Union[Path, str],
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
force_download: bool = False,
cache_dir: Optional[str] = None,
Expand All @@ -283,6 +286,7 @@ def _cached_file(
filename=file_name.as_posix(),
subfolder=subfolder,
use_auth_token=use_auth_token,
token=token,
revision=revision,
cache_dir=cache_dir,
force_download=force_download,
Expand All @@ -298,6 +302,7 @@ def _from_transformers(
model_id: str,
config: PretrainedConfig,
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
force_download: bool = False,
cache_dir: Optional[str] = None,
Expand Down Expand Up @@ -344,6 +349,7 @@ def _from_transformers(
revision=revision,
cache_dir=cache_dir,
use_auth_token=use_auth_token,
token=token,
local_files_only=local_files_only,
force_download=force_download,
trust_remote_code=trust_remote_code,
Expand All @@ -366,6 +372,7 @@ def _to_load(
config: PretrainedConfig,
onnx_config: OnnxConfig,
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
force_download: bool = False,
cache_dir: Optional[str] = None,
Expand All @@ -390,6 +397,7 @@ def _to_load(
config=config,
from_onnx=False,
use_auth_token=use_auth_token,
token=token,
revision=revision,
force_download=force_download,
cache_dir=cache_dir,
Expand Down
4 changes: 4 additions & 0 deletions optimum/intel/openvino/modeling_base_seq2seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def _from_pretrained(
model_id: Union[str, Path],
config: PretrainedConfig,
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
force_download: bool = False,
cache_dir: Optional[str] = None,
Expand Down Expand Up @@ -191,6 +192,7 @@ def _from_pretrained(
repo_id=model_id,
filename=file_name,
use_auth_token=use_auth_token,
token=token,
revision=revision,
cache_dir=cache_dir,
force_download=force_download,
Expand Down Expand Up @@ -220,6 +222,7 @@ def _from_transformers(
model_id: str,
config: PretrainedConfig,
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
force_download: bool = False,
cache_dir: Optional[str] = None,
Expand Down Expand Up @@ -273,6 +276,7 @@ def _from_transformers(
revision=revision,
cache_dir=cache_dir,
use_auth_token=use_auth_token,
token=token,
local_files_only=local_files_only,
force_download=force_download,
trust_remote_code=trust_remote_code,
Expand Down
6 changes: 5 additions & 1 deletion optimum/intel/openvino/modeling_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def _from_transformers(
model_id: str,
config: PretrainedConfig,
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
force_download: bool = False,
cache_dir: Optional[str] = None,
Expand Down Expand Up @@ -255,6 +256,7 @@ def _from_transformers(
revision=revision,
cache_dir=cache_dir,
use_auth_token=use_auth_token,
token=token,
local_files_only=local_files_only,
force_download=force_download,
trust_remote_code=trust_remote_code,
Expand Down Expand Up @@ -562,7 +564,8 @@ def _from_pretrained(
cls,
model_id: Union[str, Path],
config: PretrainedConfig,
use_auth_token: Optional[Union[bool, str, None]] = None,
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[Union[str, None]] = None,
force_download: bool = False,
cache_dir: Optional[str] = None,
Expand All @@ -581,6 +584,7 @@ def _from_pretrained(
model_cache_path = cls._cached_file(
model_path=model_path,
use_auth_token=use_auth_token,
token=token,
revision=revision,
force_download=force_download,
cache_dir=cache_dir,
Expand Down
5 changes: 5 additions & 0 deletions optimum/intel/openvino/modeling_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def _from_pretrained(
model_id: Union[str, Path],
config: Dict[str, Any],
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
cache_dir: Optional[str] = None,
vae_decoder_file_name: Optional[str] = None,
Expand Down Expand Up @@ -260,6 +261,7 @@ def _from_pretrained(
cache_dir=cache_dir,
local_files_only=local_files_only,
use_auth_token=use_auth_token,
token=token,
revision=revision,
allow_patterns=allow_patterns,
ignore_patterns=ignore_patterns,
Expand Down Expand Up @@ -398,6 +400,7 @@ def _from_transformers(
model_id: str,
config: Dict[str, Any],
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
revision: Optional[str] = None,
force_download: bool = False,
cache_dir: Optional[str] = None,
Expand Down Expand Up @@ -428,6 +431,7 @@ def _from_transformers(
revision=revision,
cache_dir=cache_dir,
use_auth_token=use_auth_token,
token=token,
local_files_only=local_files_only,
force_download=force_download,
ov_config=ov_config,
Expand All @@ -438,6 +442,7 @@ def _from_transformers(
config=config,
from_onnx=False,
use_auth_token=use_auth_token,
token=token,
revision=revision,
force_download=force_download,
cache_dir=cache_dir,
Expand Down
4 changes: 3 additions & 1 deletion optimum/intel/openvino/quantization.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,8 @@ def get_calibration_dataset(
dataset_split: str = "train",
preprocess_function: Optional[Callable] = None,
preprocess_batch: bool = True,
use_auth_token: bool = False,
use_auth_token: Optional[Union[bool, str]] = None,
token: Optional[Union[bool, str]] = None,
cache_dir: Optional[str] = None,
) -> datasets.Dataset:
"""
Expand Down Expand Up @@ -576,6 +577,7 @@ def get_calibration_dataset(
name=dataset_config_name,
split=dataset_split,
use_auth_token=use_auth_token,
token=token,
cache_dir=cache_dir,
)

Expand Down

0 comments on commit 8fca1d6

Please sign in to comment.