Skip to content

Commit 291cd11

Browse files
ruisizhang123pytorchmergebot
authored andcommitted
[inductor] estimate peak memory in codegen only when buffer reuse (#162300)
As titled, this PR ensures peak memory is estimated only when buffer reuse is enabled. Without this config, some nodes' successor nodes are eliminated from memory estimation after inductor bucketing, which can cause errors. The original codegen peak memory estimation code is from this PR: #159530 Pull Request resolved: #162300 Approved by: https://github.com/eellison, https://github.com/v0i0
1 parent 7f4ff79 commit 291cd11

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

torch/_inductor/codegen/wrapper.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1736,7 +1736,8 @@ def run_wrapper_ir_passes(self, is_inference: bool):
17361736
if is_inference and config.memory_planning:
17371737
self.memory_plan()
17381738
else:
1739-
self.estimate_peak = EfficientPeakEstimate()
1739+
if config.allow_buffer_reuse:
1740+
self.estimate_peak = EfficientPeakEstimate()
17401741
self.memory_plan_reuse()
17411742

17421743
def codegen_input_symbol_assignment(

0 commit comments

Comments
 (0)