8000 [inductor] enable bf32 for mkldnn linear pointwise/binary in inductor by zhuhaozhe · Pull Request #127294 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@zhuhaozhe
Copy link
Collaborator
@zhuhaozhe zhuhaozhe commented May 28, 2024

When torch.backends.mkldnn.matmul.fp32_precision=='bf16', we also enabled mkldnn linear in inductor path and allow to run with bf16 computation data type.

Testplan:

python test/inductor/test_mkldnn_pattern_matcher.py -k test_linear_unary
python test/inductor/test_mkldnn_pattern_matcher.py -k test_linear_fp32
python test/inductor/test_mkldnn_pattern_matcher.py -k test_multi_linear_share_same_input

Stack from ghstack (oldest at bottom):

cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @jerryzh168 @voznesenskym @penguinwu @EikanWang @Guobing-Chen @blzheng @wenzhe-nrv @jiayisunx @ipiszy @chenyang78 @kadeng @muchulee8 @amjames @chauhang @aakhundov @peterbell10 @yf225 @ColinPeppler @desertfire

@pytorch-bot
Copy link
pytorch-bot bot commented May 28, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/127294

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (7 Unrelated Failures)

As of commit 63915d3 with merge base 2022588 (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but was present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

[ghstack-poisoned]
@zhuhaozhe zhuhaozhe marked this pull request as draft May 28, 2024 14:01
@zhuhaozhe zhuhaozhe requested a review from jgong5 May 28, 2024 14:15
Comment on lines 786 to 790
if not hasattr(add_node.args[1], "meta"):
# May add an "int"
# We meet this issue while enabling bf32 for test_linear_unary
# the hardsimoid case will add "3" here and cannot check meta
# TODO: Further investigate on this issue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it for the bias node or something else? Can you double check? Why didn't we get the problem in the past?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be another input node for "add".
We did not meet this in the past because we only enabled and tested lp for mkldnn fusion. For lp case, there will be a "to_dtype" inserted by autocast and will not match this pattern.

I am trying to find a case to satisfy this pattern by raising a runtime error if this function will return True.
#127597

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #127597

zhuhaozhe added a commit that referenced this pull request May 30, 2024
[ghstack-poisoned]
[ghstack-poisoned]
zhuhaozhe added a commit that referenced this pull request Jun 4, 2024
[ghstack-poisoned]
zhuhaozhe added a commit that referenced this pull request Jun 5, 2024
[ghstack-poisoned]
@zhuhaozhe zhuhaozhe requested a review from jgong5 June 5, 2024 08:33
zhuhaozhe added a commit that referenced this pull request Jun 5, 2024
[ghstack-poisoned]
zhuhaozhe added a commit that referenced this pull request Jun 7, 2024
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
yanbing-j pushed a commit to yanbing-j/pytorch that referenced this pull request Jun 30, 2025
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
yanbing-j added 2 commits July 3, 2025 01:36
[ghstack-poisoned]
[ghstack-poisoned]
@yanbing-j yanbing-j marked this pull request as ready for review July 3, 2025 08:41
@yanbing-j
Copy link
Collaborator

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: Approvers from one of the following sets are needed:

  • superuser (pytorch/metamates)
  • Core Reviewers (mruberry, lezcano, Skylion007, ngimel, peterbell10, ...)
  • Core Maintainers (soumith, gchanan, ezyang, dzhulgakov, malfet, ...)
Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@yanbing-j yanbing-j requested a review from jansel July 3, 2025 09:49
@yanbing-j
Copy link
Collaborator

Hi @jansel , could you please help review this PR as well? Thanks!

This PR is the follow-up of #125888, which is to refine fp32 precision API and has been merged. This PR will allow BF32 for mkldnn linear, which is use BF16 as FP32 internal precision for calculation.

[ghstack-poisoned]
@yanbing-j
Copy link
Collaborator

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@github-actions github-actions bot deleted the gh/zhuhaozhe/33/head branch August 7, 2025 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td Do not run TD on this PR ciflow/inductor ciflow/rocm Trigger "default" config CI on ROCm ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 ciflow/trunk Trigger trunk jobs on your pull request ciflow/xpu Run XPU CI tasks Merged module: cpu CPU specific problem (e.g., perf, algorithm) module: inductor open source topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

0