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
5 changes: 1 addition & 4 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,7 @@ disable=raw-checker-failed,
duplicate-code,
unbalanced-tuple-unpacking,
unspecified-encoding,
too-many-lines,
no-name-in-module,
unexpected-keyword-arg,
unused-argument
too-many-lines

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
7 changes: 1 addition & 6 deletions build/accelerate_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,14 @@ def main():
# message to termination log.
logging.error(traceback.format_exc())
# The exit code that sft_trainer.py threw is captured in e.returncode

return_code = e.returncode
if return_code not in [INTERNAL_ERROR_EXIT_CODE, USER_ERROR_EXIT_CODE]:
return_code = INTERNAL_ERROR_EXIT_CODE
write_termination_log(f"Unhandled exception during training. {e}")
sys.exit(return_code)
except Exception as e: # pylint: disable=broad-except
logging.error(traceback.format_exc())
# v5: torch.distributed raises ChildFailedError with per-rank exit codes
# Check if the root cause was a user error
if hasattr(e, "failures"):
root_codes = [f.exitcode for f in e.failures.values()]
if any(c == USER_ERROR_EXIT_CODE for c in root_codes):
sys.exit(USER_ERROR_EXIT_CODE)
write_termination_log(f"Unhandled exception during training. {e}")
sys.exit(INTERNAL_ERROR_EXIT_CODE)

Expand Down
15 changes: 7 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,18 @@ classifiers=[
dependencies = [
"numpy>=1.26.4,<2.2.0",
"accelerate>=1.9.0,<2.0.0",
"transformers>=5.2.0,<5.3.0",
"torch>2.7.0,<=2.9.0",
"torchvision<=0.24.0",
"transformers>=4.55.0,<=4.55.4",
"torch>2.7.0,<2.9.0",
"torchvision<0.24",
"sentencepiece>=0.1.99,<0.3",
"tokenizers<=0.23.0",
"tokenizers<=0.22",
"tqdm>=4.66.2,<5.0",
"trl>=0.27.0,<0.29.0",
"peft>=0.18.1,<0.19.0",
"trl>=0.19.1,<0.20.0",
"peft>=0.18.0,< 0.19.0",
"datasets>=4.0.0,<5.0.0",
"simpleeval>=0.9.13,<2.0",
"pillow>=12.1.1",
"kernels>=0.12.1,<0.13.0",
"huggingface_hub>=1.3.0,<1.4.0",
"kernels<=0.9.0",
]

[project.optional-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion tests/build/test_launch_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"warmup_ratio": 0.03,
"lr_scheduler_type": "cosine",
"logging_steps": 1,
"include_num_input_tokens_seen": True,
"include_tokens_per_second": True,
"packing": False,
"response_template": "\n### Label:",
"dataset_text_field": "output",
Expand Down
3 changes: 2 additions & 1 deletion tests/data/test_data_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from datasets import Dataset, DatasetDict, IterableDataset
from PIL import Image
from transformers import AutoProcessor, AutoTokenizer, DataCollatorForSeq2Seq
from trl import DataCollatorForCompletionOnlyLM
import datasets
import numpy as np
import pyarrow
Expand Down Expand Up @@ -68,7 +69,7 @@
# Local
from tuning.config import configs
from tuning.config.acceleration_configs import AttentionAndDistributedPackingConfig
from tuning.data.collators import DataCollatorForCompletionOnlyLM, VisionDataCollator
from tuning.data.collators import VisionDataCollator
from tuning.data.data_config import (
DataHandlerConfig,
DataPreProcessorConfig,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_sft_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
warmup_ratio=0.03,
lr_scheduler_type="cosine",
logging_steps=1,
include_num_input_tokens_seen=True,
include_tokens_per_second=True,
packing=False,
max_seq_length=4096,
save_strategy="epoch",
Expand All @@ -140,7 +140,7 @@
warmup_ratio=0.03,
lr_scheduler_type="cosine",
logging_steps=1,
include_num_input_tokens_seen=True,
include_tokens_per_second=True,
packing=False,
max_seq_length=4096,
save_strategy="epoch",
Expand Down
23 changes: 12 additions & 11 deletions tests/utils/test_embedding_resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@

# Third Party
from transformers import (
AutoModelForImageTextToText, # AutoModelForVision2Seq was renamed to this in transformers v5
AutoModelForCausalLM,
AutoModelForVision2Seq,
AutoProcessor,
AutoTokenizer,
)
from transformers import AutoModelForCausalLM, AutoProcessor, AutoTokenizer
import torch

# First Party
Expand Down Expand Up @@ -126,17 +128,16 @@ def test_special_tokens_before_and_after():
model = AutoModelForCausalLM.from_pretrained(MODEL_NAME)

input_tokenizer_len = len(tokenizer.get_vocab())
addn_spl_tokens_before = list(tokenizer.extra_special_tokens)
addn_spl_tokens_before = tokenizer.special_tokens_map.get(
"additional_special_tokens"
)
assert (
len(addn_spl_tokens_before) > 0
), "this test needs tokenizer special tokens to not be empty before testing"

special_tokens_dict = {"sep_token": "<SEP>", "pad_token": "<PAD>"}
addn_spl_tokens_added = ["<NotSeenTokenA>", "<NotSeenTokenB>", "<NotSeenTokenC>"]
# for transformers v5: merge existing extra_special_tokens with new ones to prevent replacement
special_tokens_dict["additional_special_tokens"] = (
list(tokenizer.extra_special_tokens) + addn_spl_tokens_added
)
special_tokens_dict["additional_special_tokens"] = addn_spl_tokens_added

resize_result = tokenizer_and_embedding_resize(
special_tokens_dict=special_tokens_dict,
Expand All @@ -149,7 +150,9 @@ def test_special_tokens_before_and_after():
addn_spl_tokens_before.extend(addn_spl_tokens_added)
expected_addn_special_tokens = addn_spl_tokens_before
expected_embedding_size = input_tokenizer_len + len(addn_spl_tokens_added) + 2
addn_spl_tokens_after = list(tokenizer.extra_special_tokens)
addn_spl_tokens_after = tokenizer.special_tokens_map.get(
"additional_special_tokens"
)

assert "<SEP>" in tokenizer.get_vocab()
assert "<PAD>" in tokenizer.get_vocab()
Expand Down Expand Up @@ -209,9 +212,7 @@ def test_resize_with_multiple_of():


def test_resize_llama_vision_model():
model = AutoModelForImageTextToText.from_pretrained(
TINY_LLAMA_VISION_MODEL_NAME
) # AutoModelForVision2Seq was renamed to AutoModelForImageTextToText in transformers v5
model = AutoModelForVision2Seq.from_pretrained(TINY_LLAMA_VISION_MODEL_NAME)
processor = AutoProcessor.from_pretrained(TINY_LLAMA_VISION_MODEL_NAME)
tokenizer = processor.tokenizer

Expand Down
Loading
Loading