platforms: Fix Ray DP startup crash (#36665)

Signed-off-by: Itay Alroy <ialroy@nvidia.com>
This commit is contained in:
Itay Alroy
2026-03-11 12:08:55 +02:00
committed by GitHub
parent 13e79fc811
commit 5353c9b016

View File

@@ -638,6 +638,11 @@ class Platform:
"""Raises if this request is unsupported on this platform"""
def __getattr__(self, key: str):
# Pickle checks dunder methods like __getstate__. If we return None
# for them, pickle treats it like a real value and tries to call it.
if key.startswith("__") and key.endswith("__"):
raise AttributeError(key)
device = getattr(torch, self.device_type, None)
if device is not None and hasattr(device, key):
attr = getattr(device, key)