infer-stack 0.7.0__tar.gz → 0.7.3__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 (217) hide show
  1. infer_stack-0.7.3/PKG-INFO +196 -0
  2. infer_stack-0.7.3/README.md +158 -0
  3. infer_stack-0.7.3/infer_stack/__init__.py +2 -0
  4. infer_stack-0.7.3/infer_stack/accounting.py +153 -0
  5. infer_stack-0.7.3/infer_stack/backends/__init__.py +3 -0
  6. infer_stack-0.7.3/infer_stack/backends/kubeai.py +1590 -0
  7. infer_stack-0.7.3/infer_stack/backends/kubeai_gateway.py +388 -0
  8. infer_stack-0.7.3/infer_stack/benchmark/__init__.py +1 -0
  9. infer_stack-0.7.3/infer_stack/benchmark/dashboard.py +345 -0
  10. infer_stack-0.7.3/infer_stack/benchmark/hardware.py +142 -0
  11. infer_stack-0.7.3/infer_stack/benchmark/ledger.py +48 -0
  12. infer_stack-0.7.3/infer_stack/benchmark/report.py +235 -0
  13. infer_stack-0.7.3/infer_stack/benchmark/runner.py +194 -0
  14. infer_stack-0.7.3/infer_stack/benchmark/workload.py +86 -0
  15. infer_stack-0.7.3/infer_stack/cli/__init__.py +264 -0
  16. infer_stack-0.7.3/infer_stack/cli/_run_lifecycle.py +74 -0
  17. infer_stack-0.7.3/infer_stack/cli/commands_benchmark.py +165 -0
  18. infer_stack-0.7.3/infer_stack/cli/commands_catalog.py +1221 -0
  19. infer_stack-0.7.3/infer_stack/cli/commands_images.py +52 -0
  20. infer_stack-0.7.3/infer_stack/cli/commands_kube.py +726 -0
  21. infer_stack-0.7.3/infer_stack/cli/commands_kube_worker.py +211 -0
  22. infer_stack-0.7.3/infer_stack/cli/commands_leasing.py +3354 -0
  23. infer_stack-0.7.3/infer_stack/cli/commands_ledger.py +80 -0
  24. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/cli/commands_meta.py +149 -32
  25. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/cli/commands_mock.py +12 -12
  26. infer_stack-0.7.3/infer_stack/cli/commands_runtime.py +982 -0
  27. infer_stack-0.7.3/infer_stack/cli/commands_server.py +118 -0
  28. infer_stack-0.7.3/infer_stack/cli/commands_usage.py +75 -0
  29. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/cli/context.py +1 -1
  30. infer_stack-0.7.3/infer_stack/cli/options.py +112 -0
  31. infer_stack-0.7.3/infer_stack/cli/remote.py +163 -0
  32. infer_stack-0.7.3/infer_stack/cli_equivalent.py +75 -0
  33. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/config.py +2 -1
  34. infer_stack-0.7.3/infer_stack/control/__init__.py +1 -0
  35. infer_stack-0.7.3/infer_stack/control/auth.py +64 -0
  36. infer_stack-0.7.3/infer_stack/control/catalog.py +109 -0
  37. infer_stack-0.7.3/infer_stack/control/client.py +67 -0
  38. infer_stack-0.7.3/infer_stack/control/errors.py +9 -0
  39. infer_stack-0.7.3/infer_stack/control/http.py +309 -0
  40. infer_stack-0.7.3/infer_stack/control/operations.py +81 -0
  41. infer_stack-0.7.3/infer_stack/control/service.py +361 -0
  42. infer_stack-0.7.3/infer_stack/control/tui.py +152 -0
  43. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/env_utils.py +31 -2
  44. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/experimental/model_catalog_discover.py +30 -22
  45. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/gpu_doctor.py +83 -17
  46. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/hardware.py +72 -31
  47. infer_stack-0.7.3/infer_stack/kube/__init__.py +13 -0
  48. infer_stack-0.7.3/infer_stack/kube/classification.py +47 -0
  49. infer_stack-0.7.3/infer_stack/kube/context.py +31 -0
  50. infer_stack-0.7.3/infer_stack/kube/inspect.py +227 -0
  51. infer_stack-0.7.3/infer_stack/kube/k3s.py +356 -0
  52. infer_stack-0.7.3/infer_stack/kube/manage.py +820 -0
  53. infer_stack-0.7.3/infer_stack/kube/monitor.py +139 -0
  54. infer_stack-0.7.3/infer_stack/kube/operations.py +155 -0
  55. infer_stack-0.7.3/infer_stack/kube/preflight.py +80 -0
  56. infer_stack-0.7.3/infer_stack/kube/worker.py +566 -0
  57. infer_stack-0.7.3/infer_stack/kubeai_ops.py +86 -0
  58. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/leasing/__init__.py +10 -1
  59. infer_stack-0.7.3/infer_stack/leasing/backend.py +918 -0
  60. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/leasing/catalog.py +278 -40
  61. infer_stack-0.7.3/infer_stack/leasing/catalog_edit.py +126 -0
  62. infer_stack-0.7.3/infer_stack/leasing/cluster_placement.py +97 -0
  63. infer_stack-0.7.3/infer_stack/leasing/compose.py +2627 -0
  64. infer_stack-0.7.3/infer_stack/leasing/controller.py +2555 -0
  65. infer_stack-0.7.3/infer_stack/leasing/diagnosis.py +193 -0
  66. infer_stack-0.7.3/infer_stack/leasing/discovery.py +163 -0
  67. infer_stack-0.7.3/infer_stack/leasing/endpoints.py +277 -0
  68. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/leasing/envfile.py +48 -20
  69. infer_stack-0.7.3/infer_stack/leasing/gateway.py +1556 -0
  70. infer_stack-0.7.3/infer_stack/leasing/instances.py +324 -0
  71. infer_stack-0.7.3/infer_stack/leasing/launch.py +276 -0
  72. infer_stack-0.7.3/infer_stack/leasing/ledger.py +603 -0
  73. infer_stack-0.7.3/infer_stack/leasing/lifecycle.py +69 -0
  74. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/leasing/models.py +46 -33
  75. infer_stack-0.7.3/infer_stack/leasing/naming.py +109 -0
  76. infer_stack-0.7.3/infer_stack/leasing/network.py +138 -0
  77. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/leasing/placement.py +90 -3
  78. infer_stack-0.7.3/infer_stack/leasing/postgres.py +134 -0
  79. infer_stack-0.7.3/infer_stack/leasing/profile.py +446 -0
  80. infer_stack-0.7.3/infer_stack/leasing/provenance.py +81 -0
  81. infer_stack-0.7.3/infer_stack/leasing/residency.py +502 -0
  82. infer_stack-0.7.3/infer_stack/leasing/routes.py +221 -0
  83. infer_stack-0.7.3/infer_stack/leasing/serving_policy.py +30 -0
  84. infer_stack-0.7.3/infer_stack/leasing/store.py +946 -0
  85. infer_stack-0.7.3/infer_stack/leasing/suggest.py +720 -0
  86. infer_stack-0.7.3/infer_stack/leasing/transition.py +78 -0
  87. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/leasing/vram.py +51 -13
  88. infer_stack-0.7.3/infer_stack/log_filter.py +399 -0
  89. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/mockserver/server.py +5 -2
  90. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/profile_runtime.py +5 -3
  91. infer_stack-0.7.3/infer_stack/runtime_images/__init__.py +75 -0
  92. infer_stack-0.7.3/infer_stack/runtime_images/maya_inkling/Dockerfile +47 -0
  93. infer_stack-0.7.3/infer_stack/runtime_images/maya_inkling/launcher.py +143 -0
  94. infer_stack-0.7.3/infer_stack/templates/catalog-qwen38-flash-next-3090.yaml +43 -0
  95. infer_stack-0.7.3/infer_stack/templates/suggestion-pool.yaml +806 -0
  96. infer_stack-0.7.3/infer_stack/tui.py +4244 -0
  97. infer_stack-0.7.3/infer_stack.egg-info/PKG-INFO +196 -0
  98. infer_stack-0.7.3/infer_stack.egg-info/SOURCES.txt +189 -0
  99. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack.egg-info/requires.txt +4 -1
  100. {infer_stack-0.7.0 → infer_stack-0.7.3}/pyproject.toml +7 -5
  101. infer_stack-0.7.3/tests/test_accounting.py +90 -0
  102. infer_stack-0.7.3/tests/test_backend_transition.py +203 -0
  103. infer_stack-0.7.3/tests/test_benchmark.py +137 -0
  104. infer_stack-0.7.3/tests/test_benchmark_dashboard.py +70 -0
  105. infer_stack-0.7.3/tests/test_benchmark_live.py +95 -0
  106. infer_stack-0.7.3/tests/test_catalog_builtin_import.py +94 -0
  107. infer_stack-0.7.3/tests/test_catalog_discovery.py +132 -0
  108. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_cli_catalog.py +215 -6
  109. infer_stack-0.7.3/tests/test_cli_equivalent.py +85 -0
  110. infer_stack-0.7.3/tests/test_cli_kube.py +598 -0
  111. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_cli_leasing.py +450 -14
  112. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_cli_meta.py +59 -4
  113. infer_stack-0.7.3/tests/test_cli_run_signals.py +139 -0
  114. infer_stack-0.7.3/tests/test_control_access.py +202 -0
  115. infer_stack-0.7.3/tests/test_control_catalog.py +192 -0
  116. infer_stack-0.7.3/tests/test_control_http.py +282 -0
  117. infer_stack-0.7.3/tests/test_control_service.py +193 -0
  118. infer_stack-0.7.3/tests/test_control_tui.py +60 -0
  119. infer_stack-0.7.3/tests/test_day2.py +351 -0
  120. infer_stack-0.7.3/tests/test_external_endpoints.py +804 -0
  121. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_gpu_doctor.py +90 -10
  122. infer_stack-0.7.3/tests/test_hardware.py +42 -0
  123. infer_stack-0.7.3/tests/test_kube_readiness.py +470 -0
  124. infer_stack-0.7.3/tests/test_kube_review.py +340 -0
  125. infer_stack-0.7.3/tests/test_kube_worker.py +556 -0
  126. infer_stack-0.7.3/tests/test_leasing_admission.py +560 -0
  127. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_leasing_catalog.py +143 -17
  128. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_leasing_compose.py +429 -63
  129. infer_stack-0.7.3/tests/test_leasing_context_metadata.py +451 -0
  130. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_leasing_controller.py +89 -0
  131. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_leasing_controller_lock.py +17 -8
  132. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_leasing_controller_queue.py +23 -28
  133. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_leasing_dynamic_routing.py +297 -34
  134. infer_stack-0.7.3/tests/test_leasing_effort.py +165 -0
  135. infer_stack-0.7.3/tests/test_leasing_image_pull.py +183 -0
  136. infer_stack-0.7.3/tests/test_leasing_kubeai.py +1280 -0
  137. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_leasing_ledger.py +20 -0
  138. infer_stack-0.7.3/tests/test_leasing_make_room.py +120 -0
  139. infer_stack-0.7.3/tests/test_leasing_network.py +229 -0
  140. infer_stack-0.7.3/tests/test_leasing_observability.py +72 -0
  141. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_leasing_placement.py +43 -19
  142. infer_stack-0.7.3/tests/test_leasing_placement_admission.py +81 -0
  143. infer_stack-0.7.3/tests/test_leasing_profile.py +684 -0
  144. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_leasing_reservation.py +4 -22
  145. infer_stack-0.7.3/tests/test_leasing_residency.py +268 -0
  146. infer_stack-0.7.3/tests/test_leasing_route_registry.py +360 -0
  147. infer_stack-0.7.3/tests/test_leasing_secrets.py +367 -0
  148. infer_stack-0.7.3/tests/test_leasing_selective_apply.py +212 -0
  149. infer_stack-0.7.3/tests/test_leasing_serialised_publication.py +831 -0
  150. infer_stack-0.7.3/tests/test_leasing_startup_failure.py +263 -0
  151. infer_stack-0.7.3/tests/test_leasing_store_threads.py +45 -0
  152. infer_stack-0.7.3/tests/test_leasing_suggest.py +612 -0
  153. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_leasing_vram.py +41 -0
  154. infer_stack-0.7.3/tests/test_lifecycle.py +58 -0
  155. infer_stack-0.7.3/tests/test_log_filter.py +312 -0
  156. infer_stack-0.7.3/tests/test_maya_inkling.py +172 -0
  157. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_mock_vllm_serve.py +2 -2
  158. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_mockserver.py +35 -27
  159. infer_stack-0.7.3/tests/test_parity.py +771 -0
  160. infer_stack-0.7.3/tests/test_publication_transaction.py +149 -0
  161. infer_stack-0.7.3/tests/test_qwen38_single_managed.py +97 -0
  162. infer_stack-0.7.3/tests/test_runtime_images.py +66 -0
  163. infer_stack-0.7.3/tests/test_service_roadmap.py +148 -0
  164. infer_stack-0.7.3/tests/test_serving_provenance.py +123 -0
  165. infer_stack-0.7.3/tests/test_shm_size.py +56 -0
  166. infer_stack-0.7.3/tests/test_store_contract.py +172 -0
  167. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_tui.py +1102 -89
  168. infer_stack-0.7.3/tests/test_tui_kube.py +505 -0
  169. infer_stack-0.7.0/PKG-INFO +0 -1073
  170. infer_stack-0.7.0/README.md +0 -1037
  171. infer_stack-0.7.0/infer_stack/__init__.py +0 -2
  172. infer_stack-0.7.0/infer_stack/backends/__init__.py +0 -4
  173. infer_stack-0.7.0/infer_stack/backends/kubeai.py +0 -535
  174. infer_stack-0.7.0/infer_stack/backends/kubeai_renderer.py +0 -204
  175. infer_stack-0.7.0/infer_stack/cli/__init__.py +0 -171
  176. infer_stack-0.7.0/infer_stack/cli/commands_catalog.py +0 -854
  177. infer_stack-0.7.0/infer_stack/cli/commands_leasing.py +0 -2314
  178. infer_stack-0.7.0/infer_stack/cli/commands_runtime.py +0 -627
  179. infer_stack-0.7.0/infer_stack/cli/options.py +0 -148
  180. infer_stack-0.7.0/infer_stack/kubeai_ops.py +0 -76
  181. infer_stack-0.7.0/infer_stack/leasing/backend.py +0 -309
  182. infer_stack-0.7.0/infer_stack/leasing/compose.py +0 -2359
  183. infer_stack-0.7.0/infer_stack/leasing/controller.py +0 -840
  184. infer_stack-0.7.0/infer_stack/leasing/ledger.py +0 -380
  185. infer_stack-0.7.0/infer_stack/leasing/store.py +0 -484
  186. infer_stack-0.7.0/infer_stack/leasing/suggest.py +0 -274
  187. infer_stack-0.7.0/infer_stack/templates/suggestion-pool.yaml +0 -377
  188. infer_stack-0.7.0/infer_stack/tui.py +0 -2574
  189. infer_stack-0.7.0/infer_stack.egg-info/PKG-INFO +0 -1073
  190. infer_stack-0.7.0/infer_stack.egg-info/SOURCES.txt +0 -82
  191. infer_stack-0.7.0/tests/test_leasing_coalesced_apply.py +0 -405
  192. infer_stack-0.7.0/tests/test_leasing_kubeai.py +0 -518
  193. infer_stack-0.7.0/tests/test_leasing_route_registry.py +0 -427
  194. infer_stack-0.7.0/tests/test_leasing_suggest.py +0 -132
  195. {infer_stack-0.7.0 → infer_stack-0.7.3}/LICENSE +0 -0
  196. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/__main__.py +0 -0
  197. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/_log.py +0 -0
  198. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/cli/__main__.py +0 -0
  199. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/diff_prompt.py +0 -0
  200. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/docker_utils.py +0 -0
  201. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/experimental/model_memory_estimator.py +0 -0
  202. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/experimental/stress_test_long_context.py +0 -0
  203. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/mockserver/__init__.py +0 -0
  204. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/mockserver/data/oracle_questions.yaml +0 -0
  205. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/mockserver/modes.py +0 -0
  206. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/mockserver/simulator.py +0 -0
  207. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/mockserver/vllm_serve.py +0 -0
  208. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/paths.py +0 -0
  209. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack/probe.py +0 -0
  210. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack.egg-info/dependency_links.txt +0 -0
  211. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack.egg-info/entry_points.txt +0 -0
  212. {infer_stack-0.7.0 → infer_stack-0.7.3}/infer_stack.egg-info/top_level.txt +0 -0
  213. {infer_stack-0.7.0 → infer_stack-0.7.3}/setup.cfg +0 -0
  214. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_cli_config.py +0 -0
  215. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_import.py +0 -0
  216. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_reservation_gpu_frame_e2e.py +0 -0
  217. {infer_stack-0.7.0 → infer_stack-0.7.3}/tests/test_simulator_runtime.py +0 -0
@@ -0,0 +1,196 @@
1
+ Metadata-Version: 2.4
2
+ Name: infer-stack
3
+ Version: 0.7.3
4
+ Summary: Profile-driven compose and KubeAI deployment compiler for inference stacks
5
+ Author-email: "jon.crall" <jon.crall@kitware.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/AIQ-Kitware/infer_stack
8
+ Classifier: Development Status :: 1 - Planning
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Programming Language :: Python :: 3.15
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Classifier: Topic :: Utilities
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: jinja2>=3.1
22
+ Requires-Dist: kwconf>=0.11.0
23
+ Requires-Dist: loguru>=0.7
24
+ Requires-Dist: pyyaml>=6.0
25
+ Requires-Dist: requests>=2.31
26
+ Requires-Dist: rich>=13.0
27
+ Requires-Dist: ubelt>=1.3
28
+ Provides-Extra: tests
29
+ Requires-Dist: pytest>=7.0; extra == "tests"
30
+ Requires-Dist: pytest-codeblocks>=0.17; extra == "tests"
31
+ Requires-Dist: pytest-cov>=3.0; extra == "tests"
32
+ Requires-Dist: xdoctest>=1.1.5; extra == "tests"
33
+ Provides-Extra: tui
34
+ Requires-Dist: textual>=0.50; extra == "tui"
35
+ Provides-Extra: postgres
36
+ Requires-Dist: psycopg[binary]<4,>=3.2; extra == "postgres"
37
+ Dynamic: license-file
38
+
39
+ # Infer Stack
40
+
41
+ [![PyPI version](https://img.shields.io/pypi/v/infer-stack.svg)](https://pypi.org/project/infer-stack/)
42
+ [![Python versions](https://img.shields.io/pypi/pyversions/infer-stack.svg)](https://pypi.org/project/infer-stack/)
43
+ [![License](https://img.shields.io/pypi/l/infer-stack.svg)](https://github.com/AIQ-Kitware/infer_stack/blob/main/LICENSE)
44
+
45
+ **Run local language models on demand, using Docker, but with simple wrappers.**
46
+
47
+ Infer-stack manages model configurations, GPU placement, and the lifetime of
48
+ inference servers. Acquire a model when you need it, use a consistent API URL,
49
+ and release it when you're done. Use it from the command line, a terminal UI,
50
+ or an automated evaluation pipeline.
51
+
52
+ - **Discover** model configurations for your hardware, or import and tune known
53
+ configurations yourself.
54
+ - **Serve** vLLM, Ollama, and compatible custom engines behind a shared LiteLLM
55
+ gateway, optionally with Open WebUI.
56
+ - **Lease** endpoints for a standing service or a single command; reuse compatible
57
+ deployments and reclaim idle ones.
58
+ - **Compare** inference performance across contexts, configurations, and machines
59
+ with a live benchmark report and a portable results ledger.
60
+
61
+ ## Quickstart
62
+
63
+ ### 1. Install and configure
64
+
65
+ Start with a Linux workstation, Python 3.10+, Docker and the Docker Compose
66
+ plugin. For NVIDIA GPU inference, install a working NVIDIA driver and NVIDIA
67
+ Container Toolkit first. The no-GPU simulator below does not require the NVIDIA software or hardware.
68
+
69
+ In a Python virtual environment:
70
+
71
+ ```bash
72
+ pip install 'infer-stack[tui]'
73
+ ```
74
+
75
+ The `tui` extra is optional. From a source checkout, use `pip install -e '.[tui]'`
76
+ instead. Initialize the Compose backend and select a data directory with room
77
+ for model weights and caches:
78
+
79
+ ```bash
80
+ umask 077
81
+ infer-stack config init --backend compose
82
+ ```
83
+
84
+ **Security:** The default Open WebUI has no login screen, and Compose publishes
85
+ its ports on the host. Use a trusted, firewalled machine; do not expose it to
86
+ untrusted networks. For API-only use, run `infer-stack config set ui false`
87
+ before acquisition. Keep config/data directories private and generated
88
+ environment files secret (do not commit `lease.env`). See [known limitations](docs/planning/known-limitations.md).
89
+
90
+ ### 2. Discover and acquire a model
91
+
92
+ ```bash
93
+ infer-stack catalog suggest --apply
94
+ infer-stack catalog endpoint list
95
+ ```
96
+
97
+ Suggestions are additive, hardware-aware starting configurations, not guarantees
98
+ that every model will fit. Choose an endpoint from the list. For a small chat
99
+ smoke test on a compatible GPU, use:
100
+
101
+ ```bash
102
+ ENDPOINT=smollm2-135m
103
+ infer-stack acquire "$ENDPOINT" --env-file lease.env
104
+ infer-stack test "$ENDPOINT"
105
+ ```
106
+
107
+ Review and confirm deployment changes when prompted. The first acquisition can
108
+ pull or build an image and download weights. It waits for a real generation,
109
+ not just a running container; allow a longer `--timeout` for large models.
110
+
111
+ **No GPU?** Substitute these commands for step 2 to exercise the same workflow:
112
+
113
+ ```bash
114
+ infer-stack catalog suggest --simulator --apply
115
+ ENDPOINT=mock-smol
116
+ infer-stack acquire "$ENDPOINT" --env-file lease.env
117
+ infer-stack test "$ENDPOINT"
118
+ ```
119
+
120
+ The [simulator](docs/mock-endpoints.md) generates mock text; it is not a real
121
+ model or a performance benchmark.
122
+
123
+ ### 3. Use the endpoint
124
+
125
+ - **Browser:** open <http://127.0.0.1:13000> if Open WebUI is enabled.
126
+ - **API:** use the endpoint name as the model ID and the default LiteLLM base
127
+ URL `http://127.0.0.1:14042/v1`. Load the credentials from your trusted local
128
+ `lease.env` file (it exports `OPENAI_BASE_URL` and `OPENAI_API_KEY`).
129
+ - **Terminal UI:** run `infer-stack tui` to browse/import models, monitor GPUs,
130
+ edit endpoints, acquire/release leases, and view logs.
131
+
132
+ For example, send a chat request through the OpenAI-compatible API (with the
133
+ normal LiteLLM gateway enabled and `curl` installed):
134
+
135
+ ```bash
136
+ (
137
+ source lease.env
138
+ curl -fsS "$OPENAI_BASE_URL/chat/completions" \
139
+ -H "Authorization: Bearer $OPENAI_API_KEY" \
140
+ -H 'Content-Type: application/json' \
141
+ -d "{\"model\":\"$INFER_STACK_MODELS\",\"messages\":[{\"role\":\"user\",\"content\":\"Say hello.\"}],\"max_tokens\":64}"
142
+ )
143
+ ```
144
+
145
+ ### 4. Release it
146
+
147
+ ```bash
148
+ infer-stack leases
149
+ infer-stack release --env-file lease.env
150
+ ```
151
+
152
+ This releases only the lease recorded in `lease.env`. Suggested endpoints stop when
153
+ their last lease ends; model weights and caches remain on disk. The gateway and
154
+ UI remain available for the next model. Remove the local `lease.env` when you
155
+ no longer need its credentials. For a full stack shutdown, see [operations](docs/operations.md#shutdown-and-reclaim).
156
+
157
+ ## Everyday workflows
158
+
159
+ | I want to… | Command |
160
+ | --- | --- |
161
+ | See available endpoint names | `infer-stack catalog endpoint list` |
162
+ | Discover or edit known configurations | `infer-stack tui` → Browse models |
163
+ | Import a known profile | `infer-stack catalog import NAME` |
164
+ | Run a job with an automatic lease | `infer-stack run --endpoint NAME -- COMMAND` |
165
+ | See running deployments | `infer-stack leases` / `infer-stack ps` |
166
+ | Follow only model engine logs | `infer-stack logs --engine -f` |
167
+ | Benchmark several endpoints serially | `infer-stack benchmark run NAME1 NAME2` |
168
+ | Compare historical measurements | `infer-stack benchmark report` |
169
+ | Find configuration and cache directories | `infer-stack paths` |
170
+ | Explore all CLI commands | `infer-stack help tree` |
171
+
172
+ In the TUI, **Suggest** recommends configurations for the detected hardware;
173
+ **Browse models** shows the full registered suggestion pool, including optional
174
+ and experimental configurations with hardware-fit warnings. Import & edit is
175
+ the path for trying a model on different hardware. Importing does not override
176
+ placement checks. See [model discovery and profiles](docs/model-profiles.md).
177
+
178
+ ## Choose a backend
179
+
180
+ **Compose** is the simplest way to serve models on one machine. For a Kubernetes
181
+ cluster, **KubeAI** uses the same catalog/lease interface with cluster scheduling
182
+ and vLLM; Ollama and custom launcher commands/mounts are Compose-only. See the
183
+ [backend comparison](docs/backend-parity.md) and [cluster setup](docs/cluster-setup.md).
184
+
185
+ ## Documentation
186
+
187
+ The **[documentation index](docs/index.md)** organizes all the guides by task.
188
+ For common next steps: [custom endpoints](docs/catalog.md),
189
+ [operations and troubleshooting](docs/operations.md),
190
+ [Compose configuration](docs/compose.md), [benchmarking](docs/benchmark.md),
191
+ and [KubeAI and remote control](docs/kubeai-backend.md).
192
+
193
+ Infer-stack is a Linux-oriented, planning-stage project. See
194
+ [known limitations](docs/planning/known-limitations.md) for operational and
195
+ security boundaries. For contributors, see [AGENTS.md](AGENTS.md) and
196
+ [dev/README.md](dev/README.md).
@@ -0,0 +1,158 @@
1
+ # Infer Stack
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/infer-stack.svg)](https://pypi.org/project/infer-stack/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/infer-stack.svg)](https://pypi.org/project/infer-stack/)
5
+ [![License](https://img.shields.io/pypi/l/infer-stack.svg)](https://github.com/AIQ-Kitware/infer_stack/blob/main/LICENSE)
6
+
7
+ **Run local language models on demand, using Docker, but with simple wrappers.**
8
+
9
+ Infer-stack manages model configurations, GPU placement, and the lifetime of
10
+ inference servers. Acquire a model when you need it, use a consistent API URL,
11
+ and release it when you're done. Use it from the command line, a terminal UI,
12
+ or an automated evaluation pipeline.
13
+
14
+ - **Discover** model configurations for your hardware, or import and tune known
15
+ configurations yourself.
16
+ - **Serve** vLLM, Ollama, and compatible custom engines behind a shared LiteLLM
17
+ gateway, optionally with Open WebUI.
18
+ - **Lease** endpoints for a standing service or a single command; reuse compatible
19
+ deployments and reclaim idle ones.
20
+ - **Compare** inference performance across contexts, configurations, and machines
21
+ with a live benchmark report and a portable results ledger.
22
+
23
+ ## Quickstart
24
+
25
+ ### 1. Install and configure
26
+
27
+ Start with a Linux workstation, Python 3.10+, Docker and the Docker Compose
28
+ plugin. For NVIDIA GPU inference, install a working NVIDIA driver and NVIDIA
29
+ Container Toolkit first. The no-GPU simulator below does not require the NVIDIA software or hardware.
30
+
31
+ In a Python virtual environment:
32
+
33
+ ```bash
34
+ pip install 'infer-stack[tui]'
35
+ ```
36
+
37
+ The `tui` extra is optional. From a source checkout, use `pip install -e '.[tui]'`
38
+ instead. Initialize the Compose backend and select a data directory with room
39
+ for model weights and caches:
40
+
41
+ ```bash
42
+ umask 077
43
+ infer-stack config init --backend compose
44
+ ```
45
+
46
+ **Security:** The default Open WebUI has no login screen, and Compose publishes
47
+ its ports on the host. Use a trusted, firewalled machine; do not expose it to
48
+ untrusted networks. For API-only use, run `infer-stack config set ui false`
49
+ before acquisition. Keep config/data directories private and generated
50
+ environment files secret (do not commit `lease.env`). See [known limitations](docs/planning/known-limitations.md).
51
+
52
+ ### 2. Discover and acquire a model
53
+
54
+ ```bash
55
+ infer-stack catalog suggest --apply
56
+ infer-stack catalog endpoint list
57
+ ```
58
+
59
+ Suggestions are additive, hardware-aware starting configurations, not guarantees
60
+ that every model will fit. Choose an endpoint from the list. For a small chat
61
+ smoke test on a compatible GPU, use:
62
+
63
+ ```bash
64
+ ENDPOINT=smollm2-135m
65
+ infer-stack acquire "$ENDPOINT" --env-file lease.env
66
+ infer-stack test "$ENDPOINT"
67
+ ```
68
+
69
+ Review and confirm deployment changes when prompted. The first acquisition can
70
+ pull or build an image and download weights. It waits for a real generation,
71
+ not just a running container; allow a longer `--timeout` for large models.
72
+
73
+ **No GPU?** Substitute these commands for step 2 to exercise the same workflow:
74
+
75
+ ```bash
76
+ infer-stack catalog suggest --simulator --apply
77
+ ENDPOINT=mock-smol
78
+ infer-stack acquire "$ENDPOINT" --env-file lease.env
79
+ infer-stack test "$ENDPOINT"
80
+ ```
81
+
82
+ The [simulator](docs/mock-endpoints.md) generates mock text; it is not a real
83
+ model or a performance benchmark.
84
+
85
+ ### 3. Use the endpoint
86
+
87
+ - **Browser:** open <http://127.0.0.1:13000> if Open WebUI is enabled.
88
+ - **API:** use the endpoint name as the model ID and the default LiteLLM base
89
+ URL `http://127.0.0.1:14042/v1`. Load the credentials from your trusted local
90
+ `lease.env` file (it exports `OPENAI_BASE_URL` and `OPENAI_API_KEY`).
91
+ - **Terminal UI:** run `infer-stack tui` to browse/import models, monitor GPUs,
92
+ edit endpoints, acquire/release leases, and view logs.
93
+
94
+ For example, send a chat request through the OpenAI-compatible API (with the
95
+ normal LiteLLM gateway enabled and `curl` installed):
96
+
97
+ ```bash
98
+ (
99
+ source lease.env
100
+ curl -fsS "$OPENAI_BASE_URL/chat/completions" \
101
+ -H "Authorization: Bearer $OPENAI_API_KEY" \
102
+ -H 'Content-Type: application/json' \
103
+ -d "{\"model\":\"$INFER_STACK_MODELS\",\"messages\":[{\"role\":\"user\",\"content\":\"Say hello.\"}],\"max_tokens\":64}"
104
+ )
105
+ ```
106
+
107
+ ### 4. Release it
108
+
109
+ ```bash
110
+ infer-stack leases
111
+ infer-stack release --env-file lease.env
112
+ ```
113
+
114
+ This releases only the lease recorded in `lease.env`. Suggested endpoints stop when
115
+ their last lease ends; model weights and caches remain on disk. The gateway and
116
+ UI remain available for the next model. Remove the local `lease.env` when you
117
+ no longer need its credentials. For a full stack shutdown, see [operations](docs/operations.md#shutdown-and-reclaim).
118
+
119
+ ## Everyday workflows
120
+
121
+ | I want to… | Command |
122
+ | --- | --- |
123
+ | See available endpoint names | `infer-stack catalog endpoint list` |
124
+ | Discover or edit known configurations | `infer-stack tui` → Browse models |
125
+ | Import a known profile | `infer-stack catalog import NAME` |
126
+ | Run a job with an automatic lease | `infer-stack run --endpoint NAME -- COMMAND` |
127
+ | See running deployments | `infer-stack leases` / `infer-stack ps` |
128
+ | Follow only model engine logs | `infer-stack logs --engine -f` |
129
+ | Benchmark several endpoints serially | `infer-stack benchmark run NAME1 NAME2` |
130
+ | Compare historical measurements | `infer-stack benchmark report` |
131
+ | Find configuration and cache directories | `infer-stack paths` |
132
+ | Explore all CLI commands | `infer-stack help tree` |
133
+
134
+ In the TUI, **Suggest** recommends configurations for the detected hardware;
135
+ **Browse models** shows the full registered suggestion pool, including optional
136
+ and experimental configurations with hardware-fit warnings. Import & edit is
137
+ the path for trying a model on different hardware. Importing does not override
138
+ placement checks. See [model discovery and profiles](docs/model-profiles.md).
139
+
140
+ ## Choose a backend
141
+
142
+ **Compose** is the simplest way to serve models on one machine. For a Kubernetes
143
+ cluster, **KubeAI** uses the same catalog/lease interface with cluster scheduling
144
+ and vLLM; Ollama and custom launcher commands/mounts are Compose-only. See the
145
+ [backend comparison](docs/backend-parity.md) and [cluster setup](docs/cluster-setup.md).
146
+
147
+ ## Documentation
148
+
149
+ The **[documentation index](docs/index.md)** organizes all the guides by task.
150
+ For common next steps: [custom endpoints](docs/catalog.md),
151
+ [operations and troubleshooting](docs/operations.md),
152
+ [Compose configuration](docs/compose.md), [benchmarking](docs/benchmark.md),
153
+ and [KubeAI and remote control](docs/kubeai-backend.md).
154
+
155
+ Infer-stack is a Linux-oriented, planning-stage project. See
156
+ [known limitations](docs/planning/known-limitations.md) for operational and
157
+ security boundaries. For contributors, see [AGENTS.md](AGENTS.md) and
158
+ [dev/README.md](dev/README.md).
@@ -0,0 +1,2 @@
1
+ __all__ = []
2
+ __version__ = '0.7.3'
@@ -0,0 +1,153 @@
1
+ """Durable usage facts and recomputable energy with explicit measurement gaps.
2
+
3
+ Intervals are half-open UTC epoch seconds. Samples are total GPU watts for the
4
+ record's device set, not whole-host power. Allocation and power are separate
5
+ facts; shared leases never receive copies of a deployment's energy.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import json
10
+ import math
11
+ import sqlite3
12
+ from dataclasses import asdict, dataclass
13
+ from pathlib import Path
14
+
15
+
16
+ @dataclass(frozen=True)
17
+ class UsageInterval:
18
+ id: str
19
+ start: float
20
+ end: float
21
+ node: str
22
+ deployment: str
23
+ replica: str
24
+ gpu_count: int
25
+ gpu_uuids: tuple[str, ...] = ()
26
+ model: str = ''
27
+ endpoint: str = ''
28
+ gpu_product: str = ''
29
+ source: str = ''
30
+ samples: tuple[tuple[float, float], ...] = ()
31
+ max_sample_gap: float = 30
32
+ proxy_watts: float | None = None
33
+ proxy_source: str = ''
34
+ proxy_version: str = ''
35
+ proxy_method: str = 'static_device_class_proxy'
36
+ request_count: int | None = None
37
+ input_tokens: int | None = None
38
+ output_tokens: int | None = None
39
+
40
+ def validate(self) -> None:
41
+ if not all(isinstance(s, str) and s for s in [self.id, self.node, self.deployment, self.replica]):
42
+ raise ValueError('Usage identity, node, deployment and replica are required')
43
+ if not all(not isinstance(n, bool) and math.isfinite(n) for n in [self.start, self.end, self.max_sample_gap]) or self.end <= self.start or self.max_sample_gap <= 0:
44
+ raise ValueError('Usage requires a finite positive interval and sample gap')
45
+ if isinstance(self.gpu_count, bool) or not isinstance(self.gpu_count, int) or self.gpu_count < 1:
46
+ raise ValueError('gpu_count must be a positive integer')
47
+ if self.gpu_uuids and (len(set(self.gpu_uuids)) != self.gpu_count or len(self.gpu_uuids) != self.gpu_count):
48
+ raise ValueError('GPU UUIDs must be unique and match allocated count')
49
+ if any(not isinstance(value, str) or not value for value in self.gpu_uuids):
50
+ raise ValueError('GPU UUIDs must be nonempty strings')
51
+ if self.samples and (not self.source or not self.gpu_uuids):
52
+ raise ValueError('Measured power requires source and stable GPU UUIDs')
53
+ previous = None
54
+ for stamp, watts in self.samples:
55
+ if not all(not isinstance(n, bool) and math.isfinite(n) for n in [stamp, watts]) or watts < 0 or (previous is not None and stamp <= previous):
56
+ raise ValueError('Power samples require increasing finite times and nonnegative watts')
57
+ previous = stamp
58
+ if self.proxy_watts is not None:
59
+ if isinstance(self.proxy_watts, bool) or not math.isfinite(self.proxy_watts) or self.proxy_watts < 0 or not self.proxy_source or not self.proxy_version:
60
+ raise ValueError('Power proxy requires nonnegative watts, source and version')
61
+ if self.proxy_method not in {'static_device_class_proxy', 'observed_power_proxy'}:
62
+ raise ValueError('Unknown power proxy method')
63
+ for n in [self.request_count, self.input_tokens, self.output_tokens]:
64
+ if n is not None and (isinstance(n, bool) or not isinstance(n, int) or n < 0):
65
+ raise ValueError('Activity counters must be nonnegative integers or unknown')
66
+
67
+ @classmethod
68
+ def from_dict(cls, values: dict) -> UsageInterval:
69
+ data = dict(values)
70
+ data['gpu_uuids'] = tuple(data.get('gpu_uuids') or ())
71
+ data['samples'] = tuple(tuple(row) for row in data.get('samples') or ())
72
+ record = cls(**data)
73
+ record.validate()
74
+ return record
75
+
76
+
77
+ def energy(record: UsageInterval) -> dict:
78
+ """Clip trapezoids to the interval and leave large/unbounded gaps unknown."""
79
+ record.validate()
80
+ duration = record.end - record.start
81
+ measured = coverage = 0.0
82
+ for (t0, p0), (t1, p1) in zip(record.samples, record.samples[1:]):
83
+ if t1 - t0 > record.max_sample_gap:
84
+ continue
85
+ a, b = max(t0, record.start), min(t1, record.end)
86
+ if b <= a:
87
+ continue
88
+ pa = p0 + (p1 - p0) * (a - t0) / (t1 - t0)
89
+ pb = p0 + (p1 - p0) * (b - t0) / (t1 - t0)
90
+ measured += (pa + pb) * 0.5 * (b - a)
91
+ coverage += b - a
92
+ missing = max(0.0, duration - coverage)
93
+ estimated = missing * record.gpu_count * record.proxy_watts if record.proxy_watts is not None else None
94
+ complete = missing <= duration * 1e-12
95
+ method = ('measured' if complete else 'mixed' if coverage and estimated is not None
96
+ else 'measured_partial' if coverage else record.proxy_method if estimated is not None else 'resource_time_only')
97
+ total = measured + (estimated or 0) if coverage or estimated is not None else None
98
+ return {'gpu_seconds': duration * record.gpu_count,
99
+ 'gpu_hours': duration * record.gpu_count / 3600,
100
+ 'energy_joules': total, 'energy_wh': total / 3600 if total is not None else None,
101
+ 'measured_joules': measured if coverage else None, 'estimated_joules': estimated,
102
+ 'method': method, 'coverage': coverage / duration,
103
+ 'unmeasured_seconds': missing, 'is_complete': complete or estimated is not None,
104
+ 'source': record.source, 'proxy_source': record.proxy_source,
105
+ 'proxy_version': record.proxy_version, 'proxy_watts': record.proxy_watts,
106
+ 'lease_attributed_energy': None}
107
+
108
+
109
+ class UsageStore:
110
+ """Append-only accounting, separate from lease/desired-state authority."""
111
+
112
+ def __init__(self, path: str | Path, *, readonly=False):
113
+ self.path = Path(path)
114
+ if readonly:
115
+ from urllib.parse import quote
116
+ self.connection = sqlite3.connect('file:' + quote(str(self.path.resolve())) + '?mode=ro', uri=True)
117
+ return
118
+ self.path.parent.mkdir(parents=True, exist_ok=True)
119
+ self.connection = sqlite3.connect(self.path)
120
+ self.connection.execute('CREATE TABLE IF NOT EXISTS usage (id TEXT PRIMARY KEY, start REAL NOT NULL, end REAL NOT NULL, node TEXT NOT NULL, replica TEXT NOT NULL, facts TEXT NOT NULL)')
121
+ self.connection.commit()
122
+
123
+ def close(self):
124
+ self.connection.close()
125
+
126
+ def append(self, record: UsageInterval) -> bool:
127
+ """Identical retries are no-ops; changed IDs or overlaps fail atomically."""
128
+ record.validate()
129
+ facts = json.dumps(asdict(record), sort_keys=True)
130
+ try:
131
+ self.connection.execute('BEGIN IMMEDIATE')
132
+ existing = self.connection.execute('SELECT facts FROM usage WHERE id=?', (record.id,)).fetchone()
133
+ if existing:
134
+ if existing[0] != facts:
135
+ raise ValueError('Usage ID already records different immutable facts')
136
+ self.connection.commit()
137
+ return False
138
+ rows = self.connection.execute('SELECT facts FROM usage WHERE node=? AND start < ? AND end > ?', (record.node, record.end, record.start))
139
+ for row in rows:
140
+ other = UsageInterval.from_dict(json.loads(row[0]))
141
+ if other.replica == record.replica or set(other.gpu_uuids) & set(record.gpu_uuids):
142
+ raise ValueError('Overlapping accounting would double count a replica or GPU')
143
+ self.connection.execute('INSERT INTO usage VALUES (?, ?, ?, ?, ?, ?)',
144
+ (record.id, record.start, record.end, record.node, record.replica, facts))
145
+ self.connection.commit()
146
+ return True
147
+ except BaseException:
148
+ self.connection.rollback()
149
+ raise
150
+
151
+ def records(self) -> list[UsageInterval]:
152
+ return [UsageInterval.from_dict(json.loads(row[0])) for row in
153
+ self.connection.execute('SELECT facts FROM usage ORDER BY start, id')]
@@ -0,0 +1,3 @@
1
+ from .kubeai import KubeaiBackend
2
+
3
+ __all__ = ['KubeaiBackend']