Skip to content

AttributeError: 'TrainingArguments' object has no attribute 'packing' #qlora, STFTrainer #unsloth #31280

@gulsumbudakoglu

Description

@gulsumbudakoglu

System Info

I use the SFTTrainer for my qlora fine-tuning for Mistral Instruct 2 model. I use unsloth to make my training faster. I have run the code multiple times before but today I got the AttributeError: 'TrainingArguments' object has no attribute 'packing' error immediatly.
Are there anyone who got the same error and know the solution?

Thank a lot!

I run my code on colab -T4
I have used the following libraries:

!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
!pip install --no-deps xformers trl peft accelerate bitsandbytes

my error explanation also:

AttributeError                            Traceback (most recent call last)
[<ipython-input-22-fee37d14dff4>](https://localhost:8080/#) in <cell line: 13>()
     11 
     12 
---> 13 trainer = SFTTrainer(
     14     model = model,
     15     tokenizer = tokenizer,

1 frames
[/usr/local/lib/python3.10/dist-packages/trl/trainer/sft_trainer.py](https://localhost:8080/#) in __init__(self, model, args, data_collator, train_dataset, eval_dataset, tokenizer, model_init, compute_metrics, callbacks, optimizers, preprocess_logits_for_metrics, peft_config, dataset_text_field, packing, formatting_func, max_seq_length, infinite, num_of_sequences, chars_per_token, dataset_num_proc, dataset_batch_size, neftune_noise_alpha, model_init_kwargs, dataset_kwargs, eval_packing)
    187             args.eval_packing = eval_packing
    188 
--> 189         if args.packing and data_collator is not None and isinstance(data_collator, DataCollatorForCompletionOnlyLM):
    190             raise ValueError(
    191                 "You passed a `DataCollatorForCompletionOnlyLM` to the SFTTrainer. This is not compatible with the `packing` argument."

AttributeError: 'TrainingArguments' object has no attribute 'packing'

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

trainer = SFTTrainer(
    model=model,
    tokenizer=tokenizer,
    train_dataset=train_data,
    dataset_text_field="text",
    max_seq_length=max_seq_length,
    dataset_num_proc=2,
    packing=False,  # Can make training 5x faster for short sequences.
    args=TrainingArguments(
        per_device_train_batch_size=2,
        gradient_accumulation_steps=4,
        warmup_steps=5,
        max_steps=60,  # Set num_train_epochs = 1 for full training runs
        learning_rate=2e-4,
        fp16=not is_bfloat16_supported(),
        bf16=is_bfloat16_supported(),
        logging_steps=1,
        optim="adamw_8bit",
        weight_decay=0.01,
        lr_scheduler_type="linear",
        seed=3407,
        save_steps=1,
        output_dir=output_dir,
    ),
)

Expected behavior

My code should run without error which is AttributeError: 'TrainingArguments' object has no attribute 'packing'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions