kernelvet 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kernelvet/__init__.py +10 -0
- kernelvet/__main__.py +3 -0
- kernelvet/benchmark/__init__.py +1 -0
- kernelvet/benchmark/engine.py +180 -0
- kernelvet/benchmark/workloads.py +153 -0
- kernelvet/cli/__init__.py +1 -0
- kernelvet/cli/app.py +64 -0
- kernelvet/cli/commands/__init__.py +1 -0
- kernelvet/cli/commands/diagnose.py +244 -0
- kernelvet/cli/commands/migrate.py +334 -0
- kernelvet/cli/commands/misc.py +216 -0
- kernelvet/cli/output.py +110 -0
- kernelvet/compatibility/__init__.py +1 -0
- kernelvet/compatibility/data/rocm_matrix.json +123 -0
- kernelvet/compatibility/engine.py +24 -0
- kernelvet/compatibility/matrix.py +128 -0
- kernelvet/compatibility/validators.py +405 -0
- kernelvet/config/__init__.py +10 -0
- kernelvet/config/settings.py +112 -0
- kernelvet/diagnose/__init__.py +1 -0
- kernelvet/diagnose/engine.py +296 -0
- kernelvet/diagnose/hardware.py +336 -0
- kernelvet/diagnose/runtime.py +332 -0
- kernelvet/diagnose/software.py +221 -0
- kernelvet/diagnose/system.py +67 -0
- kernelvet/execution/__init__.py +1 -0
- kernelvet/execution/compiler.py +275 -0
- kernelvet/execution/runner.py +125 -0
- kernelvet/execution/sandbox.py +51 -0
- kernelvet/history/__init__.py +3 -0
- kernelvet/history/store.py +157 -0
- kernelvet/main.py +19 -0
- kernelvet/migration/__init__.py +17 -0
- kernelvet/migration/analyzer.py +78 -0
- kernelvet/migration/auditor.py +89 -0
- kernelvet/migration/hipify.py +268 -0
- kernelvet/migration/planner.py +128 -0
- kernelvet/migration/rules.py +564 -0
- kernelvet/migration/scanner.py +234 -0
- kernelvet/migration/workflow.py +135 -0
- kernelvet/models/__init__.py +35 -0
- kernelvet/models/common.py +102 -0
- kernelvet/models/migration.py +236 -0
- kernelvet/models/report.py +126 -0
- kernelvet/models/system.py +89 -0
- kernelvet/reporting/__init__.py +80 -0
- kernelvet/reporting/common.py +74 -0
- kernelvet/reporting/html.py +149 -0
- kernelvet/reporting/json.py +20 -0
- kernelvet/reporting/loader.py +48 -0
- kernelvet/reporting/markdown.py +256 -0
- kernelvet/reporting/sarif.py +79 -0
- kernelvet/reporting/terminal.py +276 -0
- kernelvet/tui/__init__.py +1 -0
- kernelvet/tui/app.py +177 -0
- kernelvet/tui/screens/__init__.py +1 -0
- kernelvet/tui/screens/base.py +34 -0
- kernelvet/tui/screens/devices.py +211 -0
- kernelvet/tui/screens/diagnose.py +212 -0
- kernelvet/tui/screens/help.py +47 -0
- kernelvet/tui/screens/migration.py +573 -0
- kernelvet/tui/screens/overview.py +195 -0
- kernelvet/tui/screens/tools.py +357 -0
- kernelvet/tui/state.py +55 -0
- kernelvet/tui/widgets/__init__.py +1 -0
- kernelvet/tui/widgets/common.py +82 -0
- kernelvet/tui/workers/__init__.py +25 -0
- kernelvet/utils/__init__.py +1 -0
- kernelvet/utils/paths.py +48 -0
- kernelvet/utils/proc.py +178 -0
- kernelvet/utils/redact.py +47 -0
- kernelvet/utils/versions.py +34 -0
- kernelvet-0.1.0.dist-info/METADATA +275 -0
- kernelvet-0.1.0.dist-info/RECORD +77 -0
- kernelvet-0.1.0.dist-info/WHEEL +4 -0
- kernelvet-0.1.0.dist-info/entry_points.txt +2 -0
- kernelvet-0.1.0.dist-info/licenses/LICENSE +197 -0
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
"""Individual compatibility validators.
|
|
2
|
+
|
|
3
|
+
Each validator returns one :class:`CheckResult`. The rules:
|
|
4
|
+
|
|
5
|
+
* PASS only when the detected value is explicitly listed in the matrix;
|
|
6
|
+
* FAIL only for a known incompatibility (explicitly unsupported GPU, wrong OS
|
|
7
|
+
family, missing kernel driver on a GPU host);
|
|
8
|
+
* WARNING when the value is not listed or the data is ambiguous;
|
|
9
|
+
* SKIPPED when the input could not be detected.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
from dataclasses import dataclass
|
|
15
|
+
|
|
16
|
+
from kernelvet.compatibility.matrix import CompatibilityMatrix, GpuClass, OsEntry
|
|
17
|
+
from kernelvet.models.common import CheckResult, CheckStatus, Evidence
|
|
18
|
+
from kernelvet.models.system import GpuDevice, HostInfo, SoftwareInfo
|
|
19
|
+
from kernelvet.utils.versions import major_minor, parse_version, same_release
|
|
20
|
+
|
|
21
|
+
_RANK = {CheckStatus.PASS: 0, CheckStatus.SKIPPED: 1, CheckStatus.WARNING: 2, CheckStatus.FAIL: 3}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass
|
|
25
|
+
class CompatibilityInput:
|
|
26
|
+
host: HostInfo
|
|
27
|
+
gpus: list[GpuDevice]
|
|
28
|
+
software: SoftwareInfo
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def amd_gpus(self) -> list[GpuDevice]:
|
|
32
|
+
return [g for g in self.gpus if g.vendor_is_amd]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _check(
|
|
36
|
+
cid: str,
|
|
37
|
+
name: str,
|
|
38
|
+
status: CheckStatus,
|
|
39
|
+
summary: str,
|
|
40
|
+
*,
|
|
41
|
+
detail: str = "",
|
|
42
|
+
remediation: str | None = None,
|
|
43
|
+
source: str | None = None,
|
|
44
|
+
) -> CheckResult:
|
|
45
|
+
return CheckResult(
|
|
46
|
+
id=cid,
|
|
47
|
+
name=name,
|
|
48
|
+
category="compatibility",
|
|
49
|
+
status=status,
|
|
50
|
+
evidence=Evidence.CONFIGURED,
|
|
51
|
+
summary=summary,
|
|
52
|
+
detail=detail,
|
|
53
|
+
remediation=remediation,
|
|
54
|
+
source=source,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def gpu_classes(inp: CompatibilityInput, m: CompatibilityMatrix) -> set[GpuClass]:
|
|
59
|
+
return {c for g in inp.amd_gpus if (c := m.class_for_gfx(g.gfx_target)) is not None}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# --------------------------------------------------------------------------- GPU
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def validate_gpu(inp: CompatibilityInput, m: CompatibilityMatrix) -> CheckResult:
|
|
66
|
+
cid, name = "compat.gpu", "GPU Architecture Support"
|
|
67
|
+
gpus = inp.amd_gpus
|
|
68
|
+
if not gpus:
|
|
69
|
+
return _check(cid, name, CheckStatus.SKIPPED, "No AMD GPU detected, nothing to validate")
|
|
70
|
+
lines: list[str] = []
|
|
71
|
+
worst = CheckStatus.PASS
|
|
72
|
+
remediation = None
|
|
73
|
+
for g in gpus:
|
|
74
|
+
label = g.marketing_name or f"GPU {g.index}"
|
|
75
|
+
gfx = (g.gfx_target or "").split(":")[0]
|
|
76
|
+
if not gfx:
|
|
77
|
+
status, why = CheckStatus.WARNING, "architecture (gfx target) could not be detected"
|
|
78
|
+
elif entries := m.entries_for_gfx(gfx):
|
|
79
|
+
statuses = {e.status for e in entries}
|
|
80
|
+
names = ", ".join(e.name for e in entries)
|
|
81
|
+
if statuses == {"unsupported"}:
|
|
82
|
+
status, why = CheckStatus.FAIL, f"{gfx} is listed as unsupported ({names})"
|
|
83
|
+
remediation = "This GPU architecture is not supported by current ROCm releases"
|
|
84
|
+
elif "deprecated" in statuses and "supported" not in statuses:
|
|
85
|
+
status, why = CheckStatus.WARNING, f"{gfx} is listed as deprecated ({names})"
|
|
86
|
+
else:
|
|
87
|
+
status, why = CheckStatus.PASS, f"{gfx} is listed as supported ({entries[0].arch}: {names})"
|
|
88
|
+
elif gfx in m.targets_uncertain:
|
|
89
|
+
status, why = CheckStatus.WARNING, f"{gfx}: {m.targets_uncertain[gfx]}"
|
|
90
|
+
else:
|
|
91
|
+
status = CheckStatus.WARNING
|
|
92
|
+
why = f"{gfx} is not listed; AMD states unlisted GPUs are not officially supported"
|
|
93
|
+
lines.append(f"{label}: {why}")
|
|
94
|
+
if _RANK[status] > _RANK[worst]:
|
|
95
|
+
worst = status
|
|
96
|
+
return _check(
|
|
97
|
+
cid,
|
|
98
|
+
name,
|
|
99
|
+
worst,
|
|
100
|
+
lines[0] if len(lines) == 1 else f"{len(gpus)} GPUs checked",
|
|
101
|
+
detail="\n".join(lines),
|
|
102
|
+
remediation=remediation,
|
|
103
|
+
source=m.source_url("sysreq+matrix"),
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
# --------------------------------------------------------------------------- OS
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def _os_key(host: HostInfo) -> tuple[str | None, str | None]:
|
|
111
|
+
os_id = (host.os_id or "").lower() or None
|
|
112
|
+
ver = host.os_version
|
|
113
|
+
if os_id in ("rocky", "ol", "debian") and ver:
|
|
114
|
+
ver = ver.split(".")[0]
|
|
115
|
+
elif os_id in ("sles", "sled", "opensuse-leap") and ver:
|
|
116
|
+
os_id = "sles"
|
|
117
|
+
return os_id, ver
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def match_os(
|
|
121
|
+
host: HostInfo, m: CompatibilityMatrix, classes: set[GpuClass]
|
|
122
|
+
) -> list[tuple[GpuClass, OsEntry]]:
|
|
123
|
+
os_id, ver = _os_key(host)
|
|
124
|
+
if not os_id or not ver:
|
|
125
|
+
return []
|
|
126
|
+
out = []
|
|
127
|
+
for cls in classes or {"instinct", "radeon"}:
|
|
128
|
+
for e in m.os.get(cls, []):
|
|
129
|
+
if e.id == os_id and (e.version == ver or e.version == major_minor(ver)):
|
|
130
|
+
out.append((cls, e))
|
|
131
|
+
return out
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def validate_os(inp: CompatibilityInput, m: CompatibilityMatrix) -> CheckResult:
|
|
135
|
+
cid, name = "compat.os", "Operating System Support"
|
|
136
|
+
host = inp.host
|
|
137
|
+
src = m.source_url("sysreq+matrix")
|
|
138
|
+
if host.os_name == "macOS" or (host.os_id is None and host.os_name == "Darwin"):
|
|
139
|
+
return _check(
|
|
140
|
+
cid,
|
|
141
|
+
name,
|
|
142
|
+
CheckStatus.FAIL,
|
|
143
|
+
"ROCm is not available on macOS",
|
|
144
|
+
remediation="Run ROCm workloads on a supported Linux distribution",
|
|
145
|
+
source=src,
|
|
146
|
+
)
|
|
147
|
+
if host.os_name == "Windows":
|
|
148
|
+
return _check(
|
|
149
|
+
cid,
|
|
150
|
+
name,
|
|
151
|
+
CheckStatus.WARNING,
|
|
152
|
+
"Windows detected; this matrix snapshot covers Linux ROCm only",
|
|
153
|
+
detail="The 10.1.0 matrix lists Windows 11 25H2 for Radeon and Ryzen APUs via the HIP SDK; "
|
|
154
|
+
"KernelVet does not validate Windows configurations.",
|
|
155
|
+
source=src,
|
|
156
|
+
)
|
|
157
|
+
classes = gpu_classes(inp, m)
|
|
158
|
+
matches = match_os(host, m, classes)
|
|
159
|
+
pretty = host.os_pretty or f"{host.os_id} {host.os_version}"
|
|
160
|
+
if not matches:
|
|
161
|
+
listed = sorted({e.label for c in (classes or {"instinct", "radeon"}) for e in m.os.get(c, [])})
|
|
162
|
+
return _check(
|
|
163
|
+
cid,
|
|
164
|
+
name,
|
|
165
|
+
CheckStatus.WARNING,
|
|
166
|
+
f"{pretty} is not in the supported OS list",
|
|
167
|
+
detail="Listed: " + "; ".join(listed),
|
|
168
|
+
remediation="Use a distribution listed in AMD's ROCm system requirements",
|
|
169
|
+
source=src,
|
|
170
|
+
)
|
|
171
|
+
# GPU-specific OS restrictions
|
|
172
|
+
os_id, ver = _os_key(host)
|
|
173
|
+
for r in m.os_gpu_restrictions:
|
|
174
|
+
r_id, _, r_ver = r.os.partition(":")
|
|
175
|
+
if r_id == os_id and (r_ver == ver or r_ver == major_minor(ver)):
|
|
176
|
+
bad = [g for g in inp.amd_gpus if (g.gfx_target or "").split(":")[0] not in r.gfx]
|
|
177
|
+
if bad:
|
|
178
|
+
return _check(
|
|
179
|
+
cid,
|
|
180
|
+
name,
|
|
181
|
+
CheckStatus.WARNING,
|
|
182
|
+
f"{pretty} is restricted to specific GPUs",
|
|
183
|
+
detail=r.note,
|
|
184
|
+
remediation="Use an OS listed for your GPU",
|
|
185
|
+
source=m.source_url(r.source),
|
|
186
|
+
)
|
|
187
|
+
labels = ", ".join(sorted({f"{e.label} ({c})" for c, e in matches}))
|
|
188
|
+
note = "" if classes else " (no AMD GPU detected, so the GPU-specific OS list was not applied)"
|
|
189
|
+
return _check(cid, name, CheckStatus.PASS, f"{pretty} is listed{note}", detail=labels, source=src)
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def validate_kernel(inp: CompatibilityInput, m: CompatibilityMatrix) -> CheckResult:
|
|
193
|
+
cid, name = "compat.kernel", "Kernel Compatibility"
|
|
194
|
+
host = inp.host
|
|
195
|
+
if host.os_name in ("macOS", "Windows", "Darwin"):
|
|
196
|
+
return _check(cid, name, CheckStatus.SKIPPED, "Not a Linux host")
|
|
197
|
+
kernel_mm = major_minor(host.kernel)
|
|
198
|
+
if not kernel_mm:
|
|
199
|
+
return _check(cid, name, CheckStatus.SKIPPED, "Kernel version could not be detected")
|
|
200
|
+
matches = match_os(host, m, gpu_classes(inp, m))
|
|
201
|
+
if not matches:
|
|
202
|
+
return _check(cid, name, CheckStatus.SKIPPED, "OS not in the matrix, so no kernel list applies")
|
|
203
|
+
kernels = sorted({k for _, e in matches for k in e.kernels})
|
|
204
|
+
if not kernels:
|
|
205
|
+
return _check(
|
|
206
|
+
cid,
|
|
207
|
+
name,
|
|
208
|
+
CheckStatus.WARNING,
|
|
209
|
+
f"Kernel {host.kernel}: the matrix lists no explicit "
|
|
210
|
+
"kernel version for this OS (e.g. Oracle UEK)",
|
|
211
|
+
source=m.source_url("matrix"),
|
|
212
|
+
)
|
|
213
|
+
if kernel_mm in kernels:
|
|
214
|
+
return _check(
|
|
215
|
+
cid,
|
|
216
|
+
name,
|
|
217
|
+
CheckStatus.PASS,
|
|
218
|
+
f"Kernel {host.kernel} matches listed {kernel_mm}",
|
|
219
|
+
source=m.source_url("sysreq+matrix"),
|
|
220
|
+
)
|
|
221
|
+
return _check(
|
|
222
|
+
cid,
|
|
223
|
+
name,
|
|
224
|
+
CheckStatus.WARNING,
|
|
225
|
+
f"Kernel {host.kernel} is not one of the listed kernels",
|
|
226
|
+
detail="Listed: " + ", ".join(kernels),
|
|
227
|
+
remediation="Use the GA or HWE kernel listed for your distribution",
|
|
228
|
+
source=m.source_url("sysreq+matrix"),
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
# --------------------------------------------------------------------------- ROCm / driver / HIP
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def validate_rocm(inp: CompatibilityInput, m: CompatibilityMatrix) -> CheckResult:
|
|
236
|
+
cid, name = "compat.rocm", "ROCm Version"
|
|
237
|
+
ver = inp.software.rocm_version
|
|
238
|
+
if not ver:
|
|
239
|
+
return _check(
|
|
240
|
+
cid,
|
|
241
|
+
name,
|
|
242
|
+
CheckStatus.SKIPPED,
|
|
243
|
+
"ROCm installation not detected",
|
|
244
|
+
remediation="Install ROCm: https://rocm.docs.amd.com/projects/install-on-linux/en/latest/",
|
|
245
|
+
)
|
|
246
|
+
if same_release(ver, m.rocm_version, depth=3) or same_release(ver, m.rocm_version, depth=2):
|
|
247
|
+
return _check(
|
|
248
|
+
cid,
|
|
249
|
+
name,
|
|
250
|
+
CheckStatus.PASS,
|
|
251
|
+
f"ROCm {ver} matches the matrix snapshot ({m.rocm_version})",
|
|
252
|
+
source=m.source_url("matrix"),
|
|
253
|
+
)
|
|
254
|
+
pv, pm = parse_version(ver), parse_version(m.rocm_version)
|
|
255
|
+
newer = pv is not None and pm is not None and pv > pm
|
|
256
|
+
listed = any(same_release(ver, r, depth=2) for r in m.release_versions)
|
|
257
|
+
if newer:
|
|
258
|
+
why = f"ROCm {ver} is newer than this matrix snapshot ({m.rocm_version}); update KernelVet's matrix"
|
|
259
|
+
elif listed:
|
|
260
|
+
why = (
|
|
261
|
+
f"ROCm {ver} is a known release, but this snapshot's tables describe {m.rocm_version}; "
|
|
262
|
+
"GPU/OS results may not apply"
|
|
263
|
+
)
|
|
264
|
+
else:
|
|
265
|
+
why = f"ROCm {ver} is not covered by this matrix snapshot ({m.rocm_version})"
|
|
266
|
+
return _check(
|
|
267
|
+
cid,
|
|
268
|
+
name,
|
|
269
|
+
CheckStatus.WARNING,
|
|
270
|
+
why,
|
|
271
|
+
remediation=f"Check the compatibility matrix for ROCm {major_minor(ver)} in AMD's docs",
|
|
272
|
+
source=m.source_url("releases"),
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
def validate_driver(inp: CompatibilityInput, m: CompatibilityMatrix) -> CheckResult:
|
|
277
|
+
cid, name = "compat.driver", "AMDGPU Driver"
|
|
278
|
+
sw = inp.software
|
|
279
|
+
if inp.host.os_name in ("macOS", "Windows", "Darwin"):
|
|
280
|
+
return _check(cid, name, CheckStatus.SKIPPED, "Not a Linux host")
|
|
281
|
+
if not inp.amd_gpus:
|
|
282
|
+
return _check(cid, name, CheckStatus.SKIPPED, "No AMD GPU detected")
|
|
283
|
+
if sw.amdgpu_module_loaded is False:
|
|
284
|
+
return _check(
|
|
285
|
+
cid,
|
|
286
|
+
name,
|
|
287
|
+
CheckStatus.FAIL,
|
|
288
|
+
"amdgpu kernel module is not loaded",
|
|
289
|
+
remediation="Install the amdgpu driver (amdgpu-dkms) and reboot, or `sudo modprobe amdgpu`",
|
|
290
|
+
)
|
|
291
|
+
ver = sw.amdgpu_driver_version
|
|
292
|
+
classes = gpu_classes(inp, m)
|
|
293
|
+
if not ver:
|
|
294
|
+
return _check(
|
|
295
|
+
cid,
|
|
296
|
+
name,
|
|
297
|
+
CheckStatus.WARNING,
|
|
298
|
+
"amdgpu is loaded but reports no version (likely the distribution's inbox driver)",
|
|
299
|
+
detail="The matrix lists specific amdgpu versions for Instinct and Radeon; "
|
|
300
|
+
"Ryzen APUs use the inbox driver.",
|
|
301
|
+
source=m.source_url("matrix"),
|
|
302
|
+
)
|
|
303
|
+
listed: set[str] = set()
|
|
304
|
+
for c in classes or {"instinct", "radeon"}:
|
|
305
|
+
listed.update(getattr(m.amdgpu_driver, c))
|
|
306
|
+
if any(same_release(ver, v, depth=3) for v in listed):
|
|
307
|
+
return _check(cid, name, CheckStatus.PASS, f"amdgpu {ver} is listed", source=m.source_url("matrix"))
|
|
308
|
+
return _check(
|
|
309
|
+
cid,
|
|
310
|
+
name,
|
|
311
|
+
CheckStatus.WARNING,
|
|
312
|
+
f"amdgpu {ver} is not in the listed driver versions",
|
|
313
|
+
detail="Listed: "
|
|
314
|
+
+ ", ".join(sorted(listed))
|
|
315
|
+
+ "\nThe kernel module may report a different version scheme than the matrix.",
|
|
316
|
+
source=m.source_url("matrix"),
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def validate_hip(inp: CompatibilityInput, m: CompatibilityMatrix) -> CheckResult:
|
|
321
|
+
cid, name = "compat.hip", "HIP Compatibility"
|
|
322
|
+
sw = inp.software
|
|
323
|
+
if not sw.has("hipcc") and not sw.hip_runtime_version:
|
|
324
|
+
return _check(cid, name, CheckStatus.SKIPPED, "HIP toolchain not detected")
|
|
325
|
+
if not sw.hip_runtime_version:
|
|
326
|
+
return _check(cid, name, CheckStatus.WARNING, "hipcc found but the HIP version could not be read")
|
|
327
|
+
if sw.rocm_version and not same_release(sw.hip_runtime_version, sw.rocm_version):
|
|
328
|
+
return _check(
|
|
329
|
+
cid,
|
|
330
|
+
name,
|
|
331
|
+
CheckStatus.WARNING,
|
|
332
|
+
f"HIP {sw.hip_runtime_version} does not match ROCm {sw.rocm_version}",
|
|
333
|
+
remediation="Mixed ROCm installs detected; check PATH and ROCM_PATH point at one release",
|
|
334
|
+
)
|
|
335
|
+
return _check(
|
|
336
|
+
cid, name, CheckStatus.PASS, f"HIP {sw.hip_runtime_version} is consistent with the ROCm install"
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
# --------------------------------------------------------------------------- frameworks
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
def validate_pytorch(inp: CompatibilityInput, m: CompatibilityMatrix) -> CheckResult:
|
|
344
|
+
cid, name = "compat.pytorch", "PyTorch Compatibility"
|
|
345
|
+
t = inp.software.torch
|
|
346
|
+
fw = m.frameworks.get("pytorch")
|
|
347
|
+
if t is None:
|
|
348
|
+
return _check(cid, name, CheckStatus.SKIPPED, "PyTorch check disabled")
|
|
349
|
+
if not t.installed:
|
|
350
|
+
return _check(cid, name, CheckStatus.SKIPPED, "PyTorch not installed in the checked interpreter")
|
|
351
|
+
if not t.is_rocm_build:
|
|
352
|
+
build = f"CUDA {t.cuda_version}" if t.cuda_version else "CPU-only"
|
|
353
|
+
return _check(
|
|
354
|
+
cid,
|
|
355
|
+
name,
|
|
356
|
+
CheckStatus.WARNING,
|
|
357
|
+
f"PyTorch {t.version} is a {build} build, not ROCm",
|
|
358
|
+
remediation="Install a ROCm build of PyTorch (https://pytorch.org/get-started/locally/)",
|
|
359
|
+
)
|
|
360
|
+
if fw is None:
|
|
361
|
+
return _check(cid, name, CheckStatus.SKIPPED, "Matrix has no PyTorch data")
|
|
362
|
+
tmm = major_minor(t.version)
|
|
363
|
+
src = m.source_url(fw.source)
|
|
364
|
+
if tmm not in fw.versions:
|
|
365
|
+
return _check(
|
|
366
|
+
cid,
|
|
367
|
+
name,
|
|
368
|
+
CheckStatus.WARNING,
|
|
369
|
+
f"PyTorch {t.version} is not listed for ROCm {m.rocm_version}",
|
|
370
|
+
detail="Listed: " + ", ".join(fw.versions),
|
|
371
|
+
source=src,
|
|
372
|
+
)
|
|
373
|
+
sys_rocm = inp.software.rocm_version
|
|
374
|
+
if sys_rocm and not same_release(t.hip_version, sys_rocm):
|
|
375
|
+
return _check(
|
|
376
|
+
cid,
|
|
377
|
+
name,
|
|
378
|
+
CheckStatus.WARNING,
|
|
379
|
+
f"PyTorch {t.version} was built for HIP {t.hip_version}; system ROCm is {sys_rocm}",
|
|
380
|
+
detail="Wheels bundle their own ROCm runtime libraries, but the kernel driver must "
|
|
381
|
+
"still support them.",
|
|
382
|
+
source=src,
|
|
383
|
+
)
|
|
384
|
+
if sys_rocm and not same_release(sys_rocm, m.rocm_version):
|
|
385
|
+
return _check(
|
|
386
|
+
cid,
|
|
387
|
+
name,
|
|
388
|
+
CheckStatus.WARNING,
|
|
389
|
+
f"PyTorch {tmm} is listed for ROCm {m.rocm_version}, but this host runs ROCm {sys_rocm}",
|
|
390
|
+
source=src,
|
|
391
|
+
)
|
|
392
|
+
return _check(
|
|
393
|
+
cid, name, CheckStatus.PASS, f"PyTorch {t.version} (HIP {t.hip_version}) is listed", source=src
|
|
394
|
+
)
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
VALIDATORS = [
|
|
398
|
+
validate_gpu,
|
|
399
|
+
validate_os,
|
|
400
|
+
validate_kernel,
|
|
401
|
+
validate_rocm,
|
|
402
|
+
validate_driver,
|
|
403
|
+
validate_hip,
|
|
404
|
+
validate_pytorch,
|
|
405
|
+
]
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""User configuration (``~/.config/kernelvet/config.toml``).
|
|
2
|
+
|
|
3
|
+
Precedence: built-in defaults < config file < ``KERNELVET_*`` environment
|
|
4
|
+
variables < command-line flags.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import tomllib
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Any, Literal
|
|
13
|
+
|
|
14
|
+
from pydantic import BaseModel, Field, ValidationError
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _xdg(var: str, fallback: str) -> Path:
|
|
18
|
+
base = os.environ.get(var)
|
|
19
|
+
return Path(base) if base else Path.home() / fallback
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def config_dir() -> Path:
|
|
23
|
+
return Path(os.environ.get("KERNELVET_CONFIG_DIR") or _xdg("XDG_CONFIG_HOME", ".config") / "kernelvet")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def data_dir() -> Path:
|
|
27
|
+
return Path(os.environ.get("KERNELVET_DATA_DIR") or _xdg("XDG_DATA_HOME", ".local/share") / "kernelvet")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def config_path() -> Path:
|
|
31
|
+
return config_dir() / "config.toml"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class Settings(BaseModel):
|
|
35
|
+
command_timeout: float = Field(30.0, gt=0, description="Timeout for detection commands (s)")
|
|
36
|
+
build_timeout: float = Field(900.0, gt=0, description="Timeout for builds (s)")
|
|
37
|
+
test_timeout: float = Field(300.0, gt=0, description="Timeout per test executable (s)")
|
|
38
|
+
runtime_checks: bool = Field(True, description="Compile and run the HIP probe during diagnose")
|
|
39
|
+
torch_checks: bool = Field(True, description="Run PyTorch GPU tensor checks during diagnose")
|
|
40
|
+
python_executable: str | None = Field(
|
|
41
|
+
None, description="Python used for PyTorch checks (default: the current interpreter)"
|
|
42
|
+
)
|
|
43
|
+
hipify_preference: Literal["auto", "hipify-clang", "hipify-perl"] = "auto"
|
|
44
|
+
isolation: Literal["none", "docker"] = Field(
|
|
45
|
+
"none", description="Run migrated project builds/tests in Docker"
|
|
46
|
+
)
|
|
47
|
+
docker_image: str = Field("rocm/dev-ubuntu-24.04:latest", description="Image for isolated builds")
|
|
48
|
+
offload_arch: str | None = Field(
|
|
49
|
+
None, description="--offload-arch for hipcc (default: detected GPU targets)"
|
|
50
|
+
)
|
|
51
|
+
compatibility_matrix: str | None = Field(None, description="Path to a custom compatibility matrix JSON")
|
|
52
|
+
history: bool = Field(True, description="Record diagnostic runs and migrations in SQLite")
|
|
53
|
+
|
|
54
|
+
model_config = {"extra": "ignore"}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
ENV_PREFIX = "KERNELVET_"
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _env_overrides() -> dict[str, Any]:
|
|
61
|
+
out: dict[str, Any] = {}
|
|
62
|
+
for name in Settings.model_fields:
|
|
63
|
+
raw = os.environ.get(ENV_PREFIX + name.upper())
|
|
64
|
+
if raw is None:
|
|
65
|
+
continue
|
|
66
|
+
# pydantic coerces "true"/"0"/"30" to the field's type during validation
|
|
67
|
+
out[name] = raw
|
|
68
|
+
return out
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class ConfigError(ValueError):
|
|
72
|
+
pass
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def load_settings(path: Path | None = None) -> Settings:
|
|
76
|
+
path = path or config_path()
|
|
77
|
+
data: dict[str, Any] = {}
|
|
78
|
+
if path.exists():
|
|
79
|
+
try:
|
|
80
|
+
data = tomllib.loads(path.read_text())
|
|
81
|
+
except (OSError, tomllib.TOMLDecodeError) as exc:
|
|
82
|
+
raise ConfigError(f"could not read {path}: {exc}") from exc
|
|
83
|
+
data.update(_env_overrides())
|
|
84
|
+
try:
|
|
85
|
+
return Settings(**data)
|
|
86
|
+
except ValidationError as exc:
|
|
87
|
+
raise ConfigError(f"invalid configuration in {path}: {exc}") from exc
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def _toml_value(v: Any) -> str:
|
|
91
|
+
if isinstance(v, bool):
|
|
92
|
+
return "true" if v else "false"
|
|
93
|
+
if isinstance(v, int | float):
|
|
94
|
+
return repr(v)
|
|
95
|
+
s = str(v).replace("\\", "\\\\").replace('"', '\\"')
|
|
96
|
+
return f'"{s}"'
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def save_settings(settings: Settings, path: Path | None = None) -> Path:
|
|
100
|
+
path = path or config_path()
|
|
101
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
102
|
+
lines = ["# KernelVet configuration", ""]
|
|
103
|
+
for name, field in Settings.model_fields.items():
|
|
104
|
+
value = getattr(settings, name)
|
|
105
|
+
if field.description:
|
|
106
|
+
lines.append(f"# {field.description}")
|
|
107
|
+
if value is None:
|
|
108
|
+
lines.append(f"# {name} =")
|
|
109
|
+
else:
|
|
110
|
+
lines.append(f"{name} = {_toml_value(value)}")
|
|
111
|
+
path.write_text("\n".join(lines) + "\n")
|
|
112
|
+
return path
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|