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

PEFT to ONNX conversion #2189

Open
1 of 4 tasks
morteza89 opened this issue Feb 13, 2025 · 0 comments
Open
1 of 4 tasks

PEFT to ONNX conversion #2189

morteza89 opened this issue Feb 13, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@morteza89
Copy link

System Info

Hello! 
I have a fine-tuned LLM model from Hugging Face saved in PEFT format, and it’s about 2.1 GB. When we convert it to ONNX, its size nearly doubles to about 4.1 GB. What causes this significant increase in model size after converting from PEFT to ONNX? Is there any bug under this conversion? ( Here is the code do this conversion. Need to mention: loading it in any commented formats will kill the accuracy). Thanks

model = ORTModelForCausalLM.from_pretrained(
            peft_path,
            provider='OpenVINOExecutionProvider',
            provider_options={'device_type': 'GPU_FP16'},
            # use_cache=False,
            #use_io_binding=False
            export=True,
            #load_in_4bit=True,
            #load_in_8bit=True
            #torch_dtype=torch.bfloat16,
            #device_map=device,
            #from_transformers=True
        )
tokenizer = AutoTokenizer.from_pretrained(peft_path)
model.save_pretrained(onnex_path)
tokenizer.save_pretrained(onnex_path)

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)

model = ORTModelForCausalLM.from_pretrained(
peft_path,
provider='OpenVINOExecutionProvider',
provider_options={'device_type': 'GPU_FP16'},
# use_cache=False,
#use_io_binding=False
export=True,
#load_in_4bit=True,
#load_in_8bit=True
#torch_dtype=torch.bfloat16,
#device_map=device,
#from_transformers=True
)
tokenizer = AutoTokenizer.from_pretrained(peft_path)
model.save_pretrained(onnex_path)
tokenizer.save_pretrained(onnex_path)

Expected behavior

I need to have the OONX model with at least the same size while not loosing accuracy performance.

@morteza89 morteza89 added the bug Something isn't working label Feb 13, 2025
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