Skip to content
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
16 changes: 16 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ def token(request):


def pytest_configure(config):
# Bitsandbytes installation for {test_bnb_qlora.py test_bnb_inference.py} tests
# This change will be reverted shortly
bnb_tests = any("bnb" in name for name in config.known_args_namespace.file_or_dir)
if bnb_tests:
import subprocess
import sys

subprocess.check_call(
[
sys.executable,
"-m",
"pip",
"install",
"git+https://github.com/bitsandbytes-foundation/bitsandbytes.git@multi-backend-refactor",
]
)
name = ""
try:
from optimum.habana.utils import get_device_name
Expand Down
16 changes: 0 additions & 16 deletions tests/test_bnb_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,6 @@ def get_model(token: str):

@pytest.mark.skipif("gaudi1" == OH_DEVICE_CONTEXT, reason="execution not supported on gaudi1")
def test_nf4_quantization_inference(token: str, baseline):
try:
import subprocess
import sys

subprocess.check_call(
[
sys.executable,
"-m",
"pip",
"install",
"git+https://github.com/bitsandbytes-foundation/bitsandbytes.git@multi-backend-refactor",
]
)
except subprocess.CalledProcessError:
pytest.fail("Failed to install bitsandbytes")

os.environ["PT_HPU_LAZY_MODE"] = "0"
from optimum.habana.transformers import modeling_utils

Expand Down
19 changes: 1 addition & 18 deletions tests/test_bnb_qlora.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
# limitations under the License.

import os
import subprocess

import pytest
import torch
from datasets import load_dataset
from peft import LoraConfig, get_peft_model, prepare_model_for_kbit_training
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, DataCollatorForLanguageModeling

from optimum.habana import GaudiConfig, GaudiTrainer, GaudiTrainingArguments
Expand Down Expand Up @@ -80,23 +80,6 @@ def get_model(token: str):

@pytest.mark.skipif("gaudi1" == OH_DEVICE_CONTEXT, reason="execution not supported on gaudi1")
def test_nf4_quantization_finetuning(token: str, baseline):
try:
import sys

subprocess.check_call(
[
sys.executable,
"-m",
"pip",
"install",
"peft==0.12.0",
"git+https://github.com/bitsandbytes-foundation/bitsandbytes.git@multi-backend-refactor",
]
)
from peft import LoraConfig, get_peft_model, prepare_model_for_kbit_training
except subprocess.CalledProcessError:
pytest.fail("Failed to install peft==0.12.0 / bitsandbytes")

os.environ["PT_HPU_LAZY_MODE"] = "0"
from optimum.habana.transformers import modeling_utils

Expand Down