Skip to content

FineTuning AutoModelForSequenceClassification.from_pretrained(meta-llama/Llama-3.2-1B) Bug:RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:1 and cuda:0! (when checking argument for argument target in method wrapper_CUDA_nll_loss_forward) and awq importing - #35365

Open
alestrami wants to merge 6 commits into
huggingface:mainfrom
alestrami:main

Conversation

@alestrami

Copy link
Copy Markdown

What does this PR do?

Fixes # (issue)

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

I added two contributions.

  1. The first one regarding the mismatch about the batch of the devices then training the model with the attribute device_map='auto'. Discussed here for AutoModelForSequenceClassification.from_pretrained. Thasnks to [hust] who provided the solution. Working also in my case with llama 3.3 1B https://discuss.huggingface.co/t/fine-tune-meta-llama-llama-2-7b-hf-bug-expected-all-tensors-to-be-on-the-same-device-but-found-at-least-two-devices-cuda-1-and-cuda-0-when-checking-argument-for-argument-target-in-method-wrapper-cuda-nll-loss-forward/129341/1
  2. The seconds is regarding the checking of availability of the package awq for loading quantized models. 'problems importing in awq # importlib.metadata.version doesn't work with awq (line 144 src/transformers/utils/import_utils.py) . mportlib.metadata.version(pkg_name) works with 'autoawq' and not 'awq' while importlib.util.find_spec("awq") works only with awq and not autoawq. Both of thems need to be taken into account (is the same package)

@ArthurZucker ArthurZucker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I think we can have a more general fix in the linked PR, but thanks for jumping on this quickly!

Comment thread src/transformers/models/llama/modeling_llama.py
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

Successfully merging this pull request may close these issues.

2 participants