Skip to content

omni: INT4 per-block zero-point GEMM + calling adapter (torchao asymmetric INT4) - #629

Open
JWLHS wants to merge 2 commits into
intel:mainfrom
JWLHS:codex/int4-torchao
Open

omni: INT4 per-block zero-point GEMM + calling adapter (torchao asymmetric INT4)#629
JWLHS wants to merge 2 commits into
intel:mainfrom
JWLHS:codex/int4-torchao

Conversation

@JWLHS

@JWLHS JWLHS commented Aug 19, 2026

Copy link
Copy Markdown

目的

为 llm-scaler 的 omni 组件增加 torchao 后端量化的非对称 INT4 模型 支持:

  • kernel(omni/omni_xpu_kernel):onednn_int4_gemm_preconverted 增加可选
    zp_u8 [G, N] 参数,提供时在 oneDNN 内应用 per-block zero point,
    w = (q - zp) * scale —— 原生支持 Int4PlainInt32Tensor(int32 qdata 字节
    视图 + per-block zp/scale,非对称)。零转换、零 Python 修正项。
  • 插件(omni/ComfyUI-OmniXPU):新增 �dapters/int4_gemm.py 调用适配器
    (int4_gemm,透传 zp_u8)+ 能力探测 + config/组件注册,与 kernel 改动配套。

非对称 per-block zero point 能把偏置的权重分布逐块归中,相比对称 INT4
量化误差更小(编辑/姿态迁移类能力保留更好)。

改动

  • omni/omni_xpu_kernel/csrc/onednn_int4_gemm.cpp:per-block zp 原语 + kernel + zp_u8 参数
  • omni/omni_xpu_kernel/csrc/bindings.cpp、svdq/init.py:注册与包装
  • omni/ComfyUI-OmniXPU/adapters/int4_gemm.py(新增)+ config.py + patches/init.py

配套插件(用于体验与测试)

统一加载器 JWLHS/int4-omnixpu:wa4 + torchao
INT4 统一加载,探测本算子存在即原生调用(无则安全回退 torchao/python),开箱即用。

JWLHS added 2 commits August 20, 2026 00:36
…tric INT4)

onednn_int4_gemm_preconverted gains an optional zp_u8 [G, N]. When provided
it applies per-block zero points inside oneDNN, w = (q - zp) * scale — native
support for INT4 models quantized on the torchao backend (Int4PlainInt32Tensor:
int32 qdata byte view + per-block zp/scale, asymmetric). The per-block zero
point centers biased weight distributions per block, lowering quantization
error vs symmetric INT4.
- adapters/int4_gemm.py: int4_gemm wrapper over onednn_int4_gemm_preconverted
  with optional zp_u8 + capability check
- config flag OMNIXPU_INT4_GEMM + patch component registration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant