Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,23 @@
from peft import LoraConfig
from transformers import DataCollatorForSeq2Seq, TrainingArguments
from transformers.trainer_utils import RemoveColumnsCollator
from trl import ( # pylint: disable=import-error, no-name-in-module
DataCollatorForCompletionOnlyLM,
)
import torch

# Handle trl version compatibility
# In trl < 0.19: DataCollatorForCompletionOnlyLM
# In trl >= 0.19: May be renamed or moved
try:
# pylint: disable=import-error, no-name-in-module
from trl import DataCollatorForCompletionOnlyLM
except ImportError:
# Fallback for newer trl versions where it might be renamed
try:
from trl.trainer.utils import DataCollatorForCompletionOnlyLM
except ImportError:
# If still not available, create a placeholder that will never match
# This allows the plugin to load even if this specific collator isn't used
DataCollatorForCompletionOnlyLM = type('DataCollatorForCompletionOnlyLM', (), {})


class PaddingFreeAccelerationPlugin(AccelerationPlugin):

Expand Down
Loading