"...crds/templates/nvidia.com_dynamocomponentdeployments.yaml" did not exist on "dabd226727b714c77e03ba1834eef22307259123"
check_hygon_env.py 2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python3

"""Validate the Hygon DCU Python environment."""

from __future__ import annotations

import sys
from importlib import metadata


EXACT_VERSIONS = {
    "numpy": "1.26.4",
}

DAS_VERSIONS = {
    "torch": "2.9.0",
    "triton": "3.3.0",
    "flash_attn": "2.6.1",
    "flash_mla": "1.2.0",
    "lightop": "0.6.0",
    "lmslim": "0.3.1",
}


def main() -> int:
    errors: list[str] = []

    print("Checking Hygon DCU Python environment...")

    for pkg_name, expected_version in EXACT_VERSIONS.items():
        try:
            installed_ver = metadata.version(pkg_name)
            print(f"  {pkg_name}: {installed_ver}")
        except metadata.PackageNotFoundError:
            errors.append(f"- Missing `{pkg_name}` (expected `{expected_version}`).")
            continue
        if installed_ver != expected_version:
            errors.append(
                f"- `{pkg_name}` mismatch: expected `{expected_version}`, "
                f"got `{installed_ver}`."
            )

    for pkg_name, expected_base in DAS_VERSIONS.items():
        try:
            installed_ver = metadata.version(pkg_name)
            print(f"  {pkg_name}: {installed_ver}")
        except metadata.PackageNotFoundError:
            errors.append(
                f"- Missing `{pkg_name}` (expected Hygon build based on "
                f"`{expected_base}`)."
            )
            continue
        if not installed_ver.startswith(expected_base):
            errors.append(
                f"- `{pkg_name}` mismatch: expected base `{expected_base}`, "
                f"got `{installed_ver}`."
            )
        if "+das" not in installed_ver:
            errors.append(
                f"- `{pkg_name}` is not a Hygon custom build: "
                f"`{installed_ver}`."
            )

    if errors:
        print("\nEnvironment check failed:")
        for error in errors:
            print(error)
        return 1

    print("\nEnvironment check passed.")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())