Skip to content

Commit

Permalink
Merge pull request #411 from gkumbhat/update_packages_feb_14
Browse files Browse the repository at this point in the history
📦 Dependency updates
  • Loading branch information
gkumbhat authored Feb 18, 2025
2 parents cd44077 + 6cd31ed commit 69f99cb
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
# https://help.github.com/en/articles/about-code-owners
#

* @alex-jw-brooks @gkumbhat @evaline-ju @gabe-l-hart @tharapalanivel @Ssukriti
* @gkumbhat @evaline-ju @gabe-l-hart
8 changes: 6 additions & 2 deletions caikit_nlp/modules/text_embedding/crossencoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,10 @@ def __init__(
num_labels: int = None,
max_length: int = None,
device: str = None,
tokenizer_args: Dict = None,
automodel_args: Dict = None,
tokenizer_args: Dict = None,
config_args: Dict = None,
cache_dir: str = None,
trust_remote_code: bool = False,
revision: Optional[str] = None,
local_files_only: bool = False,
Expand All @@ -444,8 +446,10 @@ def __init__(
num_labels,
max_length,
device,
tokenizer_args,
automodel_args,
tokenizer_args,
config_args,
cache_dir,
trust_remote_code,
revision,
local_files_only,
Expand Down
4 changes: 4 additions & 0 deletions caikit_nlp/modules/text_generation/text_generation_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,10 @@ def _launch_training(
) -> None:
"""Utility function to wrap trainer and execute training"""

# gradient_accumulation_steps seems to be causing hang atleast on CPU training
# so we are removing it for now here
del training_args["gradient_accumulation_steps"]

trainer = base_model.get_trainer(
train_dataset=training_dataset, **training_args
)
Expand Down
5 changes: 4 additions & 1 deletion caikit_nlp/resources/pretrained_model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@


class LoggingTrainer(Trainer):
def log(self, logs: Dict[str, float]) -> None:
# pylint: disable=unused-argument
def log(self, logs: Dict[str, float], start_time: Optional[float] = None) -> None:
"""
Log `logs` on the various objects watching training.
Expand All @@ -58,6 +59,8 @@ def log(self, logs: Dict[str, float]) -> None:
logs (`Dict[str, float]`):
The values to log.
"""
# start_time was added in default trainer log
# https://github.com/huggingface/transformers/pull/34507
self.state = log_step(self.state, logs)
self.control = self.callback_handler.on_log(
self.args, self.state, self.control, logs
Expand Down
7 changes: 5 additions & 2 deletions caikit_nlp/resources/pretrained_model/hf_auto_seq2seq_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""
# Standard
from collections.abc import Mapping
from typing import Dict, List, Union
from typing import Dict, List, Optional, Union

# Third Party
from torch.utils.data import IterableDataset
Expand Down Expand Up @@ -46,7 +46,8 @@


class LoggingTrainer(Seq2SeqTrainer):
def log(self, logs: Dict[str, float]) -> None:
# pylint: disable=unused-argument
def log(self, logs: Dict[str, float], start_time: Optional[float] = None) -> None:
"""
Log `logs` on the various objects watching training.
Expand All @@ -56,6 +57,8 @@ def log(self, logs: Dict[str, float]) -> None:
logs (`Dict[str, float]`):
The values to log.
"""
# start_time was added in default trainer log
# https://github.com/huggingface/transformers/pull/34507
self.state = log_step(self.state, logs)
self.control = self.callback_handler.on_log(
self.args, self.state, self.control, logs
Expand Down
11 changes: 10 additions & 1 deletion examples/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,16 @@ def get_distributed_model(model_path):
"initializers": {
"default": {
"config": {
"backend_priority": [{"type": TGISBackend.backend_type}]
"backend_priority": [
{
"type": TGISBackend.backend_type,
"config": {
"connection": {
"hostname": "localhost:8033",
}
},
}
]
}
}
}
Expand Down
23 changes: 12 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ dependencies = [
"grpcio>=1.62.2", # explicitly pin grpc dependencies to a recent version to avoid pip backtracking
"grpcio-reflection>=1.62.2",
"grpcio-health-checking>=1.62.2",
"accelerate>=0.22.0",
"datasets>=2.4.0",
"accelerate>=1.3.0",
"datasets>=3.3.0",
"huggingface-hub",
"numpy>=1.22.4",
"pandas>=1.5.0",
"scikit-learn>=1.1",
"scipy>=1.8.1",
"sentence-transformers>=3.0.0,<3.1.0",
"tokenizers>=0.13.3",
"numpy>=1.23.0",
"pandas>=2.2.3",
"scikit-learn>=1.6.1",
"scipy>=1.10.0",
"sentence-transformers>=3.4.0,<3.5.0",
"tf-keras>=2.18.0",
"tokenizers>=0.20.0",
"torch>=2.3.1,<2.6.0",
"tqdm>=4.65.0",
"transformers>=4.38.0,<4.44.0",
"peft==0.6.0",
"tqdm>=4.67.0",
"transformers>=4.48.3,<4.50.0",
"peft==0.14.0",
]

[tool.setuptools.packages.find]
Expand Down
1 change: 0 additions & 1 deletion tests/modules/text_embedding/test_crossencoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,6 @@ def test_truncation(truncate_input_tokens, loaded_model):
queries_scores = [x.score for x in r.scores]
query_scores = [x.score for x in query_results[i].scores]
assert np.array_equal(queries_scores, query_scores)

# To compare scores based on the inputs, we need to use the index too
indexed_query_scores = {s.index: s.score for s in query_results[i].scores}

Expand Down
1 change: 0 additions & 1 deletion tests/modules/text_generation/test_peft_prompt_tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def test_run_stream_out_model(causal_lm_dummy_model):
pred_stream = causal_lm_dummy_model.run_stream_out("This text doesn't matter")
assert isinstance(pred_stream, Iterable)
for pred in pred_stream:
print(pred)
assert isinstance(pred, GeneratedTextStreamResult)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def test_train_model_causallm(disable_wip, set_cpu_device):


@pytest.mark.skipif(platform.processor() == "arm", reason="ARM training not supported")
def test_train_model_causallm(disable_wip, set_cpu_device):
def test_train_and_infer_model_causallm(disable_wip, set_cpu_device):
"""Ensure that we can finetune a causal-lm model on some toy data for 1+
steps & run inference."""
train_kwargs = {
Expand Down

0 comments on commit 69f99cb

Please sign in to comment.