From 154e56adf457810d1caa22c383babf6a175099ce Mon Sep 17 00:00:00 2001 From: Alex Baden Date: Fri, 31 May 2024 23:46:41 -0500 Subject: [PATCH] Use dictionary unpacking instead of merge operator for python 3.8 compatibility (#4049) The dictionary merge operator was introduced in Python 3.9 and unfortunately PyTorch still supports 3.8. I think for this use case there is no downside to unpacking, other than that it's a bit ugly. --- python/triton/runtime/autotuner.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/python/triton/runtime/autotuner.py b/python/triton/runtime/autotuner.py index 8115776beb65..73e61866273c 100644 --- a/python/triton/runtime/autotuner.py +++ b/python/triton/runtime/autotuner.py @@ -239,15 +239,16 @@ def __init__(self, kwargs, num_warps=4, num_stages=2, num_ctas=1, maxnreg=None, self.pre_hook = pre_hook def all_kwargs(self): - return self.kwargs | { - k: v - for (k, v) in ( - ("num_warps", self.num_warps), - ("num_ctas", self.num_ctas), - ("num_stages", self.num_stages), - ("maxnreg", self.maxnreg), - ) - if v is not None + return { + **self.kwargs, **{ + k: v + for (k, v) in ( + ("num_warps", self.num_warps), + ("num_ctas", self.num_ctas), + ("num_stages", self.num_stages), + ("maxnreg", self.maxnreg), + ) if v is not None + } } def __str__(self):