Buckets:

tahamajs's picture
download
raw
1.01 kB
"""Hardware device management for AEGIS."""
import torch
def get_device(preferred_device: str = "auto") -> torch.device:
"""Resolves and returns the appropriate torch.device.
Args:
preferred_device: 'auto', 'cuda', 'mps', 'cpu', or specific cuda index 'cuda:0'.
"""
if preferred_device != "auto":
return torch.device(preferred_device)
if torch.cuda.is_available():
return torch.device("cuda")
if hasattr(torch.backends, "mps") and torch.backends.mps.is_available():
return torch.device("mps")
return torch.device("cpu")
def get_torch_dtype(dtype_str: str) -> torch.dtype:
"""Maps string representation of dtype to torch.dtype."""
dtype_map = {
"float32": torch.float32,
"fp32": torch.float32,
"float16": torch.float16,
"fp16": torch.float16,
"bfloat16": torch.bfloat16,
"bf16": torch.bfloat16,
"int8": torch.int8,
}
return dtype_map.get(dtype_str.lower(), torch.float32)

Xet Storage Details

Size:
1.01 kB
·
Xet hash:
7a62a4113db58edc5875a9750d1d7bd3d5db7e472c60ff6787012969c0730837

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.