Repository navigation
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Contributor
|
There are some pending PRs w.r.t FP8 #28413. It is something we're planning to add to the project |
Collaborator
Contributor
Author
|
Thanks for the heads-up! I’ll take a look at #27512. In my experience, E4M3 is much more common for diffusion model weights. I do occasionally encounter E5M2 checkpoints, so support would be useful, but I wouldn’t consider it a high priority. Adding it as a follow-up sounds reasonable. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds CPU support for FP8, including the ability to load FP8 weights directly and convert them to FP16, BF16, or FP32.
Many diffusion models already support FP8, and some are even released with FP8 weights natively. On hardware with native FP8 support, FP8 computation can also be faster than FP16/BF16, so having proper FP8 support in GGML would be useful for both model loading and execution.
I'm not sure whether upstream would be happy with this approach, so for now I've only included the CPU-related changes in this PR. If this approach is acceptable, I can follow up with another PR that adds the conversion code for the other backends, as well as FP8
mul_matsupport for CUDA.This is the GGML implementation I'm currently using in
sd.cpp:For FP8 scale handling, my current idea is to keep the scale as a separate tensor instead of packing it into the FP8 tensor itself. I think this is more flexible and also reduces the maintenance burden.
Additional information
leejet/stable-diffusion.cpp#1913
leejet/stable-diffusion.cpp#1916
Requirements
ggmltollama.cpp.