Whether it is safe to spawn amd-smi here. On Windows w/o a working HIP runtime, amd-smi elevates a child and pops a UAC/DiskPart prompt RunAsInvoker can't suppress. Only call it on Windows with a HIP SDK (hipinfo present) or UNSLOTH_ENABLE_AMD_SMI=1; Linux/macOS always.
()
| 316 | |
| 317 | |
| 318 | def _amd_smi_allowed() -> bool: |
| 319 | """Whether it is safe to spawn amd-smi here. |
| 320 | |
| 321 | On Windows w/o a working HIP runtime, amd-smi elevates a child and pops a |
| 322 | UAC/DiskPart prompt RunAsInvoker can't suppress. Only call it on Windows with |
| 323 | a HIP SDK (hipinfo present) or UNSLOTH_ENABLE_AMD_SMI=1; Linux/macOS always. |
| 324 | """ |
| 325 | if platform.system() != "Windows": |
| 326 | return True |
| 327 | flag = os.environ.get("UNSLOTH_ENABLE_AMD_SMI", "").strip().lower() |
| 328 | if flag in ("1", "true", "yes", "on"): |
| 329 | return True |
| 330 | if flag in ("0", "false", "no", "off"): |
| 331 | return False |
| 332 | # A real HIP SDK lets amd-smi run un-elevated; hipinfo-on-PATH is the proxy. |
| 333 | # Ignore the venv hipInfo.exe (AMD wheel via bnb fix): not a HIP SDK, doesn't |
| 334 | # stop amd-smi's DiskPart UAC. |
| 335 | if _external_hipinfo_on_path(): |
| 336 | return True |
| 337 | for _var in ("HIP_PATH", "HIP_PATH_57", "ROCM_PATH"): |
| 338 | _root = os.environ.get(_var) |
| 339 | if not _root: |
| 340 | continue |
| 341 | _candidate = os.path.join(_root, "bin", "hipinfo.exe") |
| 342 | if os.path.isfile(_candidate) and not _path_inside_venv(_candidate): |
| 343 | return True |
| 344 | return False |
| 345 | |
| 346 | |
| 347 | def _detect_rocm_version() -> tuple[int, int] | None: |
no test coverage detected
searching dependent graphs…