Skip to content

Commit cccf0d8

Browse files
Address Windows stock build feedback
1 parent 71bda0e commit cccf0d8

6 files changed

Lines changed: 85 additions & 29 deletions

File tree

‎README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ GPU models sharing an architecture can expose different CU counts. When
121121
cross-building for a binned model, set `CU_NUM` to the target device's actual
122122
compute-unit count.
123123

124+
The first use of each CK FMHA variant triggers a large JIT build; later calls
125+
reuse the disk cache. Build time depends on the host and parallelism. An
126+
[independent gfx1101 report](https://github.com/ROCm/aiter/pull/4340#issuecomment-5108330794)
127+
measured 341.8 seconds with 12 build workers, so interactive users should expect
128+
the uncached first call to take several minutes.
129+
124130
### FlyDSL
125131

126132
AITER uses [FlyDSL](https://github.com/ROCm/FlyDSL)-based kernels across a range of operators (e.g., GEMM and MoE). FlyDSL is a required dependency and is installed automatically when you run `python3 setup.py develop`.

‎aiter/jit/core.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,11 @@ def get_user_jit_dir() -> str:
466466
def validate_and_update_archs():
467467
archs = os.getenv("GPU_ARCHS", "native").split(";")
468468
archs = [arch.strip() for arch in archs]
469+
if sys.platform == "win32":
470+
# TheRock's offload-arch helper cannot reliably resolve "native" on
471+
# Windows. PyTorch already exposes the live gfx name, so emit that
472+
# explicit target and avoid combining a derived arch with "native".
473+
archs = [get_gfx_runtime() if arch == "native" else arch for arch in archs]
469474
# List of allowed architectures
470475
allowed_archs = [
471476
"native",

‎aiter/jit/utils/build_targets.py‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
18: "gfx1250",
2929
}
3030

31-
# Maps gfx arch to the default (SPX / full-GPU) CU count used when no live GPU is
32-
# present at build time (e.g. CI nodes with GPU_ARCHS set but no device visible).
31+
# Maps gfx arch to the default physical CU count used when no live GPU is present
32+
# at build time (e.g. CI nodes with GPU_ARCHS set but no device visible).
3333
# For live GPU builds, get_cu_num() is used instead and correctly reflects the
3434
# actual visible CU count, including non-SPX partition modes (DPX / QPX / CPX)
3535
# and binned variants (e.g. MI308X is gfx942 but has fewer CUs than MI300X).
@@ -43,12 +43,23 @@
4343
"gfx1101": 60, # Radeon RX 7800 XT
4444
"gfx1102": 32, # Radeon RX 7600
4545
"gfx1103": 12, # Radeon 780M
46-
"gfx1151": 20, # Strix Halo / Radeon 8060S
46+
"gfx1151": 40, # Strix Halo / Radeon 8060S
4747
"gfx1201": 64, # Radeon RX 9070 XT / Radeon AI PRO R9700
4848
"gfx1250": 256, # Gfx1250
4949
}
5050

5151

52+
def torch_processor_count_to_cu(gfx: str, processor_count: int) -> int:
53+
"""Normalize PyTorch's Windows GPU count to physical compute units.
54+
55+
TheRock PyTorch reports RDNA ``multi_processor_count`` in work-group
56+
processors (WGPs), with two CUs per WGP. Other architectures already report
57+
the physical CU count used by rocminfo and AITER's tuning tables.
58+
"""
59+
count = int(processor_count)
60+
return count * 2 if gfx.lower().startswith(("gfx11", "gfx12")) else count
61+
62+
5263
def _parse_gpu_archs_env(gfx_env: str) -> list[str]:
5364
"""Split a GPU_ARCHS string into a list of non-empty architecture names.
5465

‎aiter/jit/utils/chip_info.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
_parse_gpu_archs_env,
1616
filter_tune_df,
1717
get_build_targets_env,
18+
torch_processor_count_to_cu,
1819
)
1920
except ImportError:
2021
# core.py also imports this module directly after adding utils/ to sys.path.
@@ -25,6 +26,7 @@
2526
_parse_gpu_archs_env,
2627
filter_tune_df,
2728
get_build_targets_env,
29+
torch_processor_count_to_cu,
2830
)
2931

3032
logger = logging.getLogger("aiter")
@@ -166,7 +168,9 @@ def get_cu_num_custom_op() -> int:
166168
if sys.platform == "win32":
167169
import torch
168170

169-
return int(torch.cuda.get_device_properties(0).multi_processor_count)
171+
props = torch.cuda.get_device_properties(0)
172+
gfx = props.gcnArchName.split(":", 1)[0]
173+
return torch_processor_count_to_cu(gfx, props.multi_processor_count)
170174
try:
171175
rocminfo = executable_path("rocminfo")
172176
result = subprocess.run(

‎aiter/jit/utils/cpp_extension.py‎

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -159,27 +159,28 @@ def _find_rocm_home() -> Optional[str]:
159159
# Guess #1
160160
rocm_home = os.environ.get("ROCM_HOME") or os.environ.get("ROCM_PATH")
161161
if rocm_home is None:
162-
# Guess #2: rocm-sdk-devel pip package ships a self-contained ROCm
163-
# tree under site-packages/_rocm_sdk_devel/. Prefer this over a
164-
# hipcc-on-PATH lookup because the venv's bin/hipcc is a python
165-
# wrapper, not a real binary — realpath() can't recover the SDK
166-
# root from it.
167-
try:
168-
spec = importlib.util.find_spec("_rocm_sdk_devel")
169-
except (ImportError, ValueError):
170-
spec = None
171-
if spec is not None and spec.submodule_search_locations:
162+
# Guess #2: TheRock split wheels install the runtime/toolchain under
163+
# _rocm_sdk_core, while older layouts may expose a self-contained tree
164+
# through _rocm_sdk_devel. Prefer the core runtime when both exist.
165+
# This must precede PATH lookup because wheel-provided hipcc is not
166+
# necessarily added to PATH.
167+
for package_name in ("_rocm_sdk_core", "_rocm_sdk_devel"):
168+
try:
169+
spec = importlib.util.find_spec(package_name)
170+
except (ImportError, ValueError):
171+
spec = None
172+
if spec is None or not spec.submodule_search_locations:
173+
continue
172174
candidate = spec.submodule_search_locations[0]
173175
hipconfig_names = (
174-
("hipconfig.exe", "hipconfig")
175-
if IS_WINDOWS
176-
else ("hipconfig",)
176+
("hipconfig.exe", "hipconfig") if IS_WINDOWS else ("hipconfig",)
177177
)
178178
if any(
179179
os.path.exists(os.path.join(candidate, "bin", name))
180180
for name in hipconfig_names
181181
) and os.path.exists(os.path.join(candidate, "lib")):
182182
rocm_home = candidate
183+
break
183184
if rocm_home is None:
184185
# Guess #3
185186
hipcc_path = shutil.which("hipcc")
@@ -406,6 +407,9 @@ def check_compiler_ok_for_platform(compiler: str) -> bool:
406407
True if the compiler is gcc/g++ on Linux or clang/clang++ on macOS,
407408
and always True for Windows.
408409
"""
410+
if IS_WINDOWS:
411+
return True
412+
409413
found_compiler = shutil.which(compiler)
410414
if not found_compiler:
411415
return False
@@ -479,26 +483,34 @@ def get_compiler_abi_compatibility_and_version(
479483
try:
480484
if IS_LINUX:
481485
minimum_required_version = MINIMUM_GCC_VERSION
482-
versionstr = subprocess.check_output(
486+
compiler_info = subprocess.check_output(
483487
[compiler, "-dumpfullversion", "-dumpversion"]
484488
)
485-
match = re.search(
486-
r"(\d+)\.(\d+)\.(\d+)",
487-
versionstr.decode(*SUBPROCESS_DECODE_ARGS).strip(),
489+
elif IS_WINDOWS:
490+
minimum_required_version = MINIMUM_MSVC_VERSION
491+
compiler_info = subprocess.check_output(
492+
compiler, stderr=subprocess.STDOUT
488493
)
489-
version = ["0", "0", "0"] if match is None else list(match.groups())
494+
else:
495+
return (True, Version("0.0.0"))
496+
match = re.search(
497+
r"(\d+)\.(\d+)\.(\d+)",
498+
compiler_info.decode(*SUBPROCESS_DECODE_ARGS).strip(),
499+
)
500+
version = ["0", "0", "0"] if match is None else list(match.groups())
490501
except Exception:
491502
_, error, _ = sys.exc_info()
492503
warnings.warn(f"Error checking compiler version for {compiler}: {error}")
493504
return (False, Version("0.0.0"))
494505

495-
if tuple(map(int, version)) >= minimum_required_version:
496-
return (True, Version(".".join(version)))
506+
numeric_version = [re.sub(r"\D", "", component) for component in version]
507+
if tuple(map(int, numeric_version)) >= minimum_required_version:
508+
return (True, Version(".".join(numeric_version)))
497509

498-
compiler = f'{compiler} {".".join(version)}'
510+
compiler = f'{compiler} {".".join(numeric_version)}'
499511
warnings.warn(ABI_INCOMPATIBILITY_WARNING.format(compiler))
500512

501-
return (False, Version(".".join(version)))
513+
return (False, Version(".".join(numeric_version)))
502514

503515

504516
class BuildExtension(build_ext):
@@ -1781,9 +1793,9 @@ def _write_ninja_file_to_build_library(
17811793
+ COMMON_HIP_FLAGS
17821794
+ COMMON_HIPCC_FLAGS
17831795
+ ["-std=c++20"]
1796+
+ extra_cuda_cflags
17841797
)
17851798
cuda_flags += _get_rocm_arch_flags(cuda_flags)
1786-
cuda_flags += extra_cuda_cflags
17871799
if IS_WINDOWS:
17881800
cuda_flags = _nt_quote_args(cuda_flags)
17891801

‎op_tests/test_windows_rdna_ck_targets.py‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
JIT_UTILS = os.path.join(REPO_ROOT, "aiter", "jit", "utils")
1212
sys.path.insert(0, JIT_UTILS)
1313

14-
from build_targets import get_build_targets_env # noqa: E402
14+
from build_targets import ( # noqa: E402
15+
get_build_targets_env,
16+
torch_processor_count_to_cu,
17+
)
1518
from blob_gen import windows_blob_gen_argv # noqa: E402
1619
from mha_recipes import _ck_targets_flag_for_arch # noqa: E402
1720

@@ -21,7 +24,7 @@
2124
"gfx1101": 60,
2225
"gfx1102": 32,
2326
"gfx1103": 12,
24-
"gfx1151": 20,
27+
"gfx1151": 40,
2528
"gfx1201": 64,
2629
}
2730

@@ -45,6 +48,21 @@ def test_cdna_keeps_ck_generator_defaults(self):
4548
self.assertEqual(_ck_targets_flag_for_arch("gfx942"), "")
4649
self.assertEqual(_ck_targets_flag_for_arch("gfx950"), "")
4750

51+
def test_torch_rdna_wgp_counts_are_normalized_to_physical_cus(self):
52+
for gfx, wgp_count, cu_count in (
53+
("gfx1101", 30, 60),
54+
("gfx1151", 20, 40),
55+
("gfx1201", 32, 64),
56+
):
57+
with self.subTest(gfx=gfx):
58+
self.assertEqual(
59+
torch_processor_count_to_cu(gfx, wgp_count), cu_count
60+
)
61+
62+
def test_torch_cdna_count_is_already_physical_cus(self):
63+
self.assertEqual(torch_processor_count_to_cu("gfx942", 304), 304)
64+
self.assertEqual(torch_processor_count_to_cu("gfx950", 256), 256)
65+
4866
def test_blob_generator_paths_with_spaces_are_single_arguments(self):
4967
argv = windows_blob_gen_argv(
5068
r"C:\Program Files\Python\python.exe",

0 commit comments

Comments
 (0)