Skip to content

Commit 4a8bddd

Browse files
added more warning and swapped token with use_ath_token
1 parent 4100e2d commit 4a8bddd

12 files changed

+225
-31
lines changed

optimum/exporters/openvino/__main__.py

-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ def main_export(
210210
subfolder=subfolder,
211211
revision=revision,
212212
cache_dir=cache_dir,
213-
use_auth_token=use_auth_token,
214213
token=token,
215214
local_files_only=local_files_only,
216215
force_download=force_download,
@@ -283,7 +282,6 @@ class StoreAttr(object):
283282
subfolder=subfolder,
284283
revision=revision,
285284
cache_dir=cache_dir,
286-
use_auth_token=use_auth_token,
287285
token=token,
288286
local_files_only=local_files_only,
289287
force_download=force_download,

optimum/intel/generation/modeling.py

+22-3
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,17 @@ def _from_pretrained(
364364
use_cache: bool = True,
365365
**kwargs,
366366
):
367+
if use_auth_token is not None:
368+
logger.warning(
369+
"The `use_auth_token` argument is deprecated and will be removed soon. "
370+
"Please use the `token` argument instead."
371+
)
372+
if token is not None:
373+
raise ValueError("You cannot use both `use_auth_token` and `token` arguments at the same time.")
374+
375+
token = use_auth_token
376+
use_auth_token = None
377+
367378
if not getattr(config, "torchscript", False):
368379
raise ValueError("`torchscript` should be set to True to load TorchScript model")
369380

@@ -377,7 +388,6 @@ def _from_pretrained(
377388
model_cache_path = hf_hub_download(
378389
repo_id=model_id,
379390
filename=file_name,
380-
use_auth_token=use_auth_token,
381391
token=token,
382392
revision=revision,
383393
cache_dir=cache_dir,
@@ -411,13 +421,23 @@ def _from_transformers(
411421
torch_dtype: Optional[Union[str, "torch.dtype"]] = None,
412422
**kwargs,
413423
):
424+
if use_auth_token is not None:
425+
logger.warning(
426+
"The `use_auth_token` argument is deprecated and will be removed soon. "
427+
"Please use the `token` argument instead."
428+
)
429+
if token is not None:
430+
raise ValueError("You cannot use both `use_auth_token` and `token` arguments at the same time.")
431+
432+
token = use_auth_token
433+
use_auth_token = None
434+
414435
if is_torch_version("<", "2.1.0"):
415436
raise ImportError("`torch>=2.0.0` is needed to trace your model")
416437

417438
task = cls.export_feature
418439
model_kwargs = {
419440
"revision": revision,
420-
"use_auth_token": use_auth_token,
421441
"token": token,
422442
"cache_dir": cache_dir,
423443
"subfolder": subfolder,
@@ -440,7 +460,6 @@ def _from_transformers(
440460
model_id=save_dir_path,
441461
config=config,
442462
use_cache=use_cache,
443-
use_auth_token=use_auth_token,
444463
token=token,
445464
revision=revision,
446465
force_download=force_download,

optimum/intel/ipex/modeling_base.py

+22-2
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,23 @@ def _from_transformers(
161161
torch_dtype: Optional[Union[str, "torch.dtype"]] = None,
162162
trust_remote_code: bool = False,
163163
):
164+
if use_auth_token is not None:
165+
logger.warning(
166+
"The `use_auth_token` argument is deprecated and will be removed soon. "
167+
"Please use the `token` argument instead."
168+
)
169+
if token is not None:
170+
raise ValueError("You cannot use both `use_auth_token` and `token` arguments at the same time.")
171+
172+
token = use_auth_token
173+
use_auth_token = None
174+
164175
if is_torch_version("<", "2.1.0"):
165176
raise ImportError("`torch>=2.0.0` is needed to trace your model")
166177

167178
task = cls.export_feature
168179
model_kwargs = {
169180
"revision": revision,
170-
"use_auth_token": use_auth_token,
171181
"token": token,
172182
"cache_dir": cache_dir,
173183
"subfolder": subfolder,
@@ -200,6 +210,17 @@ def _from_pretrained(
200210
subfolder: str = "",
201211
**kwargs,
202212
):
213+
if use_auth_token is not None:
214+
logger.warning(
215+
"The `use_auth_token` argument is deprecated and will be removed soon. "
216+
"Please use the `token` argument instead."
217+
)
218+
if token is not None:
219+
raise ValueError("You cannot use both `use_auth_token` and `token` arguments at the same time.")
220+
221+
token = use_auth_token
222+
use_auth_token = None
223+
203224
if not getattr(config, "torchscript", False):
204225
raise ValueError(
205226
"`config.torchscript` should be set to `True`, if your model is not a TorchScript model and needs to be traced please set `export=True` when loading it with `.from_pretrained()`"
@@ -214,7 +235,6 @@ def _from_pretrained(
214235
model_cache_path = hf_hub_download(
215236
repo_id=model_id,
216237
filename=file_name,
217-
use_auth_token=use_auth_token,
218238
token=token,
219239
revision=revision,
220240
cache_dir=cache_dir,

optimum/intel/neural_compressor/modeling_base.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,17 @@ def _from_pretrained(
109109
trust_remote_code: bool = False,
110110
**kwargs,
111111
):
112+
if use_auth_token is not None:
113+
logger.warning(
114+
"The `use_auth_token` argument is deprecated and will be removed soon. "
115+
"Please use the `token` argument instead."
116+
)
117+
if token is not None:
118+
raise ValueError("You cannot use both `use_auth_token` and `token` arguments at the same time.")
119+
120+
token = use_auth_token
121+
use_auth_token = None
122+
112123
model_name_or_path = kwargs.pop("model_name_or_path", None)
113124
if model_name_or_path is not None:
114125
logger.warning("`model_name_or_path` is deprecated please use `model_id`")
@@ -123,7 +134,6 @@ def _from_pretrained(
123134
repo_id=model_id,
124135
filename=file_name,
125136
subfolder=subfolder,
126-
use_auth_token=use_auth_token,
127137
token=token,
128138
revision=revision,
129139
cache_dir=cache_dir,
@@ -147,7 +157,6 @@ def _from_pretrained(
147157

148158
return _BaseQBitsAutoModelClass.from_pretrained(
149159
pretrained_model_name_or_path=model_id,
150-
use_auth_token=use_auth_token,
151160
token=token,
152161
revision=revision,
153162
force_download=force_download,

optimum/intel/neural_compressor/quantization.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,21 @@ def get_calibration_dataset(
474474
Returns:
475475
The calibration `datasets.Dataset` to use for the post-training static quantization calibration step.
476476
"""
477+
if use_auth_token is not None:
478+
logger.warning(
479+
"The `use_auth_token` argument is deprecated and will be removed soon. "
480+
"Please use the `token` argument instead."
481+
)
482+
if token is not None:
483+
raise ValueError("You cannot use both `use_auth_token` and `token` arguments at the same time.")
484+
485+
token = use_auth_token
486+
use_auth_token = None
487+
477488
calibration_dataset = load_dataset(
478489
dataset_name,
479490
name=dataset_config_name,
480491
split=dataset_split,
481-
use_auth_token=use_auth_token,
482492
token=token,
483493
)
484494

optimum/intel/openvino/loaders.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,17 @@ def load_textual_inversion(
266266
weight_name = kwargs.pop("weight_name", None)
267267
use_safetensors = kwargs.pop("use_safetensors", None)
268268

269+
if use_auth_token is not None:
270+
logger.warning(
271+
"The `use_auth_token` argument is deprecated and will be removed soon. "
272+
"Please use the `token` argument instead."
273+
)
274+
if token is not None:
275+
raise ValueError("You cannot use both `use_auth_token` and `token` arguments at the same time.")
276+
277+
token = use_auth_token
278+
use_auth_token = None
279+
269280
if use_safetensors and not is_safetensors_available():
270281
raise ValueError(
271282
"`use_safetensors`=True but safetensors is not installed. Please install safetensors with `pip install safetensors"
@@ -322,8 +333,7 @@ def load_textual_inversion(
322333
resume_download=resume_download,
323334
proxies=proxies,
324335
local_files_only=local_files_only,
325-
use_auth_token=use_auth_token,
326-
token=token,
336+
use_auth_token=token, # still uses use_auth_token
327337
revision=revision,
328338
subfolder=subfolder,
329339
user_agent=user_agent,
@@ -344,8 +354,7 @@ def load_textual_inversion(
344354
resume_download=resume_download,
345355
proxies=proxies,
346356
local_files_only=local_files_only,
347-
use_auth_token=use_auth_token,
348-
token=token,
357+
use_auth_token=token, # still uses use_auth_token
349358
revision=revision,
350359
subfolder=subfolder,
351360
user_agent=user_agent,

optimum/intel/openvino/modeling.py

+22-2
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,17 @@ def _from_transformers(
434434
quantization_config: Union[OVWeightQuantizationConfig, Dict] = None,
435435
**kwargs,
436436
):
437+
if use_auth_token is not None:
438+
logger.warning(
439+
"The `use_auth_token` argument is deprecated and will be removed soon. "
440+
"Please use the `token` argument instead."
441+
)
442+
if token is not None:
443+
raise ValueError("You cannot use both `use_auth_token` and `token` arguments at the same time.")
444+
445+
token = use_auth_token
446+
use_auth_token = None
447+
437448
save_dir = TemporaryDirectory()
438449
save_dir_path = Path(save_dir.name)
439450

@@ -451,7 +462,6 @@ def _from_transformers(
451462
subfolder=subfolder,
452463
revision=revision,
453464
cache_dir=cache_dir,
454-
use_auth_token=use_auth_token,
455465
token=token,
456466
local_files_only=local_files_only,
457467
force_download=force_download,
@@ -596,6 +606,17 @@ def from_pretrained(
596606
trust_remote_code: bool = False,
597607
**kwargs,
598608
):
609+
if use_auth_token is not None:
610+
logger.warning(
611+
"The `use_auth_token` argument is deprecated and will be removed soon. "
612+
"Please use the `token` argument instead."
613+
)
614+
if token is not None:
615+
raise ValueError("You cannot use both `use_auth_token` and `token` arguments at the same time.")
616+
617+
token = use_auth_token
618+
use_auth_token = None
619+
599620
# Fix the mismatch between timm_config and huggingface_config
600621
local_timm_model = _is_timm_ov_dir(model_id)
601622
if local_timm_model or (not os.path.isdir(model_id) and model_info(model_id).library_name == "timm"):
@@ -624,7 +645,6 @@ def from_pretrained(
624645
model_id=model_id,
625646
config=config,
626647
export=export,
627-
use_auth_token=use_auth_token,
628648
token=token,
629649
revision=revision,
630650
force_download=force_download,

optimum/intel/openvino/modeling_base.py

+44-4
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,23 @@ def _from_pretrained(
212212
load_in_8bit (`bool`, *optional*, defaults to `False`):
213213
Whether or not to apply 8-bit weight quantization.
214214
"""
215+
if use_auth_token is not None:
216+
logger.warning(
217+
"The `use_auth_token` argument is deprecated and will be removed soon. "
218+
"Please use the `token` argument instead."
219+
)
220+
if token is not None:
221+
raise ValueError("You cannot use both `use_auth_token` and `token` arguments at the same time.")
222+
223+
token = use_auth_token
224+
use_auth_token = None
225+
215226
model_path = Path(model_id)
216227
default_file_name = ONNX_WEIGHTS_NAME if from_onnx else OV_XML_FILE_NAME
217228
file_name = file_name or default_file_name
218229

219230
model_cache_path = cls._cached_file(
220231
model_path=model_path,
221-
use_auth_token=use_auth_token,
222232
token=token,
223233
revision=revision,
224234
force_download=force_download,
@@ -273,6 +283,17 @@ def _cached_file(
273283
subfolder: str = "",
274284
local_files_only: bool = False,
275285
):
286+
if use_auth_token is not None:
287+
logger.warning(
288+
"The `use_auth_token` argument is deprecated and will be removed soon. "
289+
"Please use the `token` argument instead."
290+
)
291+
if token is not None:
292+
raise ValueError("You cannot use both `use_auth_token` and `token` arguments at the same time.")
293+
294+
token = use_auth_token
295+
use_auth_token = None
296+
276297
# locates a file in a local folder and repo, downloads and cache it if necessary.
277298
model_path = Path(model_path)
278299
if model_path.is_dir():
@@ -288,7 +309,6 @@ def _cached_file(
288309
repo_id=model_path.as_posix(),
289310
filename=file_name.as_posix(),
290311
subfolder=subfolder,
291-
use_auth_token=use_auth_token,
292312
token=token,
293313
revision=revision,
294314
cache_dir=cache_dir,
@@ -338,6 +358,17 @@ def _from_transformers(
338358
kwargs (`Dict`, *optional*):
339359
kwargs will be passed to the model during initialization
340360
"""
361+
if use_auth_token is not None:
362+
logger.warning(
363+
"The `use_auth_token` argument is deprecated and will be removed soon. "
364+
"Please use the `token` argument instead."
365+
)
366+
if token is not None:
367+
raise ValueError("You cannot use both `use_auth_token` and `token` arguments at the same time.")
368+
369+
token = use_auth_token
370+
use_auth_token = None
371+
341372
save_dir = TemporaryDirectory()
342373
save_dir_path = Path(save_dir.name)
343374

@@ -354,7 +385,6 @@ def _from_transformers(
354385
subfolder=subfolder,
355386
revision=revision,
356387
cache_dir=cache_dir,
357-
use_auth_token=use_auth_token,
358388
token=token,
359389
local_files_only=local_files_only,
360390
force_download=force_download,
@@ -386,6 +416,17 @@ def _to_load(
386416
stateful: bool = False,
387417
**kwargs,
388418
):
419+
if use_auth_token is not None:
420+
logger.warning(
421+
"The `use_auth_token` argument is deprecated and will be removed soon. "
422+
"Please use the `token` argument instead."
423+
)
424+
if token is not None:
425+
raise ValueError("You cannot use both `use_auth_token` and `token` arguments at the same time.")
426+
427+
token = use_auth_token
428+
use_auth_token = None
429+
389430
save_dir = TemporaryDirectory()
390431
save_dir_path = Path(save_dir.name)
391432

@@ -402,7 +443,6 @@ def _to_load(
402443
model_id=save_dir_path,
403444
config=config,
404445
from_onnx=False,
405-
use_auth_token=use_auth_token,
406446
token=token,
407447
revision=revision,
408448
force_download=force_download,

0 commit comments

Comments
 (0)