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

convert-llama-ggmlv3-to-gguf: Try to handle files older than GGJTv3 #3023

Merged

Conversation

KerfuffleV2
Copy link
Collaborator

@KerfuffleV2 KerfuffleV2 commented Sep 5, 2023

  • Better error messages for files that cannot be converted

  • Add file type to GGUF output

Closes #2990

Better error messages for files that cannot be converted

Add file type to GGUF output
@KerfuffleV2
Copy link
Collaborator Author

I'll hold off merging this for a bit until I get some feedback from the people with older GGML files.

@cebtenzzre
Copy link
Collaborator

Isn't the name of the script technically inaccurate now? Maybe we should at least add something to --help to indicate to users that certain pre-GGMLv3 files are supported as well.

@cebtenzzre cebtenzzre mentioned this pull request Sep 5, 2023
@KerfuffleV2
Copy link
Collaborator Author

Isn't the name of the script technically inaccurate now?

Not just technically. :) I kind of wanted to just rename it, but I felt like that would be pretty confusing for existing users.

Maybe we should at least add something to --help

Sure, that's not a bad idea. It seems like for the most part, users don't really know the exact type of file they have anyway and will just try to run the script but some additional information certainly can't hurt.

@KerfuffleV2
Copy link
Collaborator Author

You know what, I think I will just rename the file since ggmlv3 is wrong to start with. I don't know what I was thinking.

Include original file type information in description
Comment on lines 177 to 180
if (self.file_format < GGMLFormat.GGJT or self.format_version < 2) and ftype not in (GGMLFType.ALL_F32, GGMLFType.MOSTLY_F16):
raise ValueError(f'Quantizations changed in GGJTv2. Can only convert unquantized GGML files older than GGJTv2. Sorry, your {self.file_format.name}v{self.format_version} file of type {ftype.name} is not eligible for conversion.')
if (self.file_format == GGMLFormat.GGJT and self.format_version == 2) and ftype in (GGMLFType.MOSTLY_Q4_0, GGMLFType.MOSTLY_Q4_1, GGMLFType.MOSTLY_Q4_1_SOME_F16, GGMLFType.MOSTLY_Q8_0):
raise ValueError(f'Q4 and Q8 quantizations changed in GGJTv3. Sorry, your {self.file_format.name}v{self.format_version} file of type {ftype.name} is not eligible for conversion.')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lines of code should be at most 120 chars wide, for readability:

Suggested change
if (self.file_format < GGMLFormat.GGJT or self.format_version < 2) and ftype not in (GGMLFType.ALL_F32, GGMLFType.MOSTLY_F16):
raise ValueError(f'Quantizations changed in GGJTv2. Can only convert unquantized GGML files older than GGJTv2. Sorry, your {self.file_format.name}v{self.format_version} file of type {ftype.name} is not eligible for conversion.')
if (self.file_format == GGMLFormat.GGJT and self.format_version == 2) and ftype in (GGMLFType.MOSTLY_Q4_0, GGMLFType.MOSTLY_Q4_1, GGMLFType.MOSTLY_Q4_1_SOME_F16, GGMLFType.MOSTLY_Q8_0):
raise ValueError(f'Q4 and Q8 quantizations changed in GGJTv3. Sorry, your {self.file_format.name}v{self.format_version} file of type {ftype.name} is not eligible for conversion.')
if ($
(self.file_format < GGMLFormat.GGJT or self.format_version < 2)$
and ftype not in (GGMLFType.ALL_F32, GGMLFType.MOSTLY_F16)$
):$
raise ValueError($
'Quantizations changed in GGJTv2. Can only convert unquantized GGML files older than GGJTv2. Sorry, '$
f'your {self.file_format.name}v{self.format_version} file of type {ftype.name} is not eligible for '$
'conversion.'$
)$
if ($
self.file_format == GGMLFormat.GGJT and self.format_version == 2$
and ftype in ($
GGMLFType.MOSTLY_Q4_0, GGMLFType.MOSTLY_Q4_1, GGMLFType.MOSTLY_Q4_1_SOME_F16, GGMLFType.MOSTLY_Q8_0,$
)$
):$
raise ValueError($
f'Q4 and Q8 quantizations changed in GGJTv3. Sorry, your {self.file_format.name}v{self.format_version} '$
f'file of type {ftype.name} is not eligible for conversion.'$
)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the feedback.

In this particular case, I'm honestly not sure putting the time into improving the formatting is really worth it. I doubt anyone else is going to be messing with this script, and it's probably not even going to be in the repo in a month or so. But I made some formatting cleanups anyway.

Formatting changes to clean up some long lines
@KerfuffleV2 KerfuffleV2 merged commit ea2c85d into ggerganov:master Sep 6, 2023
@KerfuffleV2 KerfuffleV2 deleted the feat-ggml-convert-improvements branch November 17, 2023 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
script Script related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Converting GGML->GGUF: ValueError: Only GGJTv3 supported
3 participants