Merge blocked
Hi @Mocchibird, welcome to submitting your first PR to CANN!
PR Merge Steps
1. CLA Signing
If the current PR label includes cann-cla/yes, it means you have signed the CLA and can proceed to the next step. If the label includes cann-cla/no, please sign the CLA first. If you have any questions, please refer to the FAQ.
2. CI Check
Please comment /compile to trigger the CI pipeline check. If the CI run is successful, the PR will be tagged with ci-pipeline-passed and you can proceed to the next step. If the CI run fails, the PR will be tagged with ci-pipeline-failed, please check the CI logs to fix the issues in the PR. If you have any questions, please refer to the FAQ.
3. Code Review
After CI passes, please refer to the PR Approval Progress and proactively @ the committers in the table to review the code. After approval, committers will comment /lgtm and /approve. Once the lgtm and approved labels are successfully added, the PR will be merged automatically.


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| experimental | ❌ (0/2)(You can also ask: 石向阳, 陈昊文, 沈承宗, 杨东, 高成) | ❌ (0/1)(You can also ask: 王子韬, 柳宗谷, 刘闯, 钱泽洪, 余鑫) |
| scripts | ❌ (0/2)(You can also ask: 杨阳, 汤平川, 范其瑞, 胡碧霞, 商晓波) | ❌ (0/1)(You can also ask: 胡碧霞, 杨阳, 商晓波, 林鹏翔, 范其瑞) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
Mocchibird, thanks for your pull request. All authors of the commits have signed the CLA. 👍


MACAQ: better W4A4 accuracy with a fused inference path
Project repository: huawei-csl/MACaQ.
Add dense and grouped MACAQ W4A4 matmul for Ascend 950 using PTO-ISA through the
ascend_ops_nnPyTorch extension.MACAQ (Model Agnostic Calibrated Quantization) applies channel scaling,
block-32 BF16 Hadamard rotation, MXFP4 activation quantization and matrix
multiplication in one mixed Vector/Cube kernel, producing BF16 output.
Calibration, weight transformation
(W / D) @ Hand Flip-Refinement are offline.The key result is better quantization accuracy with competitive small-batch
kernel latency. The online accuracy transform is included in every MACAQ
timing below. Native CANN quantization and matmul are unchanged independent
baselines. Large-prefill and grouped losses remain visible.
Accuracy results
Model perplexity: 23.7% lower than ordinary W4A4
Qwen3-0.6B on held-out WikiText-2; lower is better:
This is a CPU model-reference pilot, using 16,384 held-out tokens
(16,368 scored predictions, context 1,024). All 196 decoder linear projections
are quantized; embeddings and the LM head remain BF16. Calibration uses
1,024 training tokens, with no held-out hyperparameter tuning. It is not
full-dataset perplexity or full-model NPU execution. Algorithm 2 model
perplexity has not been measured.
Actual NPU outputs: lower error on all nine fixed projections
MACAQ lowers normalized mean squared error against both native FP4 scaling
presets on q/up/down projections at layers 0, 14 and 27. Native error is
1.58–4.61× MACAQ error for algorithm 0 and
1.68–4.14× for algorithm 2.
The measured ops-nn, TileLang regular and TileLang prepared outputs agree
exactly with the MACAQ CPU reference on all nine fixtures. Evaluation uses
1,024 separate held-out test tokens. Unsupported ops-nn dimensions are
zero-padded for accuracy coverage only, then sliced; those calls make no latency claim.
Accuracy protocol, all projection rows, grouped arithmetic checks and raw data.
Runtime and accuracy are separate experiments; this is not a joint
model-level speed-and-accuracy result.
Latency against existing native CANN operators
Baseline:
npu_dynamic_mx_quant(block32 E2M1, round-to-even,scale_alg=0)followed by
npu_quant_matmul, ornpu_grouped_matmulfor grouped workloads.MACAQ additionally performs scaling and Hadamard rotation. Each numerical
function is checked against its own CPU reference. Our split MACAQ paths
are ablations, not existing external baselines.
Native latency / MACAQ latency; above 1 favors MACAQ. Geometric means
give every configuration equal weight: all 24 (K,N) pairs at dense
M=16/128/4096 plus four-expert grouped workloads, for 96 cases in total.
Win counts compare medians and do not establish statistical significance.
Both small-batch groups are faster on the geometric mean, while the grouped mean is near parity. One call per configuration has total native/MACAQ time ratio 0.930×; MACAQ is slower in that mixture because larger cases contribute more time.
The accuracy gain comes without a latency penalty on the faster measured
workloads. It is not free for every shape: large prefill and many grouped
cases still lose. No end-to-end NPU throughput gain is claimed.
Complete protocol, all 96 rows, heatmap and raw samples.
Timing protocol and current-source validation
Ascend 950, CANN 9.3 weekly, PyTorch 2.9.0 / torch_npu 2.9.0.post2,
native TileLang 0.1.15. Each case uses 20 warmups and 15 rotated trials of
20 eager calls. Two distinct activation buffers alternate. Outputs and all
intermediate allocations count inside timed calls; compilation, calibration
and static weight/layout preparation are excluded. No explicit cache flush.
These are repeated API timings, not single-request latency or model throughput.
Within-run bootstrap intervals and an earlier equivalent TileLang sweep are
available in the reports; they do not cover systematic or across-run uncertainty.
Related implementation: TileLang PR #44.
AI/Agent disclosure