You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug Skip]: [New Case] segment_reduce accumulates in the input dtype, failing test_reduced_precision_accumulation for float16/bfloat16 #6182
test_reduced_precision_accumulation sums 4096 reduced-precision values and asserts the result matches a float accumulation of the same data; on XPU it is off by 3840.0 absolute (0.9375 relative), the magnitude you get when thousands of values are summed in float16/bfloat16 rather than in float. The XPU segment_reduce forward kernel keeps its running accumulator in scalar_t (src/ATen/native/xpu/sycl/SegmentReduceKernels.cpp:61, :88), so sum and mean never widen for reduced-precision inputs; the float16 and bfloat16 cases are the same defect in the two dtypes the test covers. Same root cause as the test_compare_cpu failures in the related draft, which that operator shows as a smaller drift against CPU.
ErrorLog
AssertionError: Tensor-likes are not close!
Traceback (most recent call last):
File "/__w/torch-xpu-ops/torch-xpu-ops/pytorch/third_party/torch-xpu-ops/test/xpu/../../../../test/test_segment_reductions.py", line 581, in test_reduced_precision_accumulation
self.assertEqual(actual, data.float().sum(0, keepdim=True).div_(4096 if reduction == "mean" else 1).to(dtype))
File "/__w/torch-xpu-ops/torch-xpu-ops/.venv/lib/python3.12/site-packages/torch/testing/_internal/common_utils.py", line 5420, in assertEqual
raise error_metas.pop()[0].to_error( # type: ignore[index]
AssertionError: Tensor-likes are not close!
Mismatched elements: 1 / 1 (100.0%)
Greatest absolute difference: 3840.0 at index (0,) (up to 1e-05 allowed)
Greatest relative difference: 0.9375 at index (0,) (up to 0.016 allowed)
To execute this test, run the following from the base repo dir:
PYTORCH_TEST_WITH_SLOW=1 python ../../test/test_segment_reductions.py TestSegmentReductionsXPU.test_reduced_precision_accumulation_xpu_bfloat16
This message can be suppressed by setting PYTORCH_PRINT_REPRO_ON_FAILURE=0
Reproduce
cd pytorch/third_party/torch-xpu-ops/test/xpu
pytest -sv test_segment_reductions_xpu.py::TestSegmentReductionsXPU::test_reduced_precision_accumulation_xpu_bfloat16
Activity
torchxpubot commentedon Nov 12, 2026
Same root cause as #6181, split because the cases do not share a classification or a row shape.