optimum icon indicating copy to clipboard operation
optimum copied to clipboard

device set bug

Open Yuang-Deng opened this issue 1 year ago • 1 comments

System Info

optimum                  1.16.1

Who can help?

@philschmid

Information

  • [X] The official example scripts
  • [ ] My own modified scripts

Tasks

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

Reproduction (minimal, reproducible, runnable)

from transformers import AutoModelForCausalLM, AutoTokenizer, GPTQConfig

model_id = "facebook/opt-125m" tokenizer = AutoTokenizer.from_pretrained(model_id) quantization_config = GPTQConfig(bits=4, dataset=["c4", "c4", "c4"], tokenizer=tokenizer)

model = AutoModelForCausalLM.from_pretrained(model_id, device_map="cuda:5", quantization_config=quantization_config)

print()

Expected behavior

optimum/gptq/quantizer.py line 429 data[k] = v.to(0)

Why is it fixed at 0? When setting device_map for the model, an error occurs that the input and model are not on the same device. Is this a bug?

Yuang-Deng avatar Jan 03 '24 09:01 Yuang-Deng

Hi @Yuang-Deng happy to have a look, could you provide a full reproduction? I think your code snippet is truncated.

fxmarty avatar Jan 09 '24 10:01 fxmarty