From c998f8b8a0ad6e6d91b8fe81a0aa127681cd52ca Mon Sep 17 00:00:00 2001 From: Benjamin Bossan Date: Wed, 8 Oct 2025 11:28:47 +0200 Subject: [PATCH 1/4] [WIP] Testing transformers deprecations DON'T MERGE Check if/how often PEFT triggers transformers FutureWarning or DeprecationWarning by converting these warnings into failures. Note that there will be many false negatives, as transformers uses logger.warning frequently, which will not trigger a failure. --- .github/workflows/tests.yml | 4 ++-- pyproject.toml | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 655189c7c3..6babb4bee7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -40,8 +40,8 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11", "3.12", "3.13"] - os: ["ubuntu-latest", "macos-13", "windows-latest"] + python-version: ["3.13"] + os: ["ubuntu-latest"] exclude: - os: macos-13 python-version: "3.13" diff --git a/pyproject.toml b/pyproject.toml index 4f09d81e44..76c7294107 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,3 +49,8 @@ markers = [ "regression: whether to run regression suite test", "bitsandbytes: select bitsandbytes integration tests" ] + +filterwarnings = [ + "error::DeprecationWarning:transformers", + "error::FutureWarning:transformers", +] From 4e9657ee15f6aaa6dbc173c9c66caae41965a6de Mon Sep 17 00:00:00 2001 From: Benjamin Bossan Date: Wed, 8 Oct 2025 11:42:27 +0200 Subject: [PATCH 2/4] Also check log messages for deprecations --- tests/conftest.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index e4ee39b69e..852242a8ea 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging import platform import re @@ -25,6 +26,20 @@ def pytest_addoption(parser): def pytest_configure(config): config.addinivalue_line("markers", "regression: mark regression tests") + # Errors from transformers deprecations + logger = logging.getLogger("transformers") + + class ErrorOnDeprecation(logging.Handler): + def emit(self, record): + msg = record.getMessage().lower() + if "deprecat" in msg or "future" in msg.lower(): + raise AssertionError(f"**Transformers Deprecation**: {msg}") + + # Add our handler + handler = ErrorOnDeprecation() + logger.addHandler(handler) + logger.setLevel(logging.WARNING) + def pytest_collection_modifyitems(config, items): if config.getoption("--regression"): From 451d37094a5a371fe882728f83bfcb45dddfb0b3 Mon Sep 17 00:00:00 2001 From: Benjamin Bossan Date: Wed, 8 Oct 2025 12:27:53 +0200 Subject: [PATCH 3/4] Ignore torch_dtype deprecation --- tests/conftest.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 852242a8ea..866ae88536 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -32,8 +32,10 @@ def pytest_configure(config): class ErrorOnDeprecation(logging.Handler): def emit(self, record): msg = record.getMessage().lower() - if "deprecat" in msg or "future" in msg.lower(): - raise AssertionError(f"**Transformers Deprecation**: {msg}") + if "deprecat" in msg or "future" in msg: + if "torch_dtype" not in msg: + # let's ignore the torch_dtype => dtype deprecation for now + raise AssertionError(f"**Transformers Deprecation**: {msg}") # Add our handler handler = ErrorOnDeprecation() From 366bd290df48384857c67d36923040159114d24e Mon Sep 17 00:00:00 2001 From: Benjamin Bossan Date: Wed, 8 Oct 2025 13:45:08 +0200 Subject: [PATCH 4/4] Test full matrix --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6babb4bee7..655189c7c3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -40,8 +40,8 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.13"] - os: ["ubuntu-latest"] + python-version: ["3.10", "3.11", "3.12", "3.13"] + os: ["ubuntu-latest", "macos-13", "windows-latest"] exclude: - os: macos-13 python-version: "3.13"