You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: support Q4 and Q5 weights in INT8 linear layers - #2452
If this PR adds or changes model support, I have added or updated its usage guide and relevant model index/README entries following the model documentation requirements.
Summary by CodeRabbit
New Features
INT8 GEMM now supports Q4_0, Q4_1, Q5_0, Q5_1, and Q8_0 weights on CUDA, HIP, MUSA, and Vulkan.
Floating-point checkpoints can be quantized at load time using the --type option. Layers without supported INT8 requantization continue to use their original execution paths.
Documentation
Updated the runtime requantization guide with supported weight types and load-time quantization details.
No actionable comments were generated in the recent review.
Walkthrough
INT8 requantization now accepts Q4_0, Q4_1, Q5_0, Q5_1, and Q8_0 weights. Shared operation handling and CUDA and Vulkan implementations use the expanded type support. The guide documents the eligible types and the --type load-time quantization option.
Changes: INT8 requantization
Layer / File(s)
Summary
Shared i8 contract and dispatch src/core/ggml_extensions.h, src/core/ggml_extensions.cpp, src/core/ggml_extend.cpp, docs/guides/int8_convrot.md
The shared operation accepts supported Q4, Q5, and Q8 weight types. Linear dispatch uses the i8 operation, and the guide describes the expanded eligibility and load-time quantization option.
CUDA quantized decoding and execution src/core/cuda/requantize.cu
The CUDA kernel decodes supported Q4, Q5, and Q8 blocks through a templated path. Execution dispatches by weight type and registers the i8 operation.
Vulkan shader and packing support src/core/vulkan/CMakeLists.txt, src/core/vulkan/int8.cpp, src/core/vulkan/shaders/pack_i8_rows.comp
Vulkan adds Q4 and Q5 shader variants. Packing selects type-specific decoders for supported quantized inputs and registers the i8 operation.
sequenceDiagram
participant Linear as ggml_ext_linear
participant Infer as requantize_i8_infer
participant CUDA as CUDA backend
participant Vulkan as Vulkan backend
Linear->>Infer: validate supported weight type and operation inputs
alt CUDA execution
Linear->>CUDA: dispatch i8 requantization
else Vulkan execution
Linear->>Vulkan: dispatch i8 requantization
end
Loading
Possibly related PRs
leejet/stable-diffusion.cpp#2445: Adds the --linear-type i8 option and the original Q8_0-to-INT8 requantization path that this change extends.
Merge Risk: Minimal · up to 50395
This change extends INT8 linear layers to Q4_0, Q4_1, Q5_0, Q5_1 and Q8_0 weights, and layers that fail the eligibility checks keep their original execution path. The CUDA and Vulkan weight decoders were checked against GGML's block formats and match, so no concrete merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title states the main change: adding Q4 and Q5 weight support to the INT8 linear layer path. The changeset extends eligibility beyond Q8_0 to Q4_0, Q4_1, Q5_0, and Q5_1 weights, adds matching Vulk…
Description check
The description follows the repository template. It has Summary, Related Issue / Discussion, Additional Information, and Checklist sections. The Summary explains what changed and why, including the re…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title states the main change: adding Q4 and Q5 weight support to the INT8 linear layer path. The changeset extends eligibility beyond Q8_0 to Q4_0, Q4_1, Q5_0, and Q5_1 weights, adds matching Vulkan shaders, and renames the requantization op to requantize_i8. The title is concise and specific, and a teammate scanning history would understand the primary change.
Full details: Description check
Explanation
The description follows the repository template. It has Summary, Related Issue / Discussion, Additional Information, and Checklist sections. The Summary explains what changed and why, including the reuse of the H256 rotation and INT8 GEMM and the fallback for ineligible layers. Related Issue is marked N/A, and Additional Information is marked N/A, although no validation results are reported. The checklist is ticked. The description is mostly complete.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 5a695817-3c5b-4aa7-8291-c73fc07d1d87
Commits
Reviewing files that changed from the base of the PR and between 3771ef2 and 5039583.
Files selected for processing: 8
docs/guides/int8_convrot.md
src/core/cuda/requantize.cu
src/core/ggml_extend.cpp
src/core/ggml_extensions.cpp
src/core/ggml_extensions.h
src/core/vulkan/CMakeLists.txt
src/core/vulkan/int8.cpp
src/core/vulkan/shaders/pack_i8_rows.comp
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
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
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.
Summary
Related Issue / Discussion
N/A
Additional Information
N/A
Checklist
Summary by CodeRabbit
--typeoption. Layers without supported INT8 requantization continue to use their original execution paths.