Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Inductor] Fix the High Order Op layout issue (#128275) #128834

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

zou3519
Copy link
Contributor

@zou3519 zou3519 commented Jun 17, 2024

Fix the issue: #127995

  • In current implementation of creating FallbackKernel, the device of the NoneLayout is set to None when example_output returns from cls.process_kernel is None.

    pytorch/torch/_inductor/ir.py

    Lines 5632 to 5649 in 921aa19

    with context:
    (
    example_output,
    tensor_args,
    non_tensor_args,
    unflatten_args,
    unbacked_bindings,
    ) = cls.process_kernel(kernel, *args, **kwargs)
    if example_output is None:
    packed = cls(
    NoneLayout(None),
    kernel,
    tensor_args,
    non_tensor_args,
    unflatten_args,
    unbacked_bindings=unbacked_bindings,
    )
  • If a ExternalKernel schedulerNode has None device, the previous buffer will not flush before codegen this ExternalKernel schedulerNode which causes the wrong generated code.
    if not isinstance(node, NopKernelSchedulerNode) and (
    device := node.get_device()
    ):
    if (
    device != self.current_device
    or node.is_extern()
    or node.is_template()
    ):
    self.flush()

Test Plan

python -u -m pytest -s -v test/higher_order_ops/test_with_effects.py -k test_compile_inductor_external_op_return_none

Pull Request resolved: #128275
Approved by: https://github.com/eellison

Fixes #ISSUE_NUMBER

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @peterbell10 @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @chauhang

Fix the issue: #127995

- In current implementation of creating `FallbackKernel`, the `device` of the `NoneLayout` is set to `None` when `example_output` returns from `cls.process_kernel` is `None`. https://github.com/pytorch/pytorch/blob/921aa194c77f5279b15415eaa213813ddcdb3b29/torch/_inductor/ir.py#L5632-L5649
- If a `ExternalKernel schedulerNode` has None device, the previous buffer will not flush before codegen this `ExternalKernel schedulerNode`  which causes the wrong generated code.
https://github.com/pytorch/pytorch/blob/ef2b5ed500cba0b8b2bf04e6006a0d64c910f440/torch/_inductor/scheduler.py#L2701-L2709

**Test Plan**
```
python -u -m pytest -s -v test/higher_order_ops/test_with_effects.py -k test_compile_inductor_external_op_return_none
```

Pull Request resolved: #128275
Approved by: https://github.com/eellison
Copy link

pytorch-bot bot commented Jun 17, 2024

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 17 New Failures

As of commit e41397d with merge base b66e3f0 (image):

NEW FAILURES - The following jobs have failed:

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

@atalman atalman merged commit 0e0a9c5 into release/2.4 Jun 19, 2024
148 of 165 checks passed
@github-actions github-actions bot deleted the rzou/2.4/silent_incorrect_custom_op branch July 20, 2024 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants