Skip to content

v4.41.2 default_data_collator import torch bug #42316

@AdrianMoen

Description

@AdrianMoen

System Info

Transformers v4.41.2
Python v3.11.9
Linux (wsl2)

Discovered when finetuning phi3-mini-128k-instruct and doing custom masking of the dataset

There seems to be a hanging debug check in the default_data_collator method that is not present in the v4.41-release branch code, where it has been removed.
This debug check uses the torch module, but it is not imported at that point during runtime.

Nevertheless its present in at least v4.41.2

Couldn't find the source code for v4.41.2 specifically so creating this issue instead

Who can help?

@Rocketknight1
@sgugger
@sdwalker62
@aromans

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

  1. Setup a finetuning environment, with arbitrary training data
  2. Create labels with masking
  3. The batch should then include "labels" as a key, and it should have one or more values
  4. use the default_data_collator from transformers library
  5. you should get a NameError: name 'torch' is not defined

Expected behavior

The debug check should be removed as it does not influence the outcome at all, as we can see in the official v4.41-release branch

Source of bug found at line 93 to 106 in transformers/data/data_collator.py under the default_data_collator method

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions