Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test marker to run all tests with @require_bitsandbytes #28278

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ doctest_optionflags="NUMBER NORMALIZE_WHITESPACE ELLIPSIS"
doctest_glob="**/*.md"
markers = [
"flash_attn_test: marks tests related to flash attention (deselect with '-m \"not flash_attn_test\"')",
"bitsandbytes: select (or deselect with `not`) bitsandbytes integration tests",
Titus-von-Koeller marked this conversation as resolved.
Show resolved Hide resolved
]
12 changes: 10 additions & 2 deletions src/transformers/testing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,9 +966,17 @@ def require_aqlm(test_case):

def require_bitsandbytes(test_case):
"""
Decorator for bits and bytes (bnb) dependency
Decorator marking a test that requires the bitsandbytes library. Will be skipped when the library or its hard dependency torch is not installed.
"""
return unittest.skipUnless(is_bitsandbytes_available(), "test requires bnb")(test_case)
if is_bitsandbytes_available() and is_torch_available():
try:
import pytest

return pytest.mark.bitsandbytes(test_case)
except ImportError:
return test_case
else:
return unittest.skip("test requires bitsandbytes and torch")(test_case)


def require_optimum(test_case):
Expand Down
Loading