gpustack-runtime 0.1.39.post2__py3-none-any.whl → 0.1.40__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.
Files changed (43) hide show
  1. gpustack_runtime/__main__.py +7 -3
  2. gpustack_runtime/_version.py +2 -2
  3. gpustack_runtime/_version_appendix.py +1 -1
  4. gpustack_runtime/cmds/__init__.py +2 -0
  5. gpustack_runtime/cmds/deployer.py +84 -2
  6. gpustack_runtime/cmds/images.py +2 -0
  7. gpustack_runtime/deployer/__init__.py +2 -0
  8. gpustack_runtime/deployer/__types__.py +52 -28
  9. gpustack_runtime/deployer/__utils__.py +99 -112
  10. gpustack_runtime/deployer/cdi/__init__.py +81 -0
  11. gpustack_runtime/deployer/cdi/__types__.py +667 -0
  12. gpustack_runtime/deployer/cdi/thead.py +103 -0
  13. gpustack_runtime/deployer/docker.py +42 -24
  14. gpustack_runtime/deployer/kuberentes.py +8 -4
  15. gpustack_runtime/deployer/podman.py +41 -23
  16. gpustack_runtime/detector/__init__.py +62 -3
  17. gpustack_runtime/detector/__types__.py +11 -0
  18. gpustack_runtime/detector/__utils__.py +23 -0
  19. gpustack_runtime/detector/amd.py +17 -9
  20. gpustack_runtime/detector/hygon.py +6 -1
  21. gpustack_runtime/detector/iluvatar.py +20 -5
  22. gpustack_runtime/detector/mthreads.py +8 -12
  23. gpustack_runtime/detector/nvidia.py +365 -168
  24. gpustack_runtime/detector/pyacl/__init__.py +9 -1
  25. gpustack_runtime/detector/pyamdgpu/__init__.py +8 -0
  26. gpustack_runtime/detector/pycuda/__init__.py +9 -1
  27. gpustack_runtime/detector/pydcmi/__init__.py +9 -2
  28. gpustack_runtime/detector/pyhgml/__init__.py +5879 -0
  29. gpustack_runtime/detector/pyhgml/libhgml.so +0 -0
  30. gpustack_runtime/detector/pyhgml/libuki.so +0 -0
  31. gpustack_runtime/detector/pyhsa/__init__.py +9 -0
  32. gpustack_runtime/detector/pyixml/__init__.py +89 -164
  33. gpustack_runtime/detector/pyrocmcore/__init__.py +42 -24
  34. gpustack_runtime/detector/pyrocmsmi/__init__.py +141 -138
  35. gpustack_runtime/detector/thead.py +733 -0
  36. gpustack_runtime/envs.py +128 -55
  37. {gpustack_runtime-0.1.39.post2.dist-info → gpustack_runtime-0.1.40.dist-info}/METADATA +4 -2
  38. gpustack_runtime-0.1.40.dist-info/RECORD +55 -0
  39. gpustack_runtime/detector/pymtml/__init__.py +0 -770
  40. gpustack_runtime-0.1.39.post2.dist-info/RECORD +0 -49
  41. {gpustack_runtime-0.1.39.post2.dist-info → gpustack_runtime-0.1.40.dist-info}/WHEEL +0 -0
  42. {gpustack_runtime-0.1.39.post2.dist-info → gpustack_runtime-0.1.40.dist-info}/entry_points.txt +0 -0
  43. {gpustack_runtime-0.1.39.post2.dist-info → gpustack_runtime-0.1.40.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,81 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Literal
4
+
5
+ from .thead import THeadGenerator
6
+
7
+ if TYPE_CHECKING:
8
+ from pathlib import Path
9
+
10
+ from ...detector import ManufacturerEnum
11
+ from .__types__ import Generator
12
+
13
+
14
+ _GENERATORS: list[Generator] = [
15
+ THeadGenerator(),
16
+ ]
17
+ """
18
+ List of all CDI generators.
19
+ """
20
+
21
+ _GENERATORS_MAP: dict[ManufacturerEnum, Generator] = {
22
+ gen.manufacturer: gen for gen in _GENERATORS
23
+ }
24
+ """
25
+ Mapping from manufacturer to CDI generator.
26
+ """
27
+
28
+
29
+ def generate_config(
30
+ manufacturer: ManufacturerEnum | str,
31
+ output: Path | None = None,
32
+ _format: Literal["yaml", "json"] = "yaml",
33
+ ) -> tuple[str | None, str | None]:
34
+ """
35
+ Generate the CDI configuration.
36
+
37
+ Args:
38
+ manufacturer:
39
+ Manufacturer to filter the generation.
40
+ output:
41
+ The directory to store CDI files.
42
+ If None, CDI configuration is not stored.
43
+ _format:
44
+ The format of the CDI configuration.
45
+ Either "yaml" or "json". Default is "yaml".
46
+
47
+ Returns:
48
+ A tuple containing:
49
+ - CDI configuration string, or None if not supported.
50
+ - Path to the output CDI file, or None if not stored.
51
+
52
+ Raises:
53
+ Exception if failed to write to the output file.
54
+
55
+ """
56
+ gen = _GENERATORS_MAP.get(manufacturer)
57
+ if not gen:
58
+ return None, None
59
+
60
+ cfg = gen.generate()
61
+ if not cfg:
62
+ return None, None
63
+
64
+ expected = cfg.stringify(_format)
65
+ if not output:
66
+ return expected, None
67
+
68
+ cdi_file = cfg.kind.replace("/", "-") + f".{_format}"
69
+ cdi_path = output / cdi_file
70
+ if cdi_path.exists():
71
+ actual = cdi_path.read_text(encoding="utf-8")
72
+ if actual == expected:
73
+ return expected, str(cdi_path)
74
+
75
+ cdi_path.write_text(expected, encoding="utf-8")
76
+ return expected, str(cdi_path)
77
+
78
+
79
+ __all__ = [
80
+ "generate_config",
81
+ ]