model-infer-harmony

Quantize ASR models to W4A16 and convert them to omc for Kirin9030 NPU deployment.

Updated Sep 15, 2026
One-click install
npx skills add https://github.com/WangWindow/CANN-BatchMatMulMaxsum --skill model-infer-harmony-wangwindow
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: model-infer-harmony
Source: https://github.com/WangWindow/CANN-BatchMatMulMaxsum/tree/main/.agents/skills/model-infer-harmony
Command: npx skills add https://github.com/WangWindow/CANN-BatchMatMulMaxsum --skill model-infer-harmony-wangwindow

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Deploying ASR models (encoder, decoder, punctuation) on the Kirin9030 HarmonyOS NPU requires 4bit W4A16 quantization and omg offline model conversion, a process full of platform-specific pitfalls such as UINT4-only weight packing, container-only omg execution, and cryptic conversion errors. This Skill codifies the full pipeline and troubleshooting knowledge so the conversion succeeds on the first attempts. ## Core Features & Use Cases - Five-stage quantization pipeline: dopt PTQ calibration, quant parameter export, ONNX export with grid-aligned weights, graph rewriting, dimension padding, and in-container omg conversion to omc. - Kirin9030 platform rules: Enforces the two hard constraints—omg must run inside a glibc >= 2.35 container with the AscendC toolchain activated, and W4 kernels only accept UINT4 weights on the 4bit grid. - Model-specific strategies and packaging: Covers encoder/decoder/punc mixed-precision configs, encoder splitting into multiple omc segments, and CANNPAK packing of all omc files plus embedding binaries into a single on-device bin. - Use Case: You need to deploy a Conformer encoder on a Kirin9030 phone. Follow the pipeline to calibrate with real data, export grid-aligned weights, rewrite the ONNX graph, run omg in the container, split the encoder into segments, and pack everything into one bin—while routing errors like "CompressInt4ToInt8 Value -1 out of range" to their root causes. ## Quick Start Ask the assistant to quantize your ASR encoder to 4bit W4A16 and convert it with omg for Kirin9030 deployment, and it will walk you through the five-stage pipeline and platform rules.

Frequently Asked Questions about model-infer-harmony

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I quantize an ASR model to 4bit for Kirin9030 NPU?

Run the five-stage pipeline: dopt PTQ calibration with real data, export quant params with quant_param_2=True, export ONNX from fake-quantized weights, rewrite the graph, then pad dimensions and run omg in a container to produce the omc file.

Why does omg report CompressInt4ToInt8 Value -1 out of range?

Kirin9030 W4 kernels only support UINT4 weights in range [0,15], so original float weights containing negative values fail packing. Export ONNX from dopt fake-quantized grid weights, or copy grid weights into split subgraphs before conversion.

Can I run omg for Kirin9030 directly on my host machine?

No, Kirin9030 omg requires glibc >= 2.35, so it must run inside a container such as Ubuntu 22.04 or 24.04. You must also activate the AscendC toolchain inside the container and verify ccec is found, otherwise W4 MatMul falls back to unsupported precompiled kernels.

What is the difference between Kirin9020 and Kirin9030 quantization?

Kirin9020 uses INT4 weights with quant_param_2=False and can run omg on the host, while Kirin9030 requires UINT4 weights with quant_param_2=True, grid-aligned weights, and container-based omg. The two chains must not be mixed.

Does this Skill cover server-side LLM quantization with compressed-tensors?

No, it only covers Kirin9030 on-device ASR W4A16 quantization and omg/CANNPAK packaging. Server-side W8A8 quantization of LLMs with compressed-tensors is out of scope and should use a general quantization skill.

How do I fix GatherV2D Input INT64 errors during omg conversion?

The error occurs when a Cast node converts Gather indices to int64, which the platform rejects. In the graph rewriting stage, delete the Cast that turns indices into int64 and keep Gather indices as int32, as done in the encoder int32 export fix.