Migrate Inductor scheduler, dependencies, ir, and codegen/common to use OrderedSet (#130004)

Python's set is non deterministic. There is an internal failure which we recently ran into which did not consistently fail.

See, repro here: P1453035092.

Now, with these changes, it does consistently fail. In follow ups we could also consider adding a lintrule for uses of either set() or set literals.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/130004
Approved by: https://github.com/oulgen
This commit is contained in:
eellison
2024-07-30 14:38:53 -07:00
committed by PyTorch MergeBot
parent 2c7bd61afa
commit 13d744464f
13 changed files with 367 additions and 306 deletions

View File

@ -5,6 +5,7 @@ import pathlib
from typing import Any, List
from torch._inductor.metrics import get_metric_table, is_metric_table_enabled
from torch.utils._ordered_set import OrderedSet
from .. import config
from ..codecache import get_path, TritonFuture
@ -219,11 +220,11 @@ class MultiKernel:
@property
def removed_buffers(self):
return set.intersection(*[k.removed_buffers for k in self.kernels])
return OrderedSet.intersection(*[k.removed_buffers for k in self.kernels])
@property
def inplaced_to_remove(self):
return set.intersection(*[k.inplaced_to_remove for k in self.kernels])
return OrderedSet.intersection(*[k.inplaced_to_remove for k in self.kernels])
@property
@cache_on_self