XNNPACK INT4 linear returns incorrect per-channel outputs and fails groupwise FP16 on Apple M4 Max

Abierto
#25,854 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@JakeStevens ya está trabajando en esto.

Desde el 30/11/2026.

  • #25855 de @JakeStevens — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
43/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python, pytorch

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug module: quantization module: xnnpack
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, TorchAO 0.18.0.dev20260729+cpu
  • ExecuTorch e67ec4e19067b96ffbc39d973a0e4799f5836bf4, XNNPACK 92a7ad501b9516f9fecae119e0146dd1f58e54c1, cpuinfo f9a03241f8c3d4ed0c9728f5d70bff873d43d4e0
  • CMake Release build with EXECUTORCH_XNNPACK_ENABLE_KLEIDI=ON, XNNPACK_ENABLE_ARM_SME2=ON, and EXECUTORCH_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

Lenguaje dominante
Python
Estrellas
5.2k
Forks
1.3k
Merge medio
1 d 7 h
PR fusionados (30 d)
644

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de pytorch/executorch

Todos los issues de pytorch/executorch

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.