From 5fba13694d32fc38718fe649ab9cb8b9f3ae3c52 Mon Sep 17 00:00:00 2001 From: Bin Bao Date: Tue, 11 Nov 2025 07:24:30 -0800 Subject: [PATCH] Fix missing AMD cache info when running on a VM Summary: Fix https://github.com/pytorch/pytorch/issues/138718. This PR is verified to fix the issue and will be guarded on the PyTorch CI. When running on a VM, the AMD TopologyExtensions bit can be cleared, but that shouldn't stop us from reading the cache information. --- src/x86/api.h | 1 + src/x86/cache/init.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/x86/api.h b/src/x86/api.h index 1331ed04..4d456c53 100644 --- a/src/x86/api.h +++ b/src/x86/api.h @@ -105,6 +105,7 @@ CPUINFO_INTERNAL void cpuinfo_x86_detect_topology( CPUINFO_INTERNAL void cpuinfo_x86_detect_cache( uint32_t max_base_index, uint32_t max_extended_index, + /* amd_topology_extensions is not used, kept for backward compatibility */ bool amd_topology_extensions, enum cpuinfo_vendor vendor, const struct cpuinfo_x86_model_info* model_info, diff --git a/src/x86/cache/init.c b/src/x86/cache/init.c index 34af90e7..b07e61e7 100644 --- a/src/x86/cache/init.c +++ b/src/x86/cache/init.c @@ -87,7 +87,7 @@ void cpuinfo_x86_detect_cache( } } } - if (amd_topology_extensions && max_extended_index >= UINT32_C(0x8000001D)) { + if (max_extended_index >= UINT32_C(0x8000001D)) { struct cpuid_regs leaf0x8000001D; uint32_t input_ecx = 0; do {