Skip to content

Apply upstream Inductor fix for adaptive_avg_pool2d flatten-sum wrong results#3498

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-xpu-adaptive-avg-pool-bug
Draft

Apply upstream Inductor fix for adaptive_avg_pool2d flatten-sum wrong results#3498
Copilot wants to merge 2 commits intomainfrom
copilot/fix-xpu-adaptive-avg-pool-bug

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 28, 2026

torch.compile(..., backend="inductor") on XPU can return silent wrong results for adaptive_avg_pool2d(x, 7).flatten(1).sum(dim=-1) even though CPU and XPU eager are correct. The failure matches the upstream Inductor contiguous/exact-stride bug fixed in pytorch/pytorch#180898.

  • What changes

    • Add upstream PR pytorch/pytorch#180898 to the default patch list applied by /home/runner/work/torch-xpu-ops/torch-xpu-ops/.github/scripts/apply_torch_pr.py.
    • This ensures the stock PyTorch checkout used by torch-xpu-ops CI/build flows picks up the upstream Inductor fix automatically, along with its regression coverage.
  • Why this is the right layer

    • The incorrect result is not in the XPU adaptive average pooling kernel in this repository.
    • The bug is in the upstream Inductor lowering/layout logic, so the minimal repo-local fix is to apply the upstream PyTorch patch during the existing PyTorch preparation step.
  • Operational impact

    • Existing workflows that clone PyTorch and run apply_torch_pr.py will now include the upstream Inductor fix without any additional wiring.
    • No XPU kernel, YAML, or local operator registration changes are introduced.
  • Patched upstream PR

    default=[
        # Additional PRs link if need for CICD tests
        "https://github.com/pytorch/pytorch/pull/180898",
    ]

Agent-Logs-Url: https://github.com/intel/torch-xpu-ops/sessions/73f03483-85bd-499d-838a-2595423da853

Co-authored-by: laifenxiawucha <184592536+laifenxiawucha@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix wrong result for adaptive_avg_pool2d on XPU Apply upstream Inductor fix for adaptive_avg_pool2d flatten-sum wrong results Apr 28, 2026
Copilot AI requested a review from laifenxiawucha April 28, 2026 03:31
@github-actions
Copy link
Copy Markdown

Performance outliers, please check!

  • 🔴 [-1, 80%), should be regression
Category Model Target vs. Baseline [Eager] Target vs. Baseline [Inductor]
timm_models_bfloat16_training vit_base_patch16_siglip_256 0.695962 0.744412
timm_models_bfloat16_training visformer_small 0.715022 0.754084
timm_models_bfloat16_training dm_nfnet_f0 0.640517 0.767955
timm_models_bfloat16_training deit_base_distilled_patch16_224 0.749122 0.775495
timm_models_bfloat16_training beit_base_patch16_224 0.735098 0.814096
timm_models_bfloat16_training mobilenetv3_large_100 0.784127 0.823835
timm_models_bfloat16_training nfnet_l0 0.736359 0.827558
timm_models_bfloat16_training inception_v3 0.784848 0.836940
timm_models_bfloat16_training adv_inception_v3 0.787293 0.844838
timm_models_bfloat16_training mobilevit_s 0.722290 0.960236
  • 🟡 [80%, 90%), may be fluctuations
Category Model Target vs. Baseline [Eager] Target vs. Baseline [Inductor]
timm_models_bfloat16_training convnextv2_nano.fcmae_ft_in22k_in1k 0.808973 0.815837
timm_models_bfloat16_training swin_base_patch4_window7_224 0.837380 0.828020
timm_models_bfloat16_training deit_tiny_patch16_224.fb_in1k 0.865131 0.840690
timm_models_bfloat16_training repvgg_a2 0.828854 0.846576
timm_models_bfloat16_training ghostnet_100 0.845650 0.850532
timm_models_bfloat16_training mobilenetv2_100 0.839038 0.872309
timm_models_bfloat16_training tf_efficientnet_b0 0.800028 0.907076

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ai_generated] XPU wrong result for torch.compile adaptive_avg_pool2d flatten-sum fusion

2 participants