mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
IPEX add GPU cache size table
This commit is contained in:
@@ -108,12 +108,8 @@ def ipex_init(): # pylint: disable=too-many-statements
|
||||
torch.cuda.BoolStorage = torch.xpu.BoolStorage
|
||||
torch.cuda.ComplexFloatStorage = torch.xpu.ComplexFloatStorage
|
||||
torch.cuda.ComplexDoubleStorage = torch.xpu.ComplexDoubleStorage
|
||||
|
||||
torch._C._cuda_getCurrentRawStream = ipex._C._getCurrentRawStream
|
||||
ipex._C._DeviceProperties.multi_processor_count = ipex._C._DeviceProperties.gpu_subslice_count
|
||||
ipex._C._DeviceProperties.major = 12
|
||||
ipex._C._DeviceProperties.minor = 1
|
||||
ipex._C._DeviceProperties.L2_cache_size = 16*1024*1024 # A770 and A750
|
||||
if has_ipex:
|
||||
torch._C._cuda_getCurrentRawStream = ipex._C._getCurrentRawStream
|
||||
else:
|
||||
torch.cuda._initialization_lock = torch.xpu._initialization_lock
|
||||
torch.cuda._initialized = torch.xpu._initialized
|
||||
@@ -123,12 +119,7 @@ def ipex_init(): # pylint: disable=too-many-statements
|
||||
torch.cuda._tls = torch.xpu._tls
|
||||
torch.cuda.threading = torch.xpu.threading
|
||||
torch.cuda.traceback = torch.xpu.traceback
|
||||
|
||||
torch._C._cuda_getCurrentRawStream = torch._C._xpu_getCurrentRawStream
|
||||
torch._C._XpuDeviceProperties.multi_processor_count = torch._C._XpuDeviceProperties.gpu_subslice_count
|
||||
torch._C._XpuDeviceProperties.major = 12
|
||||
torch._C._XpuDeviceProperties.minor = 1
|
||||
torch._C._XpuDeviceProperties.L2_cache_size = 16*1024*1024 # A770 and A750
|
||||
|
||||
if torch_version[0] < 2 or (torch_version[0] == 2 and torch_version[1] < 5):
|
||||
torch.cuda.os = torch.xpu.os
|
||||
@@ -207,9 +198,6 @@ def ipex_init(): # pylint: disable=too-many-statements
|
||||
torch.version.cuda = "12.1"
|
||||
torch.cuda.get_arch_list = getattr(torch.xpu, "get_arch_list", lambda: ["pvc", "dg2", "ats-m150"])
|
||||
torch.cuda.get_device_capability = lambda *args, **kwargs: (12,1)
|
||||
torch.cuda.get_device_properties.major = 12
|
||||
torch.cuda.get_device_properties.minor = 1
|
||||
torch.cuda.get_device_properties.L2_cache_size = 16*1024*1024 # A770 and A750
|
||||
torch.cuda.ipc_collect = lambda *args, **kwargs: None
|
||||
torch.cuda.utilization = lambda *args, **kwargs: 0
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
|
||||
|
||||
def mb_to_byte(mb: int) -> int:
|
||||
return mb * 1024*1024
|
||||
|
||||
unknown_cache_size = 2
|
||||
cache_size_dict = {
|
||||
0x0000: mb_to_byte(unknown_cache_size),
|
||||
0xE212: mb_to_byte(4), # Arc Pro B50 / Xe2
|
||||
0xE211: mb_to_byte(18), # Arc Pro B60 / Xe2
|
||||
0xE20B: mb_to_byte(18), # Arc B580 / Xe2
|
||||
0xE20C: mb_to_byte(18), # Arc B570 / Xe2
|
||||
0x64A0: mb_to_byte(4), # Arc 130V Mobile / Arc 140V Mobile / Lunar Lake / Xe2
|
||||
0x6420: mb_to_byte(unknown_cache_size*2), # (?) (EU: 64/56) / Lunar Lake / Xe2
|
||||
0x64B0: mb_to_byte(unknown_cache_size), # (?) (EU: 32) / Lunar Lake / Xe2
|
||||
0x7D51: mb_to_byte(4), # Arc 130T Mobile / Arc 140T Mobile / Arrow Lake-H / Xe-LPG
|
||||
0x7D67: mb_to_byte(unknown_cache_size*2), # (?) (EU: 64/48/32) / Arrow Lake-S / Xe-LPG
|
||||
0x7D41: mb_to_byte(unknown_cache_size*2), # (?) (EU: 64) / Arrow Lake-U / Xe-LPG
|
||||
0x7DD5: mb_to_byte(unknown_cache_size*2), # (?) (EU: 128/112) / Meteor Lake / Xe-LPG
|
||||
0x7D45: mb_to_byte(unknown_cache_size), # (?) (EU: 64/48) / Meteor Lake / Xe-LPG
|
||||
0x7D40: mb_to_byte(unknown_cache_size), # (?) (EU: 64/48) / Meteor Lake / Xe-LPG
|
||||
0x7D55: mb_to_byte(unknown_cache_size*2), # (?) (EU: 128/112) / Meteor Lake / Xe-LPG
|
||||
0x0BD5: mb_to_byte(408), # Max 1550 / Xe-HPC
|
||||
0x0BDA: mb_to_byte(204) , # Max 1100 / Xe-HPC
|
||||
0x56C0: mb_to_byte(16), # Flex 170 / Xe-HPG
|
||||
0x56C1: mb_to_byte(4), # Flex 140 / Xe-HPG
|
||||
0x5690: mb_to_byte(16), # Arc A770M / Xe-HPG
|
||||
0x5691: mb_to_byte(12), # Arc A730M / Xe-HPG
|
||||
0x5696: mb_to_byte(8), # Arc A570M / Xe-HPG
|
||||
0x5692: mb_to_byte(8), # Arc A550M / Xe-HPG
|
||||
0x5697: mb_to_byte(8), # Arc A530M / Xe-HPG
|
||||
0x5693: mb_to_byte(4), # Arc A370M / Xe-HPG
|
||||
0x5694: mb_to_byte(4), # Arc A350M / Xe-HPG
|
||||
0x56A0: mb_to_byte(16), # Arc A770 / Xe-HPG
|
||||
0x56A1: mb_to_byte(16), # Arc A750 / Xe-HPG
|
||||
0x56A2: mb_to_byte(8), # Arc A580 / Xe-HPG
|
||||
0x56A5: mb_to_byte(4), # Arc A380 / Xe-HPG
|
||||
0x56A6: mb_to_byte(4), # Arc A310 / Xe-HPG
|
||||
0x56B3: mb_to_byte(12), # Arc Pro A60 / Xe-HPG
|
||||
0x56B2: mb_to_byte(8), # Arc Pro A60M / Xe-HPG
|
||||
0x56B1: mb_to_byte(4), # Arc Pro A40/A50 / Xe-HPG
|
||||
0x56B0: mb_to_byte(4), # Arc Pro A30M / Xe-HPG
|
||||
0x56BA: mb_to_byte(unknown_cache_size*2), # Arc A380E / Xe-HPG
|
||||
0x56BC: mb_to_byte(unknown_cache_size*2), # Arc A370E / Xe-HPG
|
||||
0x56BD: mb_to_byte(unknown_cache_size*2), # Arc A350E / Xe-HPG
|
||||
0x56BB: mb_to_byte(unknown_cache_size*2), # Arc A310E / Xe-HPG
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import torch
|
||||
import numpy as np
|
||||
from modules import devices
|
||||
|
||||
from .device_prop import cache_size_dict
|
||||
|
||||
torch_version = torch.__version__[:4]
|
||||
if torch_version[-1] not in {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}:
|
||||
@@ -310,6 +311,27 @@ def torch_cuda_set_device(device):
|
||||
torch.xpu.set_device(device)
|
||||
|
||||
|
||||
@wraps(torch.cuda.get_device_properties)
|
||||
def get_device_properties(device = None):
|
||||
device_prop = torch.xpu.get_device_properties(device)
|
||||
new_keys = {
|
||||
"major": 12,
|
||||
"minor": 1,
|
||||
"multi_processor_count": device_prop.gpu_subslice_count,
|
||||
"L2_cache_size": cache_size_dict.get(getattr(device_prop, "device_id", 0x56A0), cache_size_dict[0x0000]),
|
||||
}
|
||||
return DeviceProperties(device_prop, new_keys)
|
||||
|
||||
|
||||
class DeviceProperties():
|
||||
def __init__(self, device_prop, new_keys):
|
||||
for key in dir(device_prop):
|
||||
if not key.startswith("__"):
|
||||
setattr(self, key, getattr(device_prop, key))
|
||||
for key, value in new_keys.items():
|
||||
setattr(self, key, value)
|
||||
|
||||
|
||||
# torch.Generator has to be a class for isinstance checks
|
||||
original_torch_Generator = torch.Generator
|
||||
class torch_Generator(original_torch_Generator):
|
||||
@@ -343,6 +365,7 @@ def ipex_hijacks():
|
||||
torch.cuda.synchronize = torch_cuda_synchronize
|
||||
torch.cuda.device = torch_cuda_device
|
||||
torch.cuda.set_device = torch_cuda_set_device
|
||||
torch.cuda.get_device_properties = get_device_properties
|
||||
|
||||
torch.Generator = torch_Generator
|
||||
torch._C.Generator = torch_Generator
|
||||
|
||||
Reference in New Issue
Block a user