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

[Feature] Support unit32 in save_gguf #814

Open
mzbac opened this issue Mar 10, 2024 · 4 comments
Open

[Feature] Support unit32 in save_gguf #814

mzbac opened this issue Mar 10, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@mzbac
Copy link
Contributor

mzbac commented Mar 10, 2024

While working on converting the quant MLX model to GGUF format, I noticed that we do not support uint32 in save_gguf. This makes it difficult to convert the quant mode given that the weight of quant models are in uint32 format. I am wondering if there is any chance we would support uint32 format in the save_gguf method?

the code to replicate the issue:

import mlx.core as mx


weights = {"test": (mx.ones(shape=(2,), dtype=mx.uint32))}


mx.save_gguf("mlx_model.gguf", weights)
@awni
Copy link
Member

awni commented Mar 10, 2024

So I think you're goal is to export weights, scales, and biases to GGUF without dequantizing so you can load them natively in llama.cpp right?

It is not quite so simple as enabling a uint32 format (which would actually be the wrong thing). GGUF stores quantized weights in a completely different format, and it is packed. So all three tensors (weights, scales, biases) would get packed into e.g. a q4_0 tensor. Doing that properly is a bit messy hence right now we don't really support exporting quantized models into GGUF.

@awni
Copy link
Member

awni commented Mar 10, 2024

I will leave this open as an enhancement to help prioritize when we can get to it. For the very short-term your best bet is exporting to fp16 (either safetensors or gguf) and then quantizing.

@awni awni added the enhancement New feature or request label Mar 10, 2024
@mzbac
Copy link
Contributor Author

mzbac commented Mar 10, 2024

I see, I thought that since we can load a quantized gguf format model without de-quantization in mlx, maybe we can directly convert mlx quant to gguf, which would be more beneficial than converting it to f16 gguf format and quantize it

@dc-dc-dc
Copy link
Contributor

Quick note, not sure if uint32 is a supported type in gguf, only see signed ints on the list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants