Skip to content

[Bug Skip]: [New Case] segment_reduce accumulates in the input dtype, failing test_reduced_precision_accumulation for float16/bfloat16 #6182

Open

Description

@torchxpubot

🐛 Describe the bug with skip template

Cases:
op_ut,third_party.torch-xpu-ops.test.xpu.test_segment_reductions_xpu.TestSegmentReductionsXPU,test_reduced_precision_accumulation_xpu_bfloat16
op_ut,third_party.torch-xpu-ops.test.xpu.test_segment_reductions_xpu.TestSegmentReductionsXPU,test_reduced_precision_accumulation_xpu_float16

Summary

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

Pytorch Version

Category Run Date torch torch-xpu-ops
op_ut Last good #43027469769 (op_ut) 2026-11-11 unknown unknown
op_ut First seen bad #43225498542 (op_ut) 2026-11-12 unknown unknown

Versions

Detail
collect_env output was not captured in this run's artifact.

Activity

  1. added
    skippedUsed for temp UT failure to parallel fix
    skipped_bmgTemporarily skipped on BMG
    new_case_failureAbsent from the baseline, or present but skipped
    on Nov 12, 2026
  2. torchxpubot commented on Nov 12, 2026

    @torchxpubot
    ContributorAuthor

    Same root cause as #6181, split because the cases do not share a classification or a row shape.

  3. added this to the UT Backlog milestone on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    new_case_failureAbsent from the baseline, or present but skippedskippedUsed for temp UT failure to parallel fixskipped_bmgTemporarily skipped on BMG

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions