[Build] Fix CUDA arch detection producing kernel-less builds on SM121 (#49904)
This commit is contained in:
@@ -21,3 +21,28 @@ endif()
|
||||
)
|
||||
|
||||
subprocess.run(["cmake", "-P", script], check=True)
|
||||
|
||||
|
||||
def test_extract_archs_prefers_sass_target_over_corrupted_virtual_arch(
|
||||
tmp_path: Path,
|
||||
):
|
||||
"""torch's autodetection can emit a bogus arch=compute_* half (e.g.
|
||||
capability 12.1 corrupted to arch=compute_20,code=sm_121); the SASS
|
||||
target must win, while PTX-only entries keep the virtual arch."""
|
||||
repo_root = Path(__file__).parents[1]
|
||||
script = tmp_path / "test_extract_archs.cmake"
|
||||
script.write_text(
|
||||
f"""
|
||||
cmake_minimum_required(VERSION 3.26)
|
||||
include("{repo_root / "cmake" / "utils.cmake"}")
|
||||
extract_unique_cuda_archs_ascending(actual
|
||||
"-gencode arch=compute_20,code=sm_121;\
|
||||
-gencode arch=compute_80,code=sm_80;\
|
||||
-gencode arch=compute_80,code=compute_80")
|
||||
if(NOT "${{actual}}" STREQUAL "8.0;12.1")
|
||||
message(FATAL_ERROR "Expected '8.0;12.1', got '${{actual}}'")
|
||||
endif()
|
||||
"""
|
||||
)
|
||||
|
||||
subprocess.run(["cmake", "-P", script], check=True)
|
||||
|
||||
Reference in New Issue
Block a user