hexagon: add an experimental Qualcomm FP8 DiT and VAE path - #1970
Open
happyyzy wants to merge 1 commit into
Open
hexagon: add an experimental Qualcomm FP8 DiT and VAE path#1970happyyzy wants to merge 1 commit into
happyyzy wants to merge 1 commit into
Conversation
Contributor
Author
Owner
|
For ggml-related changes, please submit a PR to ggml-org/ggml or ggml-org/llama.cpp first. If the changes are merged upstream, I will sync them here. As for the FP8-related changes, I previously submitted a PR to ggml-org/llama.cpp, but it has not been merged yet. |
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.
Motivation
We are building high-performance DiT inference on Qualcomm devices, covering both Adreno GPUs and Hexagon NPUs, for Local Dream.
Our Adreno work is already being contributed to llama.cpp: #22755, #26085, and #26331 are merged; Fused QKNorm-RoPE #28446 is currently open.
This PR provides the integrated Hexagon NPU path for stable-diffusion.cpp.
Implementation
The v79+ path includes standard
F8_E4M3safetensor loading; HMX 32x32set_tensorrepacking; FP8 W8A16 GEMM; non-causal HMX FA; fused Q/K RMSNorm-RoPE; segmented-K Kleinlinear2; FP16 VAE activations; direct implicit-GEMM convolution; fused GroupNorm-affine-SiLU; and fused upscale-convolution. Qwen3-4B uses the existing generic Hexagon Q4 kernels.The FP8 GEMM uses the v79
activation.hf/weight.f8HMX path with FP32 accumulation. HMXcvt.hf = acc(2)applies the architectural 1/256 conversion; the HVX output epilogue compensates by 256 and folds the model's FP32 weight scale and any graph scalar scale into the same store pass.Temporary integration
The FP8 plumbing required for full llama.cpp integration has not yet been accepted into llama.cpp's embedded ggml, for reasons that remain unclear to us. This PR temporarily uses happyyzy/ggml, branch
work/qualcomm-hexagon-optimizations, commit8121decc678bfb9f02a0f7190bce143bfb1599fa.The generic pieces are being upstreamed into llama.cpp incrementally. This is a temporary integration vehicle for Local Dream until that work is complete.
End-to-end results
Device: Snapdragon 8 Elite / SM8750 / HTP v79. TE, DiT, and VAE all run on HTP. Prompt is
a lovely cat, Euler, CFG 1, seed 42. ``E2Eisgenerate_image completed`, including live TE, all sampling steps, and VAE decode. None of these runs uses tiled VAE.During the long 1536 runs, Z-Image iterations 5-8 rose to 36.16-38.37 s/it and the final Klein iteration rose to 25.24 s/it. The E2E numbers above include that thermal throttling.
This puts phone-class Snapdragon inference close to mainstream NVIDIA RTX GPU latency for these distilled pipelines.
Commands
Images
Z-Image 1024, 8 steps
Klein 1024, 4 steps
Z-Image 1536, 8 steps
Klein 1536, 4 steps
FP8 vs Upstream Q4_0/Q8_0
Compared with upstream Hexagon using standard Q4_0/Q8_0 GGUF weights, FP8 is 8.87x faster for Z-Image and 9.30x faster for FLUX.2/Klein at 1K, while also delivering visibly better image quality.
Q4_0 + Q8_0
F8_E4M3