Skip to content

ggml : add FP8 types and CPU conversions - #28485

Draft
leejet wants to merge 1 commit into
ggml-org:masterfrom
leejet:fp8_support
Draft

leejet wants to merge 1 commit into
ggml-org:masterfrom
leejet:fp8_support

Conversation

@leejet

@leejet leejet commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

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_mat support 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

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: Yes, I use AI to help with debugging and porting code from ggml to llama.cpp.

@leejet
leejet requested a review from ggerganov as a code owner September 6, 2026 09:56
@ggml-gh-bot

This comment was marked as resolved.

@github-actions github-actions Bot added testing Everything test related ggml changes relating to the ggml tensor library for machine learning labels Sep 6, 2026
@am17an

am17an commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

There are some pending PRs w.r.t FP8 #28413. It is something we're planning to add to the project

@ORippler

ORippler commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

@leejet feel free to take a look at #27512, I consider it ready for review. How often do you encounter e5m2 for diffusion-based workloads? wondering how important it will be to add as a follow-up

@leejet

leejet commented Oct 12, 2026

Copy link
Copy Markdown
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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants