已合并
【bug-fix】DeviceProperty属性中multi_processor_count设置默认值 #31539
【bug-fix】DeviceProperty属性中multi_processor_count设置默认值 #31539
已合并
xiaoqi-zhou创建于 3月9日
2 个文件变更+10-1
@@ -67,7 +67,7 @@ class TorchNPUDeviceTestCase(TestCase):
67 def test_npu_get_unsupported_device_properties(self):67 def test_npu_get_unsupported_device_properties(self):
68 props = torch_npu.npu.get_device_properties(0)68 props = torch_npu.npu.get_device_properties(0)
69 unsupported_fields = [69 unsupported_fields = [
70- 'major', 'minor', 'is_multi_gpu_board', 'is_integrated', 'multi_processor_count',70+ 'major', 'minor', 'is_multi_gpu_board', 'is_integrated',
71 'max_threads_per_multi_processor', 'warp_size', 'regs_per_multiprocessor', 'gcnArchName'71 'max_threads_per_multi_processor', 'warp_size', 'regs_per_multiprocessor', 'gcnArchName'
72 ]72 ]
73 for field in unsupported_fields:73 for field in unsupported_fields:
@@ -213,6 +213,15 @@ void initDeviceProperty(int64_t deviceid)
213 NPU_CHECK_ERROR_WITHOUT_UCE(aclGetDeviceCapability(deviceid, ACL_DEVICE_INFO_L2_SIZE, &L2_cache_size));213 NPU_CHECK_ERROR_WITHOUT_UCE(aclGetDeviceCapability(deviceid, ACL_DEVICE_INFO_L2_SIZE, &L2_cache_size));
214 device_properties[deviceid].L2_cache_size = L2_cache_size;214 device_properties[deviceid].L2_cache_size = L2_cache_size;
215 215 
216+ // Set multi_processor_count to vector_core_num for compatibility with DataParallel balance check
217+ // Use vector_core_num as it represents the number of processing units similar to CUDA's multi_processor_count
218+ if (vector_core_num > 0) {
219+ device_properties[deviceid].multi_processor_count = static_cast<int>(vector_core_num);
220+ } else if (cube_core_num > 0) {
221+ // Fallback to cube_core_num if vector_core_num is not available
222+ device_properties[deviceid].multi_processor_count = static_cast<int>(cube_core_num);
223+ }
224+ 
216 if (c10_npu::acl::IsExistDeviceGetUuid()) {225 if (c10_npu::acl::IsExistDeviceGetUuid()) {
217 aclError err = c10_npu::acl::AclrtDeviceGetUuid(deviceid, &uuid);226 aclError err = c10_npu::acl::AclrtDeviceGetUuid(deviceid, &uuid);
218 if (err == ACL_ERROR_NONE) {227 if (err == ACL_ERROR_NONE) {