[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
657b3251f8
commit
d6f1075812
460 changed files with 13446 additions and 4512 deletions
|
|
@ -243,7 +243,11 @@ def _detect_rocm_version() -> tuple[int, int] | None:
|
|||
if result.returncode == 0:
|
||||
raw = result.stdout.decode().strip().split("\n")[0]
|
||||
parts = raw.split(".")
|
||||
if len(parts) >= 2 and parts[0].isdigit() and parts[1].split("-")[0].isdigit():
|
||||
if (
|
||||
len(parts) >= 2
|
||||
and parts[0].isdigit()
|
||||
and parts[1].split("-")[0].isdigit()
|
||||
):
|
||||
return int(parts[0]), int(parts[1].split("-")[0])
|
||||
except Exception:
|
||||
pass
|
||||
|
|
@ -359,7 +363,8 @@ def _detect_windows_gfx_arch() -> str | None:
|
|||
# findall gets every gcnArchName line so multi-GPU hosts are
|
||||
# enumerable and HIP_VISIBLE_DEVICES selects correctly.
|
||||
_tokens = [
|
||||
t.strip().lower() for t in re.findall(r"(?im)^\s*gcnArchName\s*:\s*(\S+)", text)
|
||||
t.strip().lower()
|
||||
for t in re.findall(r"(?im)^\s*gcnArchName\s*:\s*(\S+)", text)
|
||||
]
|
||||
_pick = _dedup_pick(_tokens)
|
||||
if _pick:
|
||||
|
|
@ -536,7 +541,9 @@ def _persist_bnb_rocm_version(version: str) -> bool:
|
|||
try:
|
||||
sitecustomize_path.parent.mkdir(parents = True, exist_ok = True)
|
||||
existing = (
|
||||
sitecustomize_path.read_text(encoding = "utf-8") if sitecustomize_path.exists() else ""
|
||||
sitecustomize_path.read_text(encoding = "utf-8")
|
||||
if sitecustomize_path.exists()
|
||||
else ""
|
||||
)
|
||||
# Strip all managed regions, including one whose END marker was lost to
|
||||
# an interrupted write, then append exactly one fresh block.
|
||||
|
|
@ -779,7 +786,8 @@ def _install_bnb_windows_rocm() -> bool:
|
|||
# Fall back to "72" if detection fails (e.g. install was a no-op / dry-run).
|
||||
_env_ver = os.environ.get("BNB_ROCM_VERSION")
|
||||
_env_is_persisted_default = (
|
||||
os.environ.get(_BNB_ROCM_VERSION_SOURCE_ENV) == _BNB_ROCM_VERSION_SOURCE_SITECUSTOMIZE
|
||||
os.environ.get(_BNB_ROCM_VERSION_SOURCE_ENV)
|
||||
== _BNB_ROCM_VERSION_SOURCE_SITECUSTOMIZE
|
||||
)
|
||||
_persist_detected_version = False
|
||||
if _env_ver and not _env_is_persisted_default:
|
||||
|
|
@ -913,7 +921,9 @@ def _ensure_cuda_torch() -> None:
|
|||
# Take the last non-empty stdout line: stray output from sitecustomize or
|
||||
# an import hook must not mask the marker (fail-closed either way).
|
||||
_marker_lines = [
|
||||
line.strip() for line in probe.stdout.decode(errors = "replace").splitlines() if line.strip()
|
||||
line.strip()
|
||||
for line in probe.stdout.decode(errors = "replace").splitlines()
|
||||
if line.strip()
|
||||
]
|
||||
if not _marker_lines or _marker_lines[-1] != "hip":
|
||||
return # healthy CUDA torch, or a deliberate CPU wheel -- leave as-is
|
||||
|
|
@ -1022,7 +1032,9 @@ def _ensure_rocm_torch() -> None:
|
|||
if not _torch_already_rocm:
|
||||
index_url = _windows_rocm_index_url(gfx_arch)
|
||||
if index_url is None:
|
||||
print(f" No AMD Windows torch index for GPU arch {gfx_arch} -- skipping")
|
||||
print(
|
||||
f" No AMD Windows torch index for GPU arch {gfx_arch} -- skipping"
|
||||
)
|
||||
return
|
||||
print(f" {gfx_arch} (Windows) -- installing torch from {index_url}")
|
||||
pip_install(
|
||||
|
|
@ -1095,7 +1107,9 @@ def _ensure_rocm_torch() -> None:
|
|||
except (OSError, subprocess.TimeoutExpired):
|
||||
probe = None
|
||||
has_hip_torch = (
|
||||
probe is not None and probe.returncode == 0 and probe.stdout.decode().strip() != ""
|
||||
probe is not None
|
||||
and probe.returncode == 0
|
||||
and probe.stdout.decode().strip() != ""
|
||||
)
|
||||
|
||||
rocm_torch_ready = has_hip_torch
|
||||
|
|
@ -1117,11 +1131,14 @@ def _ensure_rocm_torch() -> None:
|
|||
# Pick the runtime-visible GPU: use the HIP_VISIBLE_DEVICES index
|
||||
# into gfx_codes, else default to the first GPU. Skip the override
|
||||
# unless the resolved GPU is Strix.
|
||||
_runtime_gfx = gfx_codes[_pick_visible_index(len(gfx_codes))] if gfx_codes else None
|
||||
_runtime_gfx = (
|
||||
gfx_codes[_pick_visible_index(len(gfx_codes))] if gfx_codes else None
|
||||
)
|
||||
if _runtime_gfx in _strix_gfx:
|
||||
_selected_gfx = _runtime_gfx
|
||||
_amd_mirror = (
|
||||
os.environ.get("UNSLOTH_AMD_ROCM_MIRROR") or "https://repo.amd.com/rocm/whl"
|
||||
os.environ.get("UNSLOTH_AMD_ROCM_MIRROR")
|
||||
or "https://repo.amd.com/rocm/whl"
|
||||
).rstrip("/")
|
||||
_strix_override_url = f"{_amd_mirror}/{_selected_gfx}/"
|
||||
_strix_override_pkgs = (
|
||||
|
|
@ -1182,7 +1199,10 @@ def _ensure_rocm_torch() -> None:
|
|||
None,
|
||||
)
|
||||
if tag is None:
|
||||
print(f" No PyTorch wheel for ROCm {ver[0]}.{ver[1]} -- " f"skipping torch reinstall")
|
||||
print(
|
||||
f" No PyTorch wheel for ROCm {ver[0]}.{ver[1]} -- "
|
||||
f"skipping torch reinstall"
|
||||
)
|
||||
else:
|
||||
index_url = f"{_PYTORCH_WHL_BASE}/{tag}"
|
||||
print(f" ROCm {ver[0]}.{ver[1]} -- installing torch from {index_url}")
|
||||
|
|
@ -1340,7 +1360,9 @@ CONSTRAINTS = SINGLE_ENV / "constraints.txt"
|
|||
LOCAL_DD_UNSTRUCTURED_PLUGIN = (
|
||||
SCRIPT_DIR / "backend" / "plugins" / "data-designer-unstructured-seed"
|
||||
)
|
||||
LOCAL_DD_GITHUB_PLUGIN = SCRIPT_DIR / "backend" / "plugins" / "data-designer-github-repo-seed"
|
||||
LOCAL_DD_GITHUB_PLUGIN = (
|
||||
SCRIPT_DIR / "backend" / "plugins" / "data-designer-github-repo-seed"
|
||||
)
|
||||
|
||||
# Apple Silicon: override mlx-vlm/mlx-lm's transformers pin (see overrides).
|
||||
_MLX_OVERRIDES = SINGLE_ENV / "overrides-darwin-arm64.txt"
|
||||
|
|
@ -1465,7 +1487,9 @@ def _progress(label: str) -> None:
|
|||
pad = " " * (_COL - len(_LABEL))
|
||||
end = "\n" if _STEP >= _TOTAL else ""
|
||||
try:
|
||||
sys.stdout.write(f"\r {_dim(_LABEL)}{pad}[{bar}] {_STEP:2}/{_TOTAL} {label:<20}{end}")
|
||||
sys.stdout.write(
|
||||
f"\r {_dim(_LABEL)}{pad}[{bar}] {_STEP:2}/{_TOTAL} {label:<20}{end}"
|
||||
)
|
||||
sys.stdout.flush()
|
||||
except OSError:
|
||||
pass
|
||||
|
|
@ -1525,7 +1549,9 @@ def _build_flash_attn_wheel_url(env: dict[str, str]) -> str | None:
|
|||
return flash_attn_wheel_url(env)
|
||||
|
||||
|
||||
def _print_optional_install_failure(label: str, result: subprocess.CompletedProcess[str]) -> None:
|
||||
def _print_optional_install_failure(
|
||||
label: str, result: subprocess.CompletedProcess[str]
|
||||
) -> None:
|
||||
_step("warning", f"{label} failed (exit code {result.returncode})", _cyan)
|
||||
if result.stdout:
|
||||
print(result.stdout.strip())
|
||||
|
|
@ -1620,7 +1646,9 @@ def _filter_requirements(req: Path, skip: set[str]) -> Path:
|
|||
"""Return a temp copy of a requirements file with certain packages removed."""
|
||||
lines = req.read_text(encoding = "utf-8").splitlines(keepends = True)
|
||||
filtered = [
|
||||
line for line in lines if not any(line.strip().lower().startswith(pkg) for pkg in skip)
|
||||
line
|
||||
for line in lines
|
||||
if not any(line.strip().lower().startswith(pkg) for pkg in skip)
|
||||
]
|
||||
tmp = tempfile.NamedTemporaryFile(
|
||||
mode = "w",
|
||||
|
|
@ -1830,7 +1858,9 @@ def install_python_stack() -> int:
|
|||
if not IS_MACOS and not NO_TORCH:
|
||||
base_total += 1 # ROCm torch check (line 1526) -- all non-macOS platforms
|
||||
if not IS_WINDOWS:
|
||||
base_total += 2 # flash-attn (line 1620) + ROCm torch final (line 1705) -- Linux only
|
||||
base_total += (
|
||||
2 # flash-attn (line 1620) + ROCm torch final (line 1705) -- Linux only
|
||||
)
|
||||
_TOTAL = (base_total - 1) if skip_base else base_total
|
||||
|
||||
# 1. Try uv for faster installs (before pip upgrade -- uv venvs don't
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue