pytorch - 💡(How to fix) Fix [Inductor] Copy-paste typo in scheduler prologue fusion guard: `node1` checked twice instead of `node1` and `node2`

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fix

-            if node1.has_aliasing_or_mutation() or node1.has_aliasing_or_mutation():
+            if node1.has_aliasing_or_mutation() or node2.has_aliasing_or_mutation():
                 why("template prologue can only fuse functional pointwise nodes")
                 return False

Code Example

# Line 6610 (BUGGY):
if node1.has_aliasing_or_mutation() or node1.has_aliasing_or_mutation():
    why("template prologue can only fuse functional pointwise nodes")
    return False

---

# Correct:
if node1.has_aliasing_or_mutation() or node2.has_aliasing_or_mutation():
    why("template prologue can only fuse functional pointwise nodes")
    return False

---

# Line 6377 (correct):
if node1.has_aliasing_or_mutation() or node2.has_aliasing_or_mutation():
    return None

---

import inspect
from torch._inductor import scheduler

source = inspect.getsource(scheduler)
lines = source.split('\n')

for i, line in enumerate(lines):
    if 'node1.has_aliasing_or_mutation() or node1.has_aliasing_or_mutation()' in line:
        for j in range(max(0, i-3), min(len(lines), i+4)):
            marker = ">>>" if j == i else "   "
            print(f"  {marker} {lines[j]}")
        print(f"\n  BUG: second 'node1' should be 'node2'")
        break

---

if node1.get_buffer_names() & unsupported_prologue_args:
                   why("prologue fusion not implemented for kernel for these inputs")
                   return False
   >>>
               if node1.has_aliasing_or_mutation() or node1.has_aliasing_or_mutation():
                   why("template prologue can only fuse functional pointwise nodes")
                   return False

     BUG: second 'node1' should be 'node2'

---

-            if node1.has_aliasing_or_mutation() or node1.has_aliasing_or_mutation():
+            if node1.has_aliasing_or_mutation() or node2.has_aliasing_or_mutation():
                 why("template prologue can only fuse functional pointwise nodes")
                 return False
RAW_BUFFERClick to expand / collapse

🐛 Describe the bug

🐛 Describe the bug

In torch/_inductor/scheduler.py, the can_fuse() method has a copy-paste typo in the template prologue fusion guard. The condition at line 6610 checks node1.has_aliasing_or_mutation() twice instead of checking both node1 and node2:

# Line 6610 (BUGGY):
if node1.has_aliasing_or_mutation() or node1.has_aliasing_or_mutation():
    why("template prologue can only fuse functional pointwise nodes")
    return False

The second node1 should be node2:

# Correct:
if node1.has_aliasing_or_mutation() or node2.has_aliasing_or_mutation():
    why("template prologue can only fuse functional pointwise nodes")
    return False

The same pattern is used correctly elsewhere in the same function:

# Line 6377 (correct):
if node1.has_aliasing_or_mutation() or node2.has_aliasing_or_mutation():
    return None

As a result, if node2 (the template node) has aliasing or mutation, the prologue fusion guard does not reject the fusion.

Reproducer

import inspect
from torch._inductor import scheduler

source = inspect.getsource(scheduler)
lines = source.split('\n')

for i, line in enumerate(lines):
    if 'node1.has_aliasing_or_mutation() or node1.has_aliasing_or_mutation()' in line:
        for j in range(max(0, i-3), min(len(lines), i+4)):
            marker = ">>>" if j == i else "   "
            print(f"  {marker} {lines[j]}")
        print(f"\n  BUG: second 'node1' should be 'node2'")
        break

Output:

               if node1.get_buffer_names() & unsupported_prologue_args:
                   why("prologue fusion not implemented for kernel for these inputs")
                   return False
   >>>
               if node1.has_aliasing_or_mutation() or node1.has_aliasing_or_mutation():
                   why("template prologue can only fuse functional pointwise nodes")
                   return False

     BUG: second 'node1' should be 'node2'

Fix

-            if node1.has_aliasing_or_mutation() or node1.has_aliasing_or_mutation():
+            if node1.has_aliasing_or_mutation() or node2.has_aliasing_or_mutation():
                 why("template prologue can only fuse functional pointwise nodes")
                 return False

Versions

Versions

  • PyTorch: 2.13.0.dev20260513+cu126
  • File: torch/_inductor/scheduler.py, line 6610

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - 💡(How to fix) Fix [Inductor] Copy-paste typo in scheduler prologue fusion guard: `node1` checked twice instead of `node1` and `node2`