ggml : add native INT8 convrot support - #26914
Conversation
|
Hi @leejet, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
|
I rewrote the CUDA rowwise quantization kernel to work without large shared memory (leejet#1) and ended up at something very similar to Similar optimizations could probably be made to the group_amax/reduce_row_amax/group_quantize path as well. |
|
@leejet Verified on gfx1100 (Windows, ROCm 7.1): tests/test-int8-convrot passes, CPU-vs-GPU bit-exact at real model shapes (K=3840/10240, N<=11520), krea2_turbo int8 convrot generates fully on my 7900XTX. |
Overview
This PR adds native execution support for tensorwise INT8 ConvRot linear layers without converting the stored INT8 weights to another format.
It introduces:
The intended downstream use case is loading ComfyUI
int8_tensorwisecheckpoints withconvrotmetadata directly, while preserving the original INT8 weights. Check stable-diffusion.cpp pr leejet/stable-diffusion.cpp#1857.Additional information
The runtime activation representation is a transient I8 tensor containing the quantized activation rows followed by one F32 scale per logical row. Keeping both outputs in one tensor avoids recomputing the Hadamard transform and row maximum in separate graph operations, and allows the packed activation to be cached and reused by linear layers sharing the same input.
The tensorwise INT8 helper retains
GGML_OP_MUL_MATbecause the logical operation and output shape remain a matrix multiplication. It uses:src[0]: INT8 weightssrc[1]: F32 input or prequantized INT8 activationsrc[2]: F32 weight scalessrc[3]: optional F32 biasop_params[2]: ConvRot group sizeThe dedicated CUDA and Vulkan activation paths currently target H256. Unsupported configurations and devices are rejected by backend capability checks so that the scheduler can select a fallback backend. HIP and MUSA do not currently expose the dedicated ConvRot quantization path.
This functionality is currently consumed by stable-diffusion.cpp; no llama.cpp model path uses these operations yet.
Validation performed:
1e-5.On the RTX 4090 Vulkan backend, cooperative-matrix execution reached approximately 73.5 TOPS in the synthetic large-GEMM test. Handling 4096 aligned rows with cooperative matrices and the remaining 18 Krea2 text-token rows with the scalar path reduced steady-state Krea2 execution from approximately 9.47 s/step to 1.72 s/step. The scalar-only and mixed-dispatch runs produced byte-identical final PNG output.
Requirements
ggmltollama.cpp.