Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitsandbytes integration in ORTModelForCausalLM.from_pretrained() #1664

Open
4 tasks
pradeepdev-1995 opened this issue Jan 23, 2024 · 0 comments
Open
4 tasks
Labels
bug Something isn't working

Comments

@pradeepdev-1995
Copy link

System Info

optimum==1.17.0.dev0

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 (minimal, reproducible, runnable)

The given code

from optimum.onnxruntime import ORTModelForCausalLM
from transformers import BitsAndBytesConfig
finetuned_model_name = "path"
import torch
compute_dtype = getattr(torch, "float16")
bnb_config = BitsAndBytesConfig(load_in_4bit=True,
                                bnb_4bit_quant_type="nf4",
                                bnb_4bit_compute_dtype=compute_dtype,
                                bnb_4bit_use_double_quant=False)
ort_model = ORTModelForCausalLM.from_pretrained(
    finetuned_model_name,
    use_io_binding=True,
    quantization_config=bnb_config,
    export=True,
    use_cache=True,
    from_transformers=True
)

shows the errror

TypeError: _from_transformers() got an unexpected keyword argument 'quantization_config'

so how to do quantization while loading with ORTModelForCausalLM

Expected behavior

The given code

from optimum.onnxruntime import ORTModelForCausalLM
from transformers import BitsAndBytesConfig
finetuned_model_name = "path"
import torch
compute_dtype = getattr(torch, "float16")
bnb_config = BitsAndBytesConfig(load_in_4bit=True,
                                bnb_4bit_quant_type="nf4",
                                bnb_4bit_compute_dtype=compute_dtype,
                                bnb_4bit_use_double_quant=False)
ort_model = ORTModelForCausalLM.from_pretrained(
    finetuned_model_name,
    use_io_binding=True,
    quantization_config=bnb_config,
    export=True,
    use_cache=True,
    from_transformers=True
)

shows the errror

TypeError: _from_transformers() got an unexpected keyword argument 'quantization_config'

so how to do quantization while loading with ORTModelForCausalLM

@pradeepdev-1995 pradeepdev-1995 added the bug Something isn't working label Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant