[inductor] Clamp explicit mix-order split size to a power of two on npu by zhoushaowen69 · Pull Request #201600 · pytorch/pytorch · GitHub
Skip to content

[inductor] Clamp explicit mix-order split size to a power of two on npu - #201600

Open
zhoushaowen69 wants to merge 1 commit into
pytorch:mainfrom
zhoushaowen69:fix/mix-order-split-size-pow2
Open

zhoushaowen69 wants to merge 1 commit into
pytorch:mainfrom
zhoushaowen69:fix/mix-order-split-size-pow2

Conversation

@zhoushaowen69

Copy link
Copy Markdown

On npu (triton-ascend on Ascend 910B4), a non-power-of-two
config.triton.mix_order_reduction_split_size miscompiles the tail-block
mask of the mix-order kernel: with a (40961, 129) bf16 sum(dim=-1)+sum(dim=0)
probe, split sizes 18/24/48 over-count 1-3 rows of the tail block (each
column's sum is off by an exact multiple of 0.25), while 16/32/64 are correct.

The heuristic branch below already yields a power of two (last_power_of_2
clamped to [16, 128]); only the explicit config override can inject a
non-power-of-two value. Clamp it on npu to the largest power of two <= the
requested value (18→16, 24→16, 48→32), all within the verified-correct set.
Other devices are untouched.

With this clamp, split sizes 16/18/20/24/32/48/64 all produce bit-correct
results on 910B4, and
test/inductor/test_mix_order_reduction.py::MixOrderReductionNumericTest
(passing an explicit split size of 18) runs clean.

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo

🤖 Generated with Claude Code

@pytorch-bot

pytorch-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

@pytorch-bot

pytorch-bot Bot commented Oct 21, 2026

Copy link
Copy Markdown

The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:

  • ciflow/inductor
  • ciflow/torchtitan

Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows.

1 similar comment
@pytorch-bot

pytorch-bot Bot commented Oct 21, 2026

Copy link
Copy Markdown

The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:

  • ciflow/inductor
  • ciflow/torchtitan

Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ Unknown (e80e5e4)
  • ✅ login: zhoushaowen69 / name: zhoushaowen69 (e80e5e4)

One or more co-authors of this pull request were not found. You must specify co-authors in commit message trailer via:

Co-authored-by: name <email>

Supported Co-authored-by: formats include:

  1. Anything <id+login@users.noreply.github.com> - it will locate your GitHub user by id part.
  2. Anything <login@users.noreply.github.com> - it will locate your GitHub user by login part.
  3. Anything <public-email> - it will locate your GitHub user by public-email part. Note that this email must be made public on Github.
  4. Anything <other-email> - it will locate your GitHub user by other-email part but only if that email was used before for any other CLA as a main commit author.
  5. login <any-valid-email> - it will locate your GitHub user by login part, note that login part must be at least 3 characters long.

Alternatively, if the co-author should not be included, remove the Co-authored-by: line from the commit message.

Please update your commit message(s) by doing git commit --amend and then git push [--force] and then request re-running CLA check via commenting on this pull request:

/easycla

@github-actions github-actions Bot added bot-triaged This is a label only to be used by the auto triage bot missing actionable issue A PR without a linked actionable issue or maintainer sponsor triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Oct 21, 2026
Probed on 910B4 / triton-ascend 3.6 with (40961, 129) bf16
sum(dim=-1)+sum(dim=0): RSPLIT_SIZE values that are powers of two
(16/32/64) produce correct results; non-powers of two (18/24/48)
miscompile the tail-block mask of the mix-order kernel and over-count
1-3 rows. The upstream heuristic branch already yields a power of two
(last_power_of_2, clamped to [16, 128]); only the explicit
config.triton.mix_order_reduction_split_size override can produce a
non-power-of-two, so clamp it on npu to the largest power of two <= the
requested value.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@zhoushaowen69
zhoushaowen69 force-pushed the fix/mix-order-split-size-pow2 branch 2 times, most recently from 5a26acc to e80e5e4 Compare October 21, 2026 11:28
@zhoushaowen69

Copy link
Copy Markdown
Author

This branch was successfully deployed

1 active (outdated) deployment
bedrock — 5b08ae5d Deployed Oct 21, 2026 by pytorchbot via analyze #12170
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-triaged This is a label only to be used by the auto triage bot ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests missing actionable issue A PR without a linked actionable issue or maintainer sponsor module: inductor open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants