Skip to content

Commit e008608

Browse files
committed
Fix ValueError handling and add device type check
Signed-off-by: Hubert Zhang <hubert.zyk@gmail.com>
1 parent 2fe70fa commit e008608

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

checkpoint_engine/device_utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def npu_generate_uuid() -> str:
3939
match_chip_id = re.search(r"Chip ID[^\d]*(\d+)", search_after_pid)
4040
chip_id = int(match_chip_id.group(1))
4141
return f"{get_ip()}-{npu_id * chip_count + chip_id}"
42-
ValueError("The current process is not running on the npu device")
43-
except subprocess.CalledProcessError:
44-
ValueError("The current process is not running on the npu device")
42+
raise ValueError("The current process is not running on the npu device")
43+
except subprocess.CalledProcessError as e:
44+
raise ValueError("The current process is not running on the npu device") from e
4545

4646

4747
class DeviceManager:
@@ -82,3 +82,5 @@ def backend(self) -> str:
8282
return "hccl"
8383
elif self.device_type == "cuda":
8484
return "nccl"
85+
else:
86+
raise TypeError("The current device type is not supported")

0 commit comments

Comments
 (0)