-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
[Single File] Add GGUF support #9964
base: main
Are you sure you want to change the base?
Conversation
@@ -204,7 +204,10 @@ def create_quantized_param( | |||
|
|||
module._parameters[tensor_name] = new_value | |||
|
|||
def check_quantized_param_shape(self, param_name, current_param_shape, loaded_param_shape): | |||
def check_quantized_param_shape(self, param_name, current_param, loaded_param): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GGUF needs to access the tensor quant type to run a shape check. So this needs to change from passing in shapes to passing in params directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not add this method to the gguf_quantizer.py
file instead of modifying this? This would be a breaking change no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you're already adding this to the GGUF quantizer class. So, maybe okay to not modify this?
import torch.nn as nn | ||
|
||
|
||
def _replace_with_gguf_linear(model, compute_dtype): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GGUF files contain a mix of quantized linear and unquantized linear layers. It's not trivial to selectively replace layers. We can replace all of them and then check the parameter type when running forward instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
compute_dtype=compute_dtype, | ||
) | ||
model._modules[name].source_cls = type(module) | ||
# Force requires grad to False to avoid unexpected errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Force requires grad to False to avoid unexpected errors | |
# Force requires_grad to False to avoid unexpected errors |
What does this PR do?
Adds support for loading GGUF checkpoints via
from_single_file
.Notes:
from_pretrained
. GGUF files have enough metadata that we can automatically infer everything we need from the file itself. We don't really need a quantization config, but it becomes necessary as we expand to support to other quant loading methods (BnB, TorchAO etc)TODOS:
Fixes # (issue)
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
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.