Skip to content

ggml: support quant scales for fp8 and nvfp4 - #28898

Draft
0cc4m wants to merge 28 commits into
osimons/ocp_fp8_cudafrom
0cc4m/fp8-scaled-mm
Draft

0cc4m wants to merge 28 commits into
osimons/ocp_fp8_cudafrom
0cc4m/fp8-scaled-mm

Conversation

@0cc4m

@0cc4m 0cc4m commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Overview

This is a prototype branch on top of @ORippler's FP8 branches, moving quant scale support into GGML. To keep it simple, it requires backends to support them for FP8 and NVFP4. Support is very simple to implement with an epilogue MUL. I also tested options for graph-based fallbacks, but they add a lot of complexity, so I think this is easier. It is backwards compatible with existing uses of MUL_MAT and MUL_MAT_ID, while supporting direct conversion of many FP8/NVFP4 safetensors models on HF directly.

For validation I also have Vulkan support added, because the primary purpose of this branch is just discussion. I can split it later if necessary.

Requirements

@github-actions github-actions Bot added model Model specific testing Everything test related Vulkan Issues specific to the Vulkan backend ggml changes relating to the ggml tensor library for machine learning CUDA Related to the CUDA backend conversion labels Sep 14, 2026
@ORippler
ORippler changed the base branch from master to osimons/ocp_fp8 September 15, 2026 12:55
@0cc4m
0cc4m force-pushed the 0cc4m/fp8-scaled-mm branch from 3d30cf0 to 973988c Compare September 15, 2026 15:16
@0cc4m
0cc4m changed the base branch from osimons/ocp_fp8 to osimons/ocp_fp8_cuda September 15, 2026 15:17
@0cc4m
0cc4m force-pushed the 0cc4m/fp8-scaled-mm branch 2 times, most recently from 1b434fb to 9188821 Compare September 18, 2026 06:56
@0cc4m

0cc4m commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

@ggerganov As soon as we add FP8 support, we'll have two types that require scales. I would like to avoid the llama.cpp (non-ggml) workarounds and instead support this case in ggml directly. The simplest way for that is to allow a weight scale tensor and an optional activation scale tensor as src to ggml_mul_mat and ggml_mul_mat_id, only for the types that require these (nvfp4 and fp8).

This branch (mostly commit 394d7a8) is a rough example of how that could be done, based on @ORippler's work and discussed with him. There is a breaking change for nvfp4, since it removes the graph-based MUL + backend-internal fusion currently used for nvfp4, but for any other type it is completely backwards compatible. Since nvfp4 is still very fresh I don't think that's a big issue.

I think this is better than requiring each backend to fuse internally and also permits optimizations for src1-quantization through preset activation scales that models ship with.

Before we pursue this further, what is your opinion on the approach? We would really like to unblock FP8 and improve NVFP4 support.

@ggerganov ggerganov self-assigned this Sep 29, 2026
@ORippler
ORippler added this pull request to stack #28393 September 29, 2026 15:25
@ORippler
ORippler force-pushed the 0cc4m/fp8-scaled-mm branch 2 times, most recently from 05b2437 to 2297880 Compare September 30, 2026 09:54
@ggerganov

Copy link
Copy Markdown
Member

I looked at the stack and the proposed changes are OK. IMO this functionality is overall quite orthogonal to most other stuff so we can afford to move forward quickly - even if we realize some better approach later on it would be simple to adjust (just like how now we will step back on the backend fusion approach).

Feel free to proceed with this as you find best. I think @jeffbolznv also had some thoughts/interest in FP8, so pinging to keep him in the loop.

@0cc4m
0cc4m force-pushed the 0cc4m/fp8-scaled-mm branch from 024aea4 to 672af95 Compare October 1, 2026 08:05
@ORippler
ORippler force-pushed the 0cc4m/fp8-scaled-mm branch from 672af95 to 5858f05 Compare October 1, 2026 11:58
@ORippler
ORippler force-pushed the 0cc4m/fp8-scaled-mm branch from 5858f05 to 675729f Compare October 1, 2026 13:55
@github-actions github-actions Bot added IBM zDNN issues specific to IBM zDNN Accelerator Hexagon labels Oct 21, 2026
0cc4m and others added 28 commits October 29, 2026 20:17
We want to test requant errors so we should be using the same kernels
to avoid a cofounder

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

AMD ZenDNN Issues related to the AMD ZenDNN backend Apple Metal https://en.wikipedia.org/wiki/Metal_(API) Ascend NPU issues specific to Ascend NPUs conversion CUDA Related to the CUDA backend ggml changes relating to the ggml tensor library for machine learning Hexagon IBM zDNN issues specific to IBM zDNN Accelerator model Model specific OpenCL Issues specific to the OpenCL backend OpenVINO SYCL https://en.wikipedia.org/wiki/SYCL - GPU programming language testing Everything test related Vulkan Issues specific to the Vulkan backend WebGPU

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants