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

bug: sft_trainer.py::train() raises exception due to change in transformers 4.38.0 #62

Closed
1 task
VassilisVassiliadis opened this issue Feb 27, 2024 · 2 comments

Comments

@VassilisVassiliadis
Copy link
Contributor

VassilisVassiliadis commented Feb 27, 2024

Issue

The __init__() method of the transformers SFTTrainer class raises an exception when using the latest commit of fms-hf-tuning (f4e8eb4) and transformers>=4.38.0.

Context

  • Currently, the dependency to transformers in the requirements.txt file is transformers>=4.34.1
  • The commit that makes fms-hf-tuning incompatible with transformers is huggingface/transformers@5f06053
    • this got released at v 4.38.0

Possible solutions

  1. Update fms-hf-tuning source code to be compatible with transformers>=4.38.0
  2. Update requirements.txt so that it uses transformers<4.38.0

Done when

  • sft_trainer.py works with the dependencies that get installed when installing fms-hf-tuning

Example:

commit: f4e8eb4

model="hf-tiny-model-private/tiny-random-BloomForCausalLM"
python tuning/sft_trainer.py --output_dir tuned --model_name_or_path ${model} --use_flash_attn=false --num_train_epochs 5 \
        --evaluation_strategy no --response_template "\n### Response" --dataset_text_field output --tokenizer_name_or_path ${model} \
        --torch_dtype float32 --data_path common_en_news_combined_512-preprocessed.jsonl \
         --target_modules all-linear --peft_method lora 

Exception:

Traceback (most recent call last):
  File "/projects/fms-hf-tuning/tuning/sft_trainer.py", line 308, in <module>
    fire.Fire(main)
  File "/projects/fms-hf-tuning/venv/lib/python3.10/site-packages/fire/core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/projects/fms-hf-tuning/venv/lib/python3.10/site-packages/fire/core.py", line 475, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/projects/fms-hf-tuning/venv/lib/python3.10/site-packages/fire/core.py", line 691, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "/projects/fms-hf-tuning/tuning/sft_trainer.py", line 304, in main
    train(model_args, data_args, training_args, tune_config)
  File "/projects/fms-hf-tuning/tuning/sft_trainer.py", line 252, in train
    trainer = SFTTrainer(
  File "/projects/fms-hf-tuning/venv/lib/python3.10/site-packages/trl/trainer/sft_trainer.py", line 295, in __init__
    super().__init__(
  File "/projects/fms-hf-tuning/venv/lib/python3.10/site-packages/transformers/trainer.py", line 648, in __init__
    self.is_fsdp_xla_v2_enabled = args.fsdp_config["xla_fsdp_v2"]
KeyError: 'xla_fsdp_v2'
@fabianlim
Copy link
Collaborator

fabianlim commented Feb 27, 2024

@VassilisVassiliadis this is addressed by #53 . As i had mentioned in that PR, best to avoid these manual adjustments of training args.

Limiting transformers<4.38.0 is a bad idea. That means you never take in new fixes. And the bug is a result of our code, not the package.

@VassilisVassiliadis
Copy link
Contributor Author

Thank you, I also prefer that fms-hf-tuning works with the latest version of transformers too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants