kavier 0.3.1__tar.gz

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 (83) hide show
  1. kavier-0.3.1/LICENSE.txt +21 -0
  2. kavier-0.3.1/PKG-INFO +129 -0
  3. kavier-0.3.1/README.md +88 -0
  4. kavier-0.3.1/pyproject.toml +120 -0
  5. kavier-0.3.1/setup.cfg +4 -0
  6. kavier-0.3.1/src/kavier/__init__.py +108 -0
  7. kavier-0.3.1/src/kavier/inference/__init__.py +269 -0
  8. kavier-0.3.1/src/kavier/py.typed +0 -0
  9. kavier-0.3.1/src/kavier/training/__init__.py +164 -0
  10. kavier-0.3.1/src/kavier.egg-info/PKG-INFO +129 -0
  11. kavier-0.3.1/src/kavier.egg-info/SOURCES.txt +81 -0
  12. kavier-0.3.1/src/kavier.egg-info/dependency_links.txt +1 -0
  13. kavier-0.3.1/src/kavier.egg-info/entry_points.txt +7 -0
  14. kavier-0.3.1/src/kavier.egg-info/requires.txt +18 -0
  15. kavier-0.3.1/src/kavier.egg-info/top_level.txt +8 -0
  16. kavier-0.3.1/src/kavier_co2/__init__.py +1 -0
  17. kavier-0.3.1/src/kavier_co2/cli.py +163 -0
  18. kavier-0.3.1/src/kavier_co2/engine.py +157 -0
  19. kavier-0.3.1/src/kavier_co2/fragments.py +91 -0
  20. kavier-0.3.1/src/kavier_co2/py.typed +0 -0
  21. kavier-0.3.1/src/kavier_energy/__init__.py +1 -0
  22. kavier-0.3.1/src/kavier_energy/calculator.py +55 -0
  23. kavier-0.3.1/src/kavier_energy/cli_args.py +26 -0
  24. kavier-0.3.1/src/kavier_energy/engine.py +19 -0
  25. kavier-0.3.1/src/kavier_energy/metrics.py +57 -0
  26. kavier-0.3.1/src/kavier_energy/py.typed +0 -0
  27. kavier-0.3.1/src/kavier_inference/__init__.py +1 -0
  28. kavier-0.3.1/src/kavier_inference/cli.py +29 -0
  29. kavier-0.3.1/src/kavier_inference/core/__init__.py +1 -0
  30. kavier-0.3.1/src/kavier_inference/core/args.py +73 -0
  31. kavier-0.3.1/src/kavier_inference/core/cache.py +41 -0
  32. kavier-0.3.1/src/kavier_inference/core/config.py +34 -0
  33. kavier-0.3.1/src/kavier_inference/core/engine.py +74 -0
  34. kavier-0.3.1/src/kavier_inference/core/metrics.py +58 -0
  35. kavier-0.3.1/src/kavier_inference/core/runner.py +79 -0
  36. kavier-0.3.1/src/kavier_inference/core/service.py +57 -0
  37. kavier-0.3.1/src/kavier_inference/data/input/input_example.csv +7 -0
  38. kavier-0.3.1/src/kavier_inference/py.typed +0 -0
  39. kavier-0.3.1/src/kavier_inference/stages/__init__.py +1 -0
  40. kavier-0.3.1/src/kavier_inference/stages/decode.py +20 -0
  41. kavier-0.3.1/src/kavier_inference/stages/gpu_usage.py +14 -0
  42. kavier-0.3.1/src/kavier_inference/stages/kv_usage.py +27 -0
  43. kavier-0.3.1/src/kavier_inference/stages/prefill.py +12 -0
  44. kavier-0.3.1/src/kavier_io/__init__.py +1 -0
  45. kavier-0.3.1/src/kavier_io/config.py +29 -0
  46. kavier-0.3.1/src/kavier_io/constants.py +6 -0
  47. kavier-0.3.1/src/kavier_io/input_spec.py +80 -0
  48. kavier-0.3.1/src/kavier_io/log.py +8 -0
  49. kavier-0.3.1/src/kavier_io/opendc/__init__.py +1 -0
  50. kavier-0.3.1/src/kavier_io/opendc/adapter.py +79 -0
  51. kavier-0.3.1/src/kavier_io/opendc/py.typed +0 -0
  52. kavier-0.3.1/src/kavier_io/opendc/schema.py +27 -0
  53. kavier-0.3.1/src/kavier_io/py.typed +0 -0
  54. kavier-0.3.1/src/kavier_io/stream_writer.py +25 -0
  55. kavier-0.3.1/src/kavier_io/training_opendc.py +135 -0
  56. kavier-0.3.1/src/kavier_library/__init__.py +13 -0
  57. kavier-0.3.1/src/kavier_library/gpu.py +152 -0
  58. kavier-0.3.1/src/kavier_library/llm.py +156 -0
  59. kavier-0.3.1/src/kavier_library/lookup.py +33 -0
  60. kavier-0.3.1/src/kavier_library/py.typed +0 -0
  61. kavier-0.3.1/src/kavier_library/specs/GPUSpec.py +32 -0
  62. kavier-0.3.1/src/kavier_library/specs/LLMSpec.py +25 -0
  63. kavier-0.3.1/src/kavier_library/specs/__init__.py +6 -0
  64. kavier-0.3.1/src/kavier_training/__init__.py +1 -0
  65. kavier-0.3.1/src/kavier_training/cli.py +132 -0
  66. kavier-0.3.1/src/kavier_training/core/__init__.py +1 -0
  67. kavier-0.3.1/src/kavier_training/core/calibration.py +106 -0
  68. kavier-0.3.1/src/kavier_training/core/cli_args.py +39 -0
  69. kavier-0.3.1/src/kavier_training/core/config.py +4 -0
  70. kavier-0.3.1/src/kavier_training/core/engine.py +237 -0
  71. kavier-0.3.1/src/kavier_training/data/calibration.json +96 -0
  72. kavier-0.3.1/src/kavier_training/data/input/input_example.csv +101 -0
  73. kavier-0.3.1/src/kavier_training/py.typed +0 -0
  74. kavier-0.3.1/src/kavier_training/validation/__init__.py +1 -0
  75. kavier-0.3.1/src/kavier_training/validation/run_benchmarks.py +125 -0
  76. kavier-0.3.1/src/kavier_training/validation/validator.py +117 -0
  77. kavier-0.3.1/src/kavier_ui/__init__.py +11 -0
  78. kavier-0.3.1/src/kavier_ui/__main__.py +16 -0
  79. kavier-0.3.1/src/kavier_ui/app.py +264 -0
  80. kavier-0.3.1/src/kavier_ui/prompts.py +243 -0
  81. kavier-0.3.1/src/kavier_ui/render.py +202 -0
  82. kavier-0.3.1/src/kavier_ui/sims.py +37 -0
  83. kavier-0.3.1/src/kavier_ui/theme.py +46 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AtLarge Research
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
kavier-0.3.1/PKG-INFO ADDED
@@ -0,0 +1,129 @@
1
+ Metadata-Version: 2.4
2
+ Name: kavier
3
+ Version: 0.3.1
4
+ Summary: Kavier: Simulating the Performance, Sustainability, and Efficiency of LLM Ecosystems under Inference and Training
5
+ Author: Radu Nicolae
6
+ Author-email: AtLarge Research <info@atlarge-research.com>
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://github.com/atlarge-research/kavier
9
+ Project-URL: Repository, https://github.com/atlarge-research/kavier
10
+ Project-URL: Documentation, https://github.com/atlarge-research/kavier
11
+ Project-URL: Bug Tracker, https://github.com/atlarge-research/kavier/issues
12
+ Keywords: LLM,simulation,performance,sustainability,energy,carbon,GPU,training,inference
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Intended Audience :: Science/Research
18
+ Classifier: Intended Audience :: Developers
19
+ Classifier: Topic :: Scientific/Engineering
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE.txt
23
+ Requires-Dist: pydantic>=2.7
24
+ Requires-Dist: pandas>=2.2
25
+ Requires-Dist: pyarrow>=23.0.1
26
+ Requires-Dist: numpy>=2.2.6
27
+ Requires-Dist: tqdm>=4.67.1
28
+ Requires-Dist: cachetools>=6.1
29
+ Requires-Dist: rich>=13
30
+ Requires-Dist: pyyaml>=6
31
+ Provides-Extra: dev
32
+ Requires-Dist: pytest>=8.2; extra == "dev"
33
+ Requires-Dist: hypothesis>=6.102; extra == "dev"
34
+ Requires-Dist: ruff>=0.4; extra == "dev"
35
+ Requires-Dist: mypy>=1.10; extra == "dev"
36
+ Requires-Dist: pandas-stubs>=2.2; extra == "dev"
37
+ Requires-Dist: types-tqdm; extra == "dev"
38
+ Requires-Dist: types-cachetools; extra == "dev"
39
+ Requires-Dist: types-PyYAML; extra == "dev"
40
+ Dynamic: license-file
41
+
42
+ # Kavier
43
+
44
+ Simulating performance, sustainability, and efficiency of LLM Ecosystems under inference and training.
45
+
46
+ [![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
47
+ [![Documentation](https://img.shields.io/badge/docs-main-green.svg)](docs/index.html)
48
+ [![CI](https://github.com/atlarge-research/kavier/actions/workflows/ci.yml/badge.svg)](https://github.com/atlarge-research/kavier/actions/workflows/ci.yml)
49
+
50
+ ---
51
+
52
+ This repository is the home of Kavier, the first scientific instrument for
53
+ predicting performance, sustainability, and efficiency of LLM ecosystems under
54
+ inference and training.
55
+
56
+ Kavier helps operators, researchers, and engineers predict:
57
+ * **Performance** — inference latencies, training throughput, GPU utilization
58
+ * **Sustainability** — energy consumption, carbon emissions (gCO2/Mtoken)
59
+ * **Efficiency** — financial and energy cost per token/sample given GPU-hour prices
60
+
61
+ ## Quick start
62
+
63
+ ```bash
64
+ git clone https://github.com/atlarge-research/kavier.git
65
+ cd kavier
66
+
67
+ python -m venv .venv
68
+ source .venv/bin/activate # Windows: .venv\Scripts\activate
69
+ python -m pip install -U pip
70
+ pip install -e ".[dev]"
71
+ ```
72
+
73
+ Run your first simulation against the tiny bundled synthetic example trace:
74
+
75
+ ```bash
76
+ kavier-perf --trace src/kavier_inference/data/input/input_example.csv
77
+ ```
78
+
79
+ Congrats! You have just run your first simulation with Kavier! 🎉
80
+
81
+ Or skip the flags — launch the **interactive UI** and pick a simulator, model and
82
+ GPU from guided menus, then chain into energy/carbon or export OpenDC:
83
+
84
+ ```bash
85
+ kavier
86
+ ```
87
+
88
+ If you installed Kavier from PyPI (`pip install kavier`) you have no `src/`
89
+ directory; the same synthetic example trace ships inside the package, so resolve
90
+ its path via `importlib.resources`:
91
+
92
+ ```bash
93
+ TRACE=$(python -c "from importlib.resources import files; print(files('kavier_inference')/'data/input/input_example.csv')")
94
+ kavier-perf --trace "$TRACE"
95
+ ```
96
+
97
+ ## Structure
98
+
99
+ Kavier is organized into the following first-party packages:
100
+
101
+ ```
102
+ src/
103
+ ├── kavier/ # Umbrella facade (re-exports the sub-packages)
104
+ ├── kavier_inference/ # Inference simulation (kavier-perf)
105
+ ├── kavier_training/ # Training simulation (kavier-train)
106
+ ├── kavier_energy/ # Energy calculator (kavier-energy)
107
+ ├── kavier_co2/ # Carbon emissions (kavier-co2)
108
+ ├── kavier_library/ # Shared GPU & LLM specifications
109
+ ├── kavier_io/ # Shared I/O utilities
110
+ │ └── opendc/ # OpenDC workload export (tasks/fragments)
111
+ ├── kavier_ui/ # Interactive REPL (the `kavier` command)
112
+ └── tests/ # Test suites
113
+ ```
114
+
115
+ ## Documentation
116
+
117
+ See [docs/index.html](docs/index.html) for the main documentation: getting started,
118
+ the Kavier CLIs (`kavier` interactive UI, `kavier-perf`, `kavier-train`,
119
+ `kavier-energy`, `kavier-co2`), the YAML `--config` input,
120
+ structure, and the contributing guide.
121
+
122
+ ## Contributing
123
+
124
+ Questions, suggestions and contributions are welcome and appreciated!
125
+ Please refer to the [contributing guide](docs/contributing.md) for more details.
126
+
127
+ ## License
128
+
129
+ Kavier is distributed under the MIT license. See [LICENSE.txt](/LICENSE.txt).
kavier-0.3.1/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # Kavier
2
+
3
+ Simulating performance, sustainability, and efficiency of LLM Ecosystems under inference and training.
4
+
5
+ [![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
6
+ [![Documentation](https://img.shields.io/badge/docs-main-green.svg)](docs/index.html)
7
+ [![CI](https://github.com/atlarge-research/kavier/actions/workflows/ci.yml/badge.svg)](https://github.com/atlarge-research/kavier/actions/workflows/ci.yml)
8
+
9
+ ---
10
+
11
+ This repository is the home of Kavier, the first scientific instrument for
12
+ predicting performance, sustainability, and efficiency of LLM ecosystems under
13
+ inference and training.
14
+
15
+ Kavier helps operators, researchers, and engineers predict:
16
+ * **Performance** — inference latencies, training throughput, GPU utilization
17
+ * **Sustainability** — energy consumption, carbon emissions (gCO2/Mtoken)
18
+ * **Efficiency** — financial and energy cost per token/sample given GPU-hour prices
19
+
20
+ ## Quick start
21
+
22
+ ```bash
23
+ git clone https://github.com/atlarge-research/kavier.git
24
+ cd kavier
25
+
26
+ python -m venv .venv
27
+ source .venv/bin/activate # Windows: .venv\Scripts\activate
28
+ python -m pip install -U pip
29
+ pip install -e ".[dev]"
30
+ ```
31
+
32
+ Run your first simulation against the tiny bundled synthetic example trace:
33
+
34
+ ```bash
35
+ kavier-perf --trace src/kavier_inference/data/input/input_example.csv
36
+ ```
37
+
38
+ Congrats! You have just run your first simulation with Kavier! 🎉
39
+
40
+ Or skip the flags — launch the **interactive UI** and pick a simulator, model and
41
+ GPU from guided menus, then chain into energy/carbon or export OpenDC:
42
+
43
+ ```bash
44
+ kavier
45
+ ```
46
+
47
+ If you installed Kavier from PyPI (`pip install kavier`) you have no `src/`
48
+ directory; the same synthetic example trace ships inside the package, so resolve
49
+ its path via `importlib.resources`:
50
+
51
+ ```bash
52
+ TRACE=$(python -c "from importlib.resources import files; print(files('kavier_inference')/'data/input/input_example.csv')")
53
+ kavier-perf --trace "$TRACE"
54
+ ```
55
+
56
+ ## Structure
57
+
58
+ Kavier is organized into the following first-party packages:
59
+
60
+ ```
61
+ src/
62
+ ├── kavier/ # Umbrella facade (re-exports the sub-packages)
63
+ ├── kavier_inference/ # Inference simulation (kavier-perf)
64
+ ├── kavier_training/ # Training simulation (kavier-train)
65
+ ├── kavier_energy/ # Energy calculator (kavier-energy)
66
+ ├── kavier_co2/ # Carbon emissions (kavier-co2)
67
+ ├── kavier_library/ # Shared GPU & LLM specifications
68
+ ├── kavier_io/ # Shared I/O utilities
69
+ │ └── opendc/ # OpenDC workload export (tasks/fragments)
70
+ ├── kavier_ui/ # Interactive REPL (the `kavier` command)
71
+ └── tests/ # Test suites
72
+ ```
73
+
74
+ ## Documentation
75
+
76
+ See [docs/index.html](docs/index.html) for the main documentation: getting started,
77
+ the Kavier CLIs (`kavier` interactive UI, `kavier-perf`, `kavier-train`,
78
+ `kavier-energy`, `kavier-co2`), the YAML `--config` input,
79
+ structure, and the contributing guide.
80
+
81
+ ## Contributing
82
+
83
+ Questions, suggestions and contributions are welcome and appreciated!
84
+ Please refer to the [contributing guide](docs/contributing.md) for more details.
85
+
86
+ ## License
87
+
88
+ Kavier is distributed under the MIT license. See [LICENSE.txt](/LICENSE.txt).
@@ -0,0 +1,120 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "kavier"
7
+ version = "0.3.1"
8
+ description = "Kavier: Simulating the Performance, Sustainability, and Efficiency of LLM Ecosystems under Inference and Training"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ authors = [
12
+ { name = "Radu Nicolae" },
13
+ { name = "AtLarge Research", email = "info@atlarge-research.com" },
14
+ ]
15
+ requires-python = ">=3.11"
16
+ dependencies = [
17
+ "pydantic>=2.7",
18
+ "pandas>=2.2",
19
+ # pyarrow>=23.0.1: clears Arrow IPC use-after-free GHSA (high-sev); was >=16.0.
20
+ "pyarrow>=23.0.1",
21
+ "numpy>=2.2.6",
22
+ "tqdm>=4.67.1",
23
+ "cachetools>=6.1",
24
+ "rich>=13",
25
+ "pyyaml>=6",
26
+ ]
27
+ keywords = [
28
+ "LLM",
29
+ "simulation",
30
+ "performance",
31
+ "sustainability",
32
+ "energy",
33
+ "carbon",
34
+ "GPU",
35
+ "training",
36
+ "inference",
37
+ ]
38
+ classifiers = [
39
+ "Development Status :: 4 - Beta",
40
+ "Programming Language :: Python :: 3.11",
41
+ "Programming Language :: Python :: 3.12",
42
+ "Programming Language :: Python :: 3.13",
43
+ "Intended Audience :: Science/Research",
44
+ "Intended Audience :: Developers",
45
+ "Topic :: Scientific/Engineering",
46
+ ]
47
+
48
+ [project.urls]
49
+ Homepage = "https://github.com/atlarge-research/kavier"
50
+ Repository = "https://github.com/atlarge-research/kavier"
51
+ Documentation = "https://github.com/atlarge-research/kavier"
52
+ "Bug Tracker" = "https://github.com/atlarge-research/kavier/issues"
53
+
54
+ [project.optional-dependencies]
55
+ dev = [
56
+ "pytest>=8.2",
57
+ "hypothesis>=6.102",
58
+ "ruff>=0.4",
59
+ "mypy>=1.10",
60
+ "pandas-stubs>=2.2",
61
+ "types-tqdm",
62
+ "types-cachetools",
63
+ "types-PyYAML",
64
+ ]
65
+
66
+ [project.scripts]
67
+ kavier = "kavier_ui:main"
68
+ kavier-perf = "kavier_inference.cli:main"
69
+ kavier-train = "kavier_training.cli:main"
70
+ kavier-energy = "kavier_energy.calculator:main"
71
+ kavier-co2 = "kavier_co2.cli:main"
72
+ kavier-eff = "kavier_inference.cli:main_efficiency"
73
+
74
+ # ------------------------------------------------------------------
75
+ # Tooling
76
+ # ------------------------------------------------------------------
77
+
78
+ [tool.ruff]
79
+ line-length = 120
80
+ target-version = "py311"
81
+
82
+ [tool.ruff.lint]
83
+ select = ["E", "F", "W", "I"]
84
+ ignore = []
85
+
86
+ [tool.setuptools]
87
+ package-dir = {"" = "src"}
88
+
89
+
90
+ [tool.setuptools.packages.find]
91
+ where = ["src"]
92
+ include = ["kavier*"]
93
+
94
+ # Ship only small runtime/demo data (calibration table + tiny example trace); large trace stays out — see examples-local/.
95
+ [tool.setuptools.package-data]
96
+ # PEP 561: ship py.typed so installed consumers get inline type hints.
97
+ kavier = ["py.typed"]
98
+ kavier_training = ["py.typed", "data/calibration.json", "data/input/input_example.csv"]
99
+ kavier_inference = ["py.typed", "data/input/input_example.csv"]
100
+ kavier_io = ["py.typed"]
101
+ kavier_energy = ["py.typed"]
102
+ kavier_co2 = ["py.typed"]
103
+ kavier_library = ["py.typed"]
104
+ "kavier_io.opendc" = ["py.typed"]
105
+
106
+ [tool.setuptools.exclude-package-data]
107
+ kavier_inference = ["data/output/*", "data/output/**/*"]
108
+
109
+ [tool.mypy]
110
+ python_version = "3.11"
111
+ strict = true
112
+ mypy_path = "src"
113
+ packages = [
114
+ "kavier_inference",
115
+ "kavier_training",
116
+ "kavier_library",
117
+ "kavier_io",
118
+ "kavier_energy",
119
+ ]
120
+ exclude = ["tests/"]
kavier-0.3.1/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,108 @@
1
+ """Umbrella facade: the public ``inference``/``training`` API plus ``kavier.<sub>`` legacy aliases."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib as _importlib
6
+ import sys as _sys
7
+ from importlib.abc import Loader as _Loader
8
+ from importlib.abc import MetaPathFinder as _MetaPathFinder
9
+ from importlib.machinery import ModuleSpec as _ModuleSpec
10
+ from importlib.metadata import PackageNotFoundError as _PackageNotFoundError
11
+ from importlib.metadata import version as _pkg_version
12
+ from types import ModuleType as _ModuleType
13
+ from typing import Any as _Any
14
+ from typing import Sequence as _Sequence
15
+
16
+ # Pure aliases: ``kavier.<sub>`` (bare AND deep) resolves to the same object as ``kavier_<sub>``.
17
+ _ALIAS_TO_LEGACY = {
18
+ "io": "kavier_io",
19
+ "energy": "kavier_energy",
20
+ "co2": "kavier_co2",
21
+ "library": "kavier_library",
22
+ "opendc": "kavier_io.opendc",
23
+ }
24
+
25
+ # ``inference`` and ``training`` are REAL packages here (the public predictor API). The bare module is
26
+ # the new package, but DEEP imports (``kavier.training.core.calibration`` ...) still resolve to the
27
+ # legacy package — preserving the live calibration ``_CAL`` swap contract (one module per spelling).
28
+ _API_PACKAGES = {
29
+ "inference": "kavier_inference",
30
+ "training": "kavier_training",
31
+ }
32
+
33
+
34
+ class _LegacyAliasFinder(_MetaPathFinder):
35
+ _prefix = f"{__name__}."
36
+
37
+ def find_spec(
38
+ self,
39
+ fullname: str,
40
+ path: _Sequence[str] | None = None,
41
+ target: _ModuleType | None = None,
42
+ ) -> _ModuleSpec | None:
43
+ if not fullname.startswith(self._prefix):
44
+ return None
45
+ tail = fullname[len(self._prefix) :]
46
+ head, _, rest = tail.partition(".")
47
+ legacy_root = _ALIAS_TO_LEGACY.get(head)
48
+ if legacy_root is None:
49
+ # Deep imports under the real API packages alias to legacy; the bare package does not.
50
+ if rest and head in _API_PACKAGES:
51
+ legacy_root = _API_PACKAGES[head]
52
+ else:
53
+ return None
54
+ legacy_name = legacy_root if not rest else f"{legacy_root}.{rest}"
55
+ spec = _ModuleSpec(fullname, _LegacyAliasLoader(legacy_name))
56
+ return spec
57
+
58
+
59
+ class _LegacyAliasLoader(_Loader):
60
+ def __init__(self, legacy_name: str) -> None:
61
+ self._legacy_name = legacy_name
62
+
63
+ def create_module(self, spec: _ModuleSpec) -> _ModuleType:
64
+ module = _importlib.import_module(self._legacy_name)
65
+ _sys.modules[spec.name] = module
66
+ return module
67
+
68
+ def exec_module(self, module: _ModuleType) -> None: # already executed
69
+ return None
70
+
71
+
72
+ _sys.meta_path.insert(0, _LegacyAliasFinder())
73
+
74
+
75
+ def __getattr__(name: str) -> _Any:
76
+ legacy = _ALIAS_TO_LEGACY.get(name)
77
+ if legacy is not None:
78
+ return _importlib.import_module(f"{__name__}.{name}")
79
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
80
+
81
+
82
+ from kavier import inference, training # noqa: E402
83
+ from kavier_library.gpu import GPU_SPEC_LIBRARY # noqa: E402
84
+ from kavier_library.llm import LLM_SPEC_LIBRARY # noqa: E402
85
+ from kavier_training.core.engine import ( # noqa: E402
86
+ simulate_full_training,
87
+ simulate_training_step,
88
+ )
89
+
90
+ __all__ = [
91
+ "simulate_training_step",
92
+ "simulate_full_training",
93
+ "GPU_SPEC_LIBRARY",
94
+ "LLM_SPEC_LIBRARY",
95
+ "training",
96
+ "inference",
97
+ "io",
98
+ "energy",
99
+ "co2",
100
+ "library",
101
+ "opendc",
102
+ ]
103
+
104
+ # Version from installed dist metadata; pyproject's static ``version`` is the single source of truth.
105
+ try:
106
+ __version__ = _pkg_version("kavier")
107
+ except _PackageNotFoundError: # editable/source tree without dist metadata
108
+ __version__ = "0.0.0+unknown"