From 8d16a73f0f6470133c7351fd1eead0d04da8ed6f Mon Sep 17 00:00:00 2001 From: Sam Larsen Date: Thu, 6 Jun 2024 13:55:05 -0700 Subject: [PATCH] Manipulate triton_hash_with_backend so that it doesn't contain any keywords (#128159) Summary: See https://github.com/pytorch/pytorch/issues/127637 where "def" appears in the backend_hash and causes a problem. Pull Request resolved: https://github.com/pytorch/pytorch/pull/128159 Approved by: https://github.com/jansel --- torch/utils/_triton.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/torch/utils/_triton.py b/torch/utils/_triton.py index 9184f782cc7..ab93a398287 100644 --- a/torch/utils/_triton.py +++ b/torch/utils/_triton.py @@ -61,7 +61,9 @@ def triton_hash_with_backend(): backend = triton_backend() key = f"{triton_key()}-{backend.hash()}" - return hashlib.sha256(key.encode("utf-8")).hexdigest() + + # Hash is upper case so that it can't contain any Python keywords. + return hashlib.sha256(key.encode("utf-8")).hexdigest().upper() def dtype_to_string(dtype):