|
8 | 8 | import itertools |
9 | 9 | import re |
10 | 10 | import time |
11 | | -import warnings |
12 | 11 | from functools import reduce |
13 | 12 | from importlib.metadata import version |
14 | 13 | from math import gcd |
|
35 | 34 | "is_sm_at_least_100", |
36 | 35 | "is_package_at_least", |
37 | 36 | "DummyModule", |
38 | | - # Deprecated |
39 | | - "TORCH_VERSION_AT_LEAST_2_2", |
40 | | - "TORCH_VERSION_AT_LEAST_2_3", |
41 | | - "TORCH_VERSION_AT_LEAST_2_4", |
42 | | - "TORCH_VERSION_AT_LEAST_2_5", |
43 | | - "TORCH_VERSION_AT_LEAST_2_6", |
44 | | - "TORCH_VERSION_AT_LEAST_2_7", |
45 | | - "TORCH_VERSION_AFTER_2_2", |
46 | | - "TORCH_VERSION_AFTER_2_3", |
47 | | - "TORCH_VERSION_AFTER_2_4", |
48 | | - "TORCH_VERSION_AFTER_2_5", |
49 | 37 | ] |
50 | 38 |
|
51 | 39 |
|
@@ -379,80 +367,6 @@ def torch_version_at_least(min_version): |
379 | 367 | return parse_version(torch.__version__) >= parse_version(min_version) |
380 | 368 |
|
381 | 369 |
|
382 | | -def _deprecated_torch_version_at_least(version_str: str) -> str: |
383 | | - """ |
384 | | - Wrapper for existing TORCH_VERSION_AT_LEAST* variables that will log |
385 | | - a deprecation warning if the variable is used. |
386 | | - """ |
387 | | - version_str_var_name = "_".join(version_str.split(".")[:2]) |
388 | | - deprecation_msg = f"TORCH_VERSION_AT_LEAST_{version_str_var_name} is deprecated and will be removed in torchao 0.14.0" |
389 | | - return _BoolDeprecationWrapper( |
390 | | - torch_version_at_least(version_str), |
391 | | - deprecation_msg, |
392 | | - ) |
393 | | - |
394 | | - |
395 | | -def _deprecated_torch_version_after(version_str: str) -> str: |
396 | | - """ |
397 | | - Wrapper for existing TORCH_VERSION_AFTER* variables that will log |
398 | | - a deprecation warning if the variable is used. |
399 | | - """ |
400 | | - bool_value = is_fbcode() or version("torch") >= version_str |
401 | | - version_str_var_name = "_".join(version_str.split(".")[:2]) |
402 | | - deprecation_msg = f"TORCH_VERSION_AFTER_{version_str_var_name} is deprecated and will be removed in torchao 0.14.0" |
403 | | - return _BoolDeprecationWrapper(bool_value, deprecation_msg) |
404 | | - |
405 | | - |
406 | | -class _BoolDeprecationWrapper: |
407 | | - """ |
408 | | - A deprecation wrapper that logs a warning when the given bool value is accessed. |
409 | | - """ |
410 | | - |
411 | | - def __init__(self, bool_value: bool, msg: str): |
412 | | - self.bool_value = bool_value |
413 | | - self.msg = msg |
414 | | - |
415 | | - def __bool__(self): |
416 | | - warnings.warn(self.msg) |
417 | | - return self.bool_value |
418 | | - |
419 | | - def __eq__(self, other): |
420 | | - return bool(self) == bool(other) |
421 | | - |
422 | | - |
423 | | -# Deprecated, use `torch_version_at_least` directly instead |
424 | | -TORCH_VERSION_AT_LEAST_2_8 = _deprecated_torch_version_at_least("2.8.0") |
425 | | -TORCH_VERSION_AT_LEAST_2_7 = _deprecated_torch_version_at_least("2.7.0") |
426 | | -TORCH_VERSION_AT_LEAST_2_6 = _deprecated_torch_version_at_least("2.6.0") |
427 | | -TORCH_VERSION_AT_LEAST_2_5 = _deprecated_torch_version_at_least("2.5.0") |
428 | | -TORCH_VERSION_AT_LEAST_2_4 = _deprecated_torch_version_at_least("2.4.0") |
429 | | -TORCH_VERSION_AT_LEAST_2_3 = _deprecated_torch_version_at_least("2.3.0") |
430 | | -TORCH_VERSION_AT_LEAST_2_2 = _deprecated_torch_version_at_least("2.2.0") |
431 | | -TORCH_VERSION_AFTER_2_5 = _deprecated_torch_version_after("2.5.0.dev") |
432 | | -TORCH_VERSION_AFTER_2_4 = _deprecated_torch_version_after("2.4.0.dev") |
433 | | -TORCH_VERSION_AFTER_2_3 = _deprecated_torch_version_after("2.3.0.dev") |
434 | | -TORCH_VERSION_AFTER_2_2 = _deprecated_torch_version_after("2.2.0.dev") |
435 | | - |
436 | | - |
437 | | -class _ConfigDeprecationWrapper: |
438 | | - """ |
439 | | - A deprecation wrapper that directs users from a deprecated "config function" |
440 | | - (e.g. `int4_weight_only`) to the replacement config class. |
441 | | - """ |
442 | | - |
443 | | - def __init__(self, deprecated_name: str, config_cls: Type): |
444 | | - self.deprecated_name = deprecated_name |
445 | | - self.config_cls = config_cls |
446 | | - |
447 | | - def __call__(self, *args, **kwargs): |
448 | | - warnings.warn( |
449 | | - f"`{self.deprecated_name}` is deprecated and will be removed in a future release. " |
450 | | - f"Please use `{self.config_cls.__name__}` instead. Example usage:\n" |
451 | | - f" quantize_(model, {self.config_cls.__name__}(...))" |
452 | | - ) |
453 | | - return self.config_cls(*args, **kwargs) |
454 | | - |
455 | | - |
456 | 370 | """ |
457 | 371 | Helper function for implementing aten op or torch function dispatch |
458 | 372 | and dispatching to these implementations. |
|
0 commit comments