XNNPACK INT4 linear returns incorrect per-channel outputs and fails groupwise FP16 on Apple M4 Max
维护者通常 1 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 43/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
调研方向
Start with the three failing test definitions in backends/xnnpack/test/ops/test_linear.py, then reproduce them using the command in the issue on the pinned versions and Apple M4 Max setup. Compare the per-channel outputs with the reference and inspect the groupwise FP16 portable runtime failure. Done means all three tests pass with their stated tolerances and the groupwise forward call executes.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
Three existing XNNPACK linear tests fail on an Apple M4 Max with dynamically quantized 8-bit activations and 4-bit weights. The per-channel cases run through the delegate and disagree with the reference. The groupwise FP16 case exports and serializes, then fails when the portable runtime executes forward.
| Test | Observed on the pinned version |
|---|---|
test_linear_qd8_f16_per_channel_int4 |
Maximum absolute error 2.43359375 on an FP16 output of shape [1, 50, 1] |
test_linear_qd8_f32_per_channel_int4 |
Maximum absolute error 1.5432514 on an FP32 output of shape [1, 68, 1] |
test_linear_qd8_f16_per_token_weight_per_channel_group_int4 |
RuntimeError: Failed to execute method forward, error: 0x1 |
The two per-channel tests expect atol=0.05 and rtol=0.001. Shapes and errors above are from one run with the tests’ randomized inputs. The same three tests also failed in a separate run.
Reproduce
From the ExecuTorch checkout below, build the Release Python runtime with XNNPACK, KleidiAI, and quantized kernels enabled, install TorchAO, and run:
python -m pytest -q --tb=short backends/xnnpack/test/ops/test_linear.py \
-k 'test_linear_qd8_f16_per_channel_int4 or test_linear_qd8_f32_per_channel_int4 or test_linear_qd8_f16_per_token_weight_per_channel_group_int4'
This produced 3 failed, 29 deselected. The groupwise failure reaches the following call chain:
backends/xnnpack/test/ops/test_linear.py:936: in test_linear_qd8_f16_per_token_weight_per_channel_group_int4
self._test_qd8_per_token_weight_per_channel_group_int4(dtype=torch.half)
backends/xnnpack/test/ops/test_linear.py:741: in _test_qd8_per_token_weight_per_channel_group_int4
self._test_groupwise_dq_linear(
backends/xnnpack/test/ops/test_linear.py:464: in _test_groupwise_dq_linear
.run_method_and_compare_outputs(atol=atol, rtol=rtol)
src/executorch/backends/test/harness/tester.py:346: in run_method_and_compare_outputs
stage_output = self.stages[stage].run_artifact(inputs_to_run)
src/executorch/backends/test/harness/stages/serialize.py:47: in run_artifact
executorch_module.run_method("forward", tuple(inputs_flattened))
RuntimeError: Failed to execute method forward, error: 0x1
Versions
- Apple M4 Max, macOS 27.2.1 (arm64), Python 3.12.14
- PyTorch
2.14.0, TorchAO0.18.0.dev20260729+cpu - ExecuTorch
e67ec4e19067b96ffbc39d973a0e4799f5836bf4, XNNPACK92a7ad501b9516f9fecae119e0146dd1f58e54c1, cpuinfof9a03241f8c3d4ed0c9728f5d70bff873d43d4e0 - CMake Release build with
EXECUTORCH_XNNPACK_ENABLE_KLEIDI=ON,XNNPACK_ENABLE_ARM_SME2=ON, andEXECUTORCH_BUILD_KERNELS_QUANTIZED_AOT=ON
Found while verifying #24667. The same failure modes occur with the proposed XNNPACK pin cf40768b61443f27cd1eed5807e2f6c0b0c7c7df and on unmodified ExecuTorch at the pinned versions above. Test definitions
cc @GregoryComer @digantdesai @cbilgin @kimishpatel @jerryzh168 @metascroy
- 主要语言
- Python
- 星标
- 5.2k
- 派生
- 1.3k
- 平均合并
- 1 天 7 小时
- 30 天内合并 PR
- 644
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pytorch/executorch 的其他 Issue
-
to_edge_transform_and_lower ignores some ops_to_not_decompose requests: multi-output ops, and non-core ops without a decomposition可能已有人在做 @Eureka-Zhang 于 7 天前认领。 未关闭module: exir
难度 2/5 1-3 小时 新手友好度 66/100
pytorch/executorch#25620 ·
维护者通常 1 天内回复
-
Qualcomm AI Engine Direct - fp16a8w quantization crashes on layer_norm可能已有人在做 @psiddh 于 21 天前认领。 未关闭bug module: qnn partner: qualcomm
难度 2/5 1-3 小时 新手友好度 74/100
pytorch/executorch#24434 · 已指派 1 人 ·
维护者通常 1 天内回复
-
enhancement triaged
难度 2/5 半天 新手友好度 68/100
pytorch/executorch#21640 ·
维护者通常 1 天内回复
-
quantize_per_channel and dequantize_per_tensor.tensor abort the process on a float32 scale可能已有人在做 @AxelNoun 今天认领。 未关闭
难度 3/5 1-2 天 新手友好度 35/100
pytorch/executorch#25873 ·
维护者通常 1 天内回复
-
Quantized quantize/dequantize kernels abort the process on a bfloat16 input or output可能已有人在做 @AxelNoun 今天认领。 未关闭
难度 3/5 1-2 天 新手友好度 25/100
pytorch/executorch#25822 ·
维护者通常 1 天内回复
查看 pytorch/executorch 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
hermes hooks doctor smoke test never checks the hook exit code — a crashing hook (exit=1) renders ✓ "ran clean" and "All shell hooks look healthy"可能已有人在做 @cestercian 今天认领。 未关闭comp/cli P2 type/bug
难度 2/5 1-3 小时 新手友好度 75/100
NousResearch/hermes-agent#162259 · 1 条评论 ·
维护者通常 1 天内回复
-
upstream update
难度 2/5 1-3 小时 新手友好度 72/100
conan-io/conan-center-index#31597 ·
维护者通常 1 天内回复
-
bug enhancement
难度 1/5 1 小时以内 新手友好度 90/100
AOSSIE-Org/PictoPy#1802 · 2 条评论 ·
维护者通常 3 天内回复
-
community-request
难度 2/5 1-3 小时 新手友好度 78/100
NVIDIA-NeMo/Run#727 ·
维护者通常 1 天内回复