Skip to content

Commit e8e45a4

Browse files
authored
[RUNTIME] Replace random number with UUID (#3544)
On a distributed setting, processes from different nodes may have the same PID. If the seed for `random` is also set, the random number is also the same, which may finally lead to collision (actually happened on my cluster). Changing the random number to `uuid` avoids such collision.
1 parent e14516a commit e8e45a4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

python/triton/runtime/cache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import importlib
22
import json
33
import os
4-
import random
4+
import uuid
55
from abc import ABC, abstractmethod
66
from pathlib import Path
77
from typing import Dict, List, Optional
@@ -113,7 +113,7 @@ def put(self, data, filename, binary=True) -> str:
113113
assert self.lock_path is not None
114114
filepath = self._make_path(filename)
115115
# Random ID to avoid any collisions
116-
rnd_id = random.randint(0, 1000000)
116+
rnd_id = str(uuid.uuid4())
117117
# we use the PID in case a bunch of these around so we can see what PID made it
118118
pid = os.getpid()
119119
# use tempfile to be robust against program interruptions

0 commit comments

Comments
 (0)