GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: packed int4 convrot model loading and dispatch by noctrex · Pull Request #2010 · leejet/stable-diffusion.cpp

Conversation

@noctrex

@noctrex noctrex commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds direct loading and execution of ComfyUI packed int4 convrot checkpoints (convrot_w4a4, asym_w4a8_int8). The packed nibble weights stream to the backend unconverted: no load-time reblock, no sidecar cache, roughly half a byte per weight parameter. Formats are documented in docs/int4_convrot.md (added here).

Loader/graph side:

  • packed-w4 tensor recognition in safetensors IO; packed payloads and companion tensors (row scales, codebook, s_channel, s_rel) pass through raw
  • block-builder support mirroring the int8 convrot chain: the activation rotation/quantize is shared with int8 tensorwise and cached per (input, group size)
  • activation quantize gated on unit scale for int4 inputs
  • docs: docs/int4_convrot.md

GGML dependency

The kernels live in the GGML submodule. The ggml-side changes are submitted as leejet/ggml#10 ("ggml : add packed int4 convrot mul_mat for CPU, CUDA, HIP and Vulkan"), which includes the HIP quantize-gate fix this PR's pin depends on.

This PR therefore bumps the ggml pin to a branch on my fork. Per the contribution guidelines, ggml updates are validated by the maintainer - keeping this PR in draft until that side is settled; the pin can be retargeted the moment the ggml content lands in leejet/ggml.

Backend notes (disclosure)

  • int4 (both kinds) runs on CPU, CUDA, HIP and Vulkan; convrot group sizes 64 and 256 verified.
  • On HIP, plain int8_tensorwise models and int8 convrot text encoders currently fall back to CPU; that enablement is the separate INT8 HIP/BLAS ggml PR's scope and does not affect int4 models.

Verification

All runs on RX 7900 XTX (gfx1100), Windows, ROCm 10 / Vulkan, 1024x1024, 8 steps, seed 42:

  • FLUX.2-klein-4b int4: Vulkan 11.9 s sampling (1.24 s/it, faster than the int8 baseline's 12.3 s), ROCm 9.56 s post-fix
  • FLUX.2-klein-4b w4a8: Vulkan 13.9 s, ROCm 12.40 s
  • FLUX.2-klein-4b int8 baseline: Vulkan 12.3 s (visual reference; images equivalent)
  • z_image-turbo int4 (gs=256 regression check): ROCm 14.38 s
  • Loader fixture against the merged loader: W4A4 bitwise vs CPU oracle, W4A8 within the int8-requant gate, raw packed passthrough intact
  • zero unsupported-node/CPU-fallback warnings for the int4 paths; images on-prompt and visually equivalent to int8

Linked context

  • ggml side: ggml : add packed int4 convrot mul_mat for CPU, CUDA, HIP and Vulkan ggml#10
  • int8 convrot foundation: feat: support INT8 ConvRot safetensors #1857
  • upstream int8 convrot proposal: ggml : add native INT8 convrot support ggml-org/llama.cpp#26914

Checklist

  • I have read and confirmed this PR follows the contribution guidelines.

LLM Disclosure: Yes, used GLM-5.3-Flash

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@noctrex
noctrex force-pushed the convrot-w4-family branch from 758299c to 68eae3d Compare October 12, 2026 00:30
@BBQ2077

BBQ2077 commented Oct 18, 2026

Copy link
Copy Markdown

Hi, does this PR also cover loading the MOSS-Image Qwen3.5-9B W4A8 GPTQ ConvRot text encoder through --llm?

Model repository:
https://huggingface.co/nif0/MOSS-Image-SFT-ComfyUI

Text encoder:
qwen3.5_9b_moss_image_sft_w4a8_gptq.safetensors

Environment

  • Windows 11
  • AMD Radeon RX 9070 (gfx1201), 16 GB VRAM
  • ROCm 10.1.0
  • Official prebuilt release: master-973-f0aac52

Observed failure

The current release fails metadata validation when loading this encoder. For example:

[E] Conditioner model tensor 'text_encoders.llm.model.layers.0.linear_attn.in_proj_qkv.weight' has wrong shape in model metadata: got [2048, 8192, 1, 1], expected [4096, 8192, 1, 1] --- model_manager.cpp:798

The physical input dimension appears to be half the expected logical dimension, consistent with packed 4-bit weights not being interpreted by the current loading path.

Replacing this encoder with Qwen3.5-9B-Q4_K_M.gguf, together with the Comfy-Org MOSS-SFT INT8 diffusion model and the external Qwen3.5 tokenizer, successfully generates images on the same machine.

I have not tested this PR branch yet. Could you confirm whether its packed W4A8 support also applies to this Qwen3.5-9B text encoder, including execution on HIP/ROCm?

Thank you!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

noctrex added 2 commits October 18, 2026 11:52
@noctrex
feat: packed-w4 convrot model loading and dispatch
4ff20cd
- loader: packed-w4 convrot tensor recognition; packed payloads stream
  to the backend unconverted (no load-time reblock, no sidecar cache)
- safetensors IO, tensor storage, block builder support for the
  packed-w4 payloads
- activation quantize gated on unit scale for w4 inputs
- ggml: pointer to the squashed w4 convrot kernel commit (6a7f9c31,
  includes group-size-64 quantize support as h64-PR overlap)
@noctrex
docs: add int4 convrot checkpoint documentation
2f4b8cf
@noctrex
noctrex force-pushed the convrot-w4-family branch from 68eae3d to 2f4b8cf Compare October 18, 2026 08:52
@noctrex

noctrex commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@BBQ2077 Yes, this change is for these to be able to loaded.
I'm trying out on my fork, but it seems that there's another problem with this specific one and cannot be loaded

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@noctrex

noctrex commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded - and thank you @leejet for landing native packed INT4 support via #2276. sd.cpp now loads ComfyUI convrot_w4a4 and asym_w4a8_int8 checkpoints directly, mixed checkpoints included, with the ggml-side work ported into the backend extension API and the performance follow-ups in #2278 and #2280. Seeing the loader work handled natively upstream is the best possible resolution for this PR.

For context on why this was draft-only: its submodule gitlink pointed at fork-only ggml commits that were unreachable from leejet/ggml, so merging it would have broken recursive clones for everyone else. The un-draft trigger we were waiting on (maintainer landing the ggml-side w4 content) resolved differently and more elegantly - the whole convrot stack moved out of the submodule into src/core/{cpu,cuda,vulkan} behind the ggml-ext registry - which makes this loader patch obsolete.

Thanks again for all the work you put into the int8/int4 stack. It is a genuinely great foundation.

(Comment drafted with LLM assistance, reviewed by noctrex.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@noctrex noctrex closed this Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@noctrex @BBQ2077
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.