add needs_second_gpu decorator (#13543)

* add needs_second_gpu decorator

* more skips

* two more fixes
This commit is contained in:
George Hotz
2025-12-02 19:08:23 -08:00
committed by GitHub
parent 0d55aec605
commit 6bd355fa26
10 changed files with 52 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
import time, struct
import time, struct, functools
from typing import Any, Callable
import numpy as np
from tinygrad import Tensor, dtypes, Device
@@ -60,5 +60,14 @@ def not_support_multi_device():
# CL and CUDA don't support multi device if in CI
return CI and REAL_DEV in ("CL", "CUDA")
def needs_second_gpu(fn):
@functools.wraps(fn)
def wrapper(self, *args, **kwargs):
# check if there's a second GPU, if not, skip multi tests
try: Tensor.zeros(10, device=f"{Device.DEFAULT}:1").contiguous().realize()
except Exception as e: self.skipTest(f"second device not available: {e}")
return fn(self, *args, **kwargs)
return wrapper
# NOTE: This will open REMOTE if it's the default device
REAL_DEV = (Device.DEFAULT if Device.DEFAULT != "REMOTE" else Device['REMOTE'].properties.real_device)