acprof 0.3.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.
Files changed (704) hide show
  1. acprof/__init__.py +3 -0
  2. acprof/__main__.py +5 -0
  3. acprof/_bundle/.dockerignore +20 -0
  4. acprof/_bundle/LICENSE +202 -0
  5. acprof/_bundle/NOTICE +43 -0
  6. acprof/_bundle/acprof/__init__.py +3 -0
  7. acprof/_bundle/acprof/__main__.py +5 -0
  8. acprof/_bundle/acprof/analysis/__init__.py +1 -0
  9. acprof/_bundle/acprof/analysis/audit.py +276 -0
  10. acprof/_bundle/acprof/analysis/comparison.py +364 -0
  11. acprof/_bundle/acprof/analysis/compatibility.py +223 -0
  12. acprof/_bundle/acprof/analysis/conditions.py +185 -0
  13. acprof/_bundle/acprof/analysis/independent_comparison.py +191 -0
  14. acprof/_bundle/acprof/analysis/latency_model.py +1106 -0
  15. acprof/_bundle/acprof/analysis/latency_report.py +577 -0
  16. acprof/_bundle/acprof/analysis/model.py +276 -0
  17. acprof/_bundle/acprof/analysis/precision.py +51 -0
  18. acprof/_bundle/acprof/analysis/uncertainty.py +144 -0
  19. acprof/_bundle/acprof/application/__init__.py +1 -0
  20. acprof/_bundle/acprof/application/download.py +14 -0
  21. acprof/_bundle/acprof/application/errors.py +5 -0
  22. acprof/_bundle/acprof/application/notifications.py +302 -0
  23. acprof/_bundle/acprof/application/preparation.py +333 -0
  24. acprof/_bundle/acprof/application/resources.py +66 -0
  25. acprof/_bundle/acprof/application/run.py +462 -0
  26. acprof/_bundle/acprof/application/terminal_log.py +136 -0
  27. acprof/_bundle/acprof/artifact_layout.py +261 -0
  28. acprof/_bundle/acprof/artifacts.py +161 -0
  29. acprof/_bundle/acprof/capabilities.py +404 -0
  30. acprof/_bundle/acprof/cli/__init__.py +1 -0
  31. acprof/_bundle/acprof/cli/audit.py +74 -0
  32. acprof/_bundle/acprof/cli/auto.py +41 -0
  33. acprof/_bundle/acprof/cli/backfill_compute.py +498 -0
  34. acprof/_bundle/acprof/cli/compare.py +34 -0
  35. acprof/_bundle/acprof/cli/coverage.py +70 -0
  36. acprof/_bundle/acprof/cli/doctor.py +47 -0
  37. acprof/_bundle/acprof/cli/inspect.py +101 -0
  38. acprof/_bundle/acprof/cli/load.py +190 -0
  39. acprof/_bundle/acprof/cli/main.py +64 -0
  40. acprof/_bundle/acprof/cli/model_store.py +22 -0
  41. acprof/_bundle/acprof/cli/plot.py +211 -0
  42. acprof/_bundle/acprof/cli/posthoc.py +113 -0
  43. acprof/_bundle/acprof/cli/probe.py +186 -0
  44. acprof/_bundle/acprof/cli/report.py +35 -0
  45. acprof/_bundle/acprof/cli/results.py +37 -0
  46. acprof/_bundle/acprof/cli/run.py +54 -0
  47. acprof/_bundle/acprof/cli/stats.py +94 -0
  48. acprof/_bundle/acprof/cli/tui.py +65 -0
  49. acprof/_bundle/acprof/config.py +177 -0
  50. acprof/_bundle/acprof/container/__init__.py +1 -0
  51. acprof/_bundle/acprof/container/compat/__init__.py +1 -0
  52. acprof/_bundle/acprof/container/compat/transformers_dynamic.py +54 -0
  53. acprof/_bundle/acprof/container/compat/transformers_model_types.json +1091 -0
  54. acprof/_bundle/acprof/container/compute_profile_runner.py +392 -0
  55. acprof/_bundle/acprof/container/download_model.py +165 -0
  56. acprof/_bundle/acprof/container/execution.py +73 -0
  57. acprof/_bundle/acprof/container/handlers/__init__.py +298 -0
  58. acprof/_bundle/acprof/container/handlers/audio.py +743 -0
  59. acprof/_bundle/acprof/container/handlers/custom_pipeline.py +74 -0
  60. acprof/_bundle/acprof/container/handlers/cv.py +321 -0
  61. acprof/_bundle/acprof/container/handlers/diffusion.py +728 -0
  62. acprof/_bundle/acprof/container/handlers/moss.py +64 -0
  63. acprof/_bundle/acprof/container/handlers/multimodal.py +609 -0
  64. acprof/_bundle/acprof/container/handlers/nlp.py +747 -0
  65. acprof/_bundle/acprof/container/handlers/onnx_tasks.py +231 -0
  66. acprof/_bundle/acprof/container/handlers/onnxruntime.py +90 -0
  67. acprof/_bundle/acprof/container/handlers/structured.py +185 -0
  68. acprof/_bundle/acprof/container/handlers/timeseries.py +178 -0
  69. acprof/_bundle/acprof/container/load_policy.py +81 -0
  70. acprof/_bundle/acprof/container/loading_quality.py +48 -0
  71. acprof/_bundle/acprof/container/local_pipeline.py +31 -0
  72. acprof/_bundle/acprof/container/model_files.py +280 -0
  73. acprof/_bundle/acprof/container/model_probe.py +80 -0
  74. acprof/_bundle/acprof/container/onnx_session.py +150 -0
  75. acprof/_bundle/acprof/container/runtime_manifest.py +150 -0
  76. acprof/_bundle/acprof/container/runtime_validate.py +156 -0
  77. acprof/_bundle/acprof/container/server.py +209 -0
  78. acprof/_bundle/acprof/container/torch_execution.py +55 -0
  79. acprof/_bundle/acprof/container/validation.py +172 -0
  80. acprof/_bundle/acprof/cpu_affinity.py +35 -0
  81. acprof/_bundle/acprof/dependency_locks.py +129 -0
  82. acprof/_bundle/acprof/experiment.py +356 -0
  83. acprof/_bundle/acprof/extensions/__init__.py +294 -0
  84. acprof/_bundle/acprof/extensions/builtin/manifest.json +3591 -0
  85. acprof/_bundle/acprof/extensions/onnxruntime/manifest.json +191 -0
  86. acprof/_bundle/acprof/extensions/schema.py +238 -0
  87. acprof/_bundle/acprof/extensions/transformers/4.57.6.json +1639 -0
  88. acprof/_bundle/acprof/extensions/transformers/5.10.4.json +1812 -0
  89. acprof/_bundle/acprof/failures.py +115 -0
  90. acprof/_bundle/acprof/hardware_conditions.py +18 -0
  91. acprof/_bundle/acprof/hf_download.py +143 -0
  92. acprof/_bundle/acprof/hf_endpoints.py +62 -0
  93. acprof/_bundle/acprof/hf_transport.py +238 -0
  94. acprof/_bundle/acprof/host/__init__.py +1 -0
  95. acprof/_bundle/acprof/host/automation.py +161 -0
  96. acprof/_bundle/acprof/host/client.py +520 -0
  97. acprof/_bundle/acprof/host/collection_history.py +77 -0
  98. acprof/_bundle/acprof/host/collection_workflow.py +285 -0
  99. acprof/_bundle/acprof/host/command.py +119 -0
  100. acprof/_bundle/acprof/host/container_lifecycle.py +225 -0
  101. acprof/_bundle/acprof/host/container_state.py +128 -0
  102. acprof/_bundle/acprof/host/coverage_state.py +259 -0
  103. acprof/_bundle/acprof/host/detect.py +669 -0
  104. acprof/_bundle/acprof/host/docker_runtime.py +359 -0
  105. acprof/_bundle/acprof/host/doctor.py +158 -0
  106. acprof/_bundle/acprof/host/env_utils.py +233 -0
  107. acprof/_bundle/acprof/host/execution_conditions.py +87 -0
  108. acprof/_bundle/acprof/host/gpu_device.py +66 -0
  109. acprof/_bundle/acprof/host/hardware_conditions.py +130 -0
  110. acprof/_bundle/acprof/host/images/__init__.py +1 -0
  111. acprof/_bundle/acprof/host/images/dependencies.py +169 -0
  112. acprof/_bundle/acprof/host/images/environment.py +313 -0
  113. acprof/_bundle/acprof/host/images/graph.py +143 -0
  114. acprof/_bundle/acprof/host/images/identity.py +6 -0
  115. acprof/_bundle/acprof/host/images/inventory.py +445 -0
  116. acprof/_bundle/acprof/host/images/runtime.py +457 -0
  117. acprof/_bundle/acprof/host/images/scan.py +154 -0
  118. acprof/_bundle/acprof/host/input_plan.py +1056 -0
  119. acprof/_bundle/acprof/host/interface_probe.py +141 -0
  120. acprof/_bundle/acprof/host/largest_scale_probe.py +566 -0
  121. acprof/_bundle/acprof/host/matrix_plan.py +98 -0
  122. acprof/_bundle/acprof/host/measurement/__init__.py +1 -0
  123. acprof/_bundle/acprof/host/measurement/boundary.py +162 -0
  124. acprof/_bundle/acprof/host/measurement/capture.py +139 -0
  125. acprof/_bundle/acprof/host/measurement/checkpoint.py +275 -0
  126. acprof/_bundle/acprof/host/measurement/config.py +212 -0
  127. acprof/_bundle/acprof/host/measurement/diagnostics.py +247 -0
  128. acprof/_bundle/acprof/host/measurement/energy_validation.py +172 -0
  129. acprof/_bundle/acprof/host/measurement/errors.py +25 -0
  130. acprof/_bundle/acprof/host/measurement/execution.py +396 -0
  131. acprof/_bundle/acprof/host/measurement/load.py +237 -0
  132. acprof/_bundle/acprof/host/measurement/metrics.py +975 -0
  133. acprof/_bundle/acprof/host/measurement/monitors.py +143 -0
  134. acprof/_bundle/acprof/host/measurement/publication.py +171 -0
  135. acprof/_bundle/acprof/host/measurement/requests.py +97 -0
  136. acprof/_bundle/acprof/host/measurement/types.py +82 -0
  137. acprof/_bundle/acprof/host/model_coverage.py +337 -0
  138. acprof/_bundle/acprof/host/model_errors.py +116 -0
  139. acprof/_bundle/acprof/host/model_inspection.py +107 -0
  140. acprof/_bundle/acprof/host/model_schema.py +35 -0
  141. acprof/_bundle/acprof/host/model_store.py +733 -0
  142. acprof/_bundle/acprof/host/network_preflight.py +229 -0
  143. acprof/_bundle/acprof/host/orchestrator.py +1133 -0
  144. acprof/_bundle/acprof/host/permissions.py +117 -0
  145. acprof/_bundle/acprof/host/platform_metadata.py +63 -0
  146. acprof/_bundle/acprof/host/posthoc/__init__.py +12 -0
  147. acprof/_bundle/acprof/host/posthoc/backfill.py +415 -0
  148. acprof/_bundle/acprof/host/posthoc/context.py +400 -0
  149. acprof/_bundle/acprof/host/posthoc/plans.py +597 -0
  150. acprof/_bundle/acprof/host/posthoc/service.py +303 -0
  151. acprof/_bundle/acprof/host/posthoc/storage.py +491 -0
  152. acprof/_bundle/acprof/host/preflight.py +370 -0
  153. acprof/_bundle/acprof/host/profiling/__init__.py +1 -0
  154. acprof/_bundle/acprof/host/profiling/compute.py +436 -0
  155. acprof/_bundle/acprof/host/profiling/compute_plan.py +261 -0
  156. acprof/_bundle/acprof/host/profiling/execution.py +547 -0
  157. acprof/_bundle/acprof/host/profiling/execution_plan.py +576 -0
  158. acprof/_bundle/acprof/host/profiling/progress.py +83 -0
  159. acprof/_bundle/acprof/host/profiling/support.py +252 -0
  160. acprof/_bundle/acprof/host/profiling/tools/__init__.py +1 -0
  161. acprof/_bundle/acprof/host/profiling/tools/advisor.py +164 -0
  162. acprof/_bundle/acprof/host/profiling/tools/compute_parsers.py +409 -0
  163. acprof/_bundle/acprof/host/profiling/tools/execution_environment.py +135 -0
  164. acprof/_bundle/acprof/host/profiling/tools/execution_parsers.py +364 -0
  165. acprof/_bundle/acprof/host/profiling/tools/massif.py +418 -0
  166. acprof/_bundle/acprof/host/profiling/tools/ncu.py +696 -0
  167. acprof/_bundle/acprof/host/profiling/tools/nsys.py +326 -0
  168. acprof/_bundle/acprof/host/profiling/tools/tool_discovery.py +229 -0
  169. acprof/_bundle/acprof/host/profiling/tools/torch.py +158 -0
  170. acprof/_bundle/acprof/host/result_cleanup.py +65 -0
  171. acprof/_bundle/acprof/host/run_state.py +639 -0
  172. acprof/_bundle/acprof/host/runtime_settings.py +10 -0
  173. acprof/_bundle/acprof/host/runtime_validation.py +302 -0
  174. acprof/_bundle/acprof/host/source_bundle.py +96 -0
  175. acprof/_bundle/acprof/host/startup_probe.py +95 -0
  176. acprof/_bundle/acprof/host/static_metadata.py +936 -0
  177. acprof/_bundle/acprof/host/task_support.py +121 -0
  178. acprof/_bundle/acprof/installation.py +26 -0
  179. acprof/_bundle/acprof/latency_slo.py +62 -0
  180. acprof/_bundle/acprof/messages.py +26 -0
  181. acprof/_bundle/acprof/metric_registry.py +315 -0
  182. acprof/_bundle/acprof/model_candidates.py +297 -0
  183. acprof/_bundle/acprof/model_contract.py +234 -0
  184. acprof/_bundle/acprof/model_dependencies.py +93 -0
  185. acprof/_bundle/acprof/model_dependency_domain.py +45 -0
  186. acprof/_bundle/acprof/model_dependency_eval.py +438 -0
  187. acprof/_bundle/acprof/model_dependency_flow.py +200 -0
  188. acprof/_bundle/acprof/model_evidence.py +115 -0
  189. acprof/_bundle/acprof/model_metadata_analysis.py +156 -0
  190. acprof/_bundle/acprof/model_repository.py +149 -0
  191. acprof/_bundle/acprof/model_resolution.py +129 -0
  192. acprof/_bundle/acprof/model_review.py +155 -0
  193. acprof/_bundle/acprof/model_source_analysis.py +299 -0
  194. acprof/_bundle/acprof/model_spec.py +204 -0
  195. acprof/_bundle/acprof/model_support.py +105 -0
  196. acprof/_bundle/acprof/model_transforms.py +81 -0
  197. acprof/_bundle/acprof/monitors/__init__.py +1 -0
  198. acprof/_bundle/acprof/monitors/common.py +63 -0
  199. acprof/_bundle/acprof/monitors/energy_cpu.py +651 -0
  200. acprof/_bundle/acprof/monitors/energy_nvml.py +381 -0
  201. acprof/_bundle/acprof/monitors/gpu_metrics.py +123 -0
  202. acprof/_bundle/acprof/monitors/interfaces.py +74 -0
  203. acprof/_bundle/acprof/monitors/perf_mips.py +617 -0
  204. acprof/_bundle/acprof/monitors/rapl_topology.py +100 -0
  205. acprof/_bundle/acprof/monitors/resource_metrics.py +472 -0
  206. acprof/_bundle/acprof/monitors/resource_readers.py +435 -0
  207. acprof/_bundle/acprof/monitors/resource_usage.py +450 -0
  208. acprof/_bundle/acprof/monitors/sampling.py +79 -0
  209. acprof/_bundle/acprof/network_policy.py +182 -0
  210. acprof/_bundle/acprof/notifications.py +279 -0
  211. acprof/_bundle/acprof/packet/__init__.py +1 -0
  212. acprof/_bundle/acprof/packet/merge_packet_latency.py +369 -0
  213. acprof/_bundle/acprof/packet/sniff_parse_pcap.py +240 -0
  214. acprof/_bundle/acprof/pixel_metrics.py +103 -0
  215. acprof/_bundle/acprof/platform.py +180 -0
  216. acprof/_bundle/acprof/plotting/__init__.py +1 -0
  217. acprof/_bundle/acprof/plotting/config.py +487 -0
  218. acprof/_bundle/acprof/plotting/data.py +236 -0
  219. acprof/_bundle/acprof/plotting/diagnostics.py +747 -0
  220. acprof/_bundle/acprof/plotting/latency.py +638 -0
  221. acprof/_bundle/acprof/plotting/metrics.py +648 -0
  222. acprof/_bundle/acprof/plotting/plotly-LICENSE.txt +21 -0
  223. acprof/_bundle/acprof/plotting/report.py +66 -0
  224. acprof/_bundle/acprof/plotting/styles.py +111 -0
  225. acprof/_bundle/acprof/precision.py +42 -0
  226. acprof/_bundle/acprof/preparation_events.py +78 -0
  227. acprof/_bundle/acprof/progress_events.py +105 -0
  228. acprof/_bundle/acprof/quality.py +153 -0
  229. acprof/_bundle/acprof/resource_budget.py +29 -0
  230. acprof/_bundle/acprof/result_csv.py +263 -0
  231. acprof/_bundle/acprof/result_layers.py +365 -0
  232. acprof/_bundle/acprof/run_args.py +223 -0
  233. acprof/_bundle/acprof/run_options.py +225 -0
  234. acprof/_bundle/acprof/runtime_dependencies.py +195 -0
  235. acprof/_bundle/acprof/runtime_profiles.py +258 -0
  236. acprof/_bundle/acprof/runtime_settings.py +72 -0
  237. acprof/_bundle/acprof/source_identity.py +68 -0
  238. acprof/_bundle/acprof/telemetry.py +225 -0
  239. acprof/_bundle/acprof/testing/__init__.py +1 -0
  240. acprof/_bundle/acprof/testing/evidence.py +117 -0
  241. acprof/_bundle/acprof/testing/plugin.py +126 -0
  242. acprof/_bundle/acprof/testing/provenance.py +53 -0
  243. acprof/_bundle/acprof/testing/sharding.py +14 -0
  244. acprof/_bundle/acprof/tui/__init__.py +1 -0
  245. acprof/_bundle/acprof/tui/app.py +934 -0
  246. acprof/_bundle/acprof/tui/app_contracts.py +43 -0
  247. acprof/_bundle/acprof/tui/catalog_controller.py +120 -0
  248. acprof/_bundle/acprof/tui/commands.py +209 -0
  249. acprof/_bundle/acprof/tui/configuration_controller.py +436 -0
  250. acprof/_bundle/acprof/tui/diagnostics.py +340 -0
  251. acprof/_bundle/acprof/tui/downloads.py +56 -0
  252. acprof/_bundle/acprof/tui/environment.py +248 -0
  253. acprof/_bundle/acprof/tui/experiment_catalog.py +279 -0
  254. acprof/_bundle/acprof/tui/experiment_controller.py +132 -0
  255. acprof/_bundle/acprof/tui/experiment_picker.py +273 -0
  256. acprof/_bundle/acprof/tui/field_validation.py +62 -0
  257. acprof/_bundle/acprof/tui/i18n.py +57 -0
  258. acprof/_bundle/acprof/tui/image_controller.py +525 -0
  259. acprof/_bundle/acprof/tui/images.py +737 -0
  260. acprof/_bundle/acprof/tui/input.py +191 -0
  261. acprof/_bundle/acprof/tui/localization_controller.py +110 -0
  262. acprof/_bundle/acprof/tui/log.py +310 -0
  263. acprof/_bundle/acprof/tui/model_candidates.py +278 -0
  264. acprof/_bundle/acprof/tui/model_controller.py +111 -0
  265. acprof/_bundle/acprof/tui/model_input.py +12 -0
  266. acprof/_bundle/acprof/tui/model_store.py +166 -0
  267. acprof/_bundle/acprof/tui/preflight_controller.py +271 -0
  268. acprof/_bundle/acprof/tui/preparation.py +269 -0
  269. acprof/_bundle/acprof/tui/presentation.py +46 -0
  270. acprof/_bundle/acprof/tui/process.py +111 -0
  271. acprof/_bundle/acprof/tui/process_controller.py +218 -0
  272. acprof/_bundle/acprof/tui/profile_controller.py +109 -0
  273. acprof/_bundle/acprof/tui/progress.py +195 -0
  274. acprof/_bundle/acprof/tui/recovery.py +114 -0
  275. acprof/_bundle/acprof/tui/recovery_controller.py +169 -0
  276. acprof/_bundle/acprof/tui/rendering.py +75 -0
  277. acprof/_bundle/acprof/tui/reports.py +303 -0
  278. acprof/_bundle/acprof/tui/result_controller.py +279 -0
  279. acprof/_bundle/acprof/tui/review_inputs.py +54 -0
  280. acprof/_bundle/acprof/tui/run_form.py +125 -0
  281. acprof/_bundle/acprof/tui/run_planning.py +97 -0
  282. acprof/_bundle/acprof/tui/run_results.py +175 -0
  283. acprof/_bundle/acprof/tui/scrollbar.py +65 -0
  284. acprof/_bundle/acprof/tui/settings.py +203 -0
  285. acprof/_bundle/acprof/tui/slash_controller.py +95 -0
  286. acprof/_bundle/acprof/tui/stages.py +97 -0
  287. acprof/_bundle/acprof/tui/storage.py +150 -0
  288. acprof/_bundle/acprof/tui/table.py +213 -0
  289. acprof/_bundle/acprof/tui/themes.py +112 -0
  290. acprof/_bundle/acprof/tui/translation_catalog.py +1861 -0
  291. acprof/_bundle/acprof/tui/tui.tcss +373 -0
  292. acprof/_bundle/acprof/tui/views.py +706 -0
  293. acprof/_bundle/acprof/window_records.py +165 -0
  294. acprof/_bundle/acprof/workloads/__init__.py +222 -0
  295. acprof/_bundle/acprof/workloads/audio.py +621 -0
  296. acprof/_bundle/acprof/workloads/contract.py +116 -0
  297. acprof/_bundle/acprof/workloads/cv.py +240 -0
  298. acprof/_bundle/acprof/workloads/diffusion.py +410 -0
  299. acprof/_bundle/acprof/workloads/multimodal.py +329 -0
  300. acprof/_bundle/acprof/workloads/nlp.py +151 -0
  301. acprof/_bundle/acprof/workloads/structured.py +151 -0
  302. acprof/_bundle/acprof/workloads/timeseries.py +69 -0
  303. acprof/_bundle/assets/audio/librispeech-clean-test-en-30s/audio.wav +0 -0
  304. acprof/_bundle/assets/audio/librispeech-clean-test-en-30s/source.json +81 -0
  305. acprof/_bundle/dockerfiles/environment_tools.py +314 -0
  306. acprof/_bundle/dockerfiles/locks/audio-cpu.artifacts.json +503 -0
  307. acprof/_bundle/dockerfiles/locks/audio-cpu.txt +143 -0
  308. acprof/_bundle/dockerfiles/locks/audio-cu124.artifacts.json +600 -0
  309. acprof/_bundle/dockerfiles/locks/audio-cu124.txt +171 -0
  310. acprof/_bundle/dockerfiles/locks/audio-cu128.artifacts.json +544 -0
  311. acprof/_bundle/dockerfiles/locks/audio-cu128.txt +155 -0
  312. acprof/_bundle/dockerfiles/locks/custom-multimodal-cpu.artifacts.json +510 -0
  313. acprof/_bundle/dockerfiles/locks/custom-multimodal-cpu.txt +145 -0
  314. acprof/_bundle/dockerfiles/locks/custom-multimodal-cu124.artifacts.json +607 -0
  315. acprof/_bundle/dockerfiles/locks/custom-multimodal-cu124.txt +173 -0
  316. acprof/_bundle/dockerfiles/locks/custom-multimodal-cu128.artifacts.json +642 -0
  317. acprof/_bundle/dockerfiles/locks/custom-multimodal-cu128.txt +183 -0
  318. acprof/_bundle/dockerfiles/locks/cv-cpu.artifacts.json +279 -0
  319. acprof/_bundle/dockerfiles/locks/cv-cpu.txt +79 -0
  320. acprof/_bundle/dockerfiles/locks/cv-cu124.artifacts.json +376 -0
  321. acprof/_bundle/dockerfiles/locks/cv-cu124.txt +107 -0
  322. acprof/_bundle/dockerfiles/locks/cv-cu128.artifacts.json +411 -0
  323. acprof/_bundle/dockerfiles/locks/cv-cu128.txt +117 -0
  324. acprof/_bundle/dockerfiles/locks/diffusion-cpu.artifacts.json +335 -0
  325. acprof/_bundle/dockerfiles/locks/diffusion-cpu.txt +95 -0
  326. acprof/_bundle/dockerfiles/locks/diffusion-cu124.artifacts.json +432 -0
  327. acprof/_bundle/dockerfiles/locks/diffusion-cu124.txt +123 -0
  328. acprof/_bundle/dockerfiles/locks/diffusion-cu128.artifacts.json +467 -0
  329. acprof/_bundle/dockerfiles/locks/diffusion-cu128.txt +133 -0
  330. acprof/_bundle/dockerfiles/locks/moss-transformers5104.artifacts.json +621 -0
  331. acprof/_bundle/dockerfiles/locks/moss-transformers5104.txt +177 -0
  332. acprof/_bundle/dockerfiles/locks/multimodal-transformers4576.artifacts.json +635 -0
  333. acprof/_bundle/dockerfiles/locks/multimodal-transformers4576.txt +181 -0
  334. acprof/_bundle/dockerfiles/locks/nlp-cpu.artifacts.json +363 -0
  335. acprof/_bundle/dockerfiles/locks/nlp-cpu.txt +103 -0
  336. acprof/_bundle/dockerfiles/locks/nlp-cu124.artifacts.json +460 -0
  337. acprof/_bundle/dockerfiles/locks/nlp-cu124.txt +131 -0
  338. acprof/_bundle/dockerfiles/locks/nlp-cu128.artifacts.json +495 -0
  339. acprof/_bundle/dockerfiles/locks/nlp-cu128.txt +141 -0
  340. acprof/_bundle/dockerfiles/locks/onnxruntime-cpu.artifacts.json +261 -0
  341. acprof/_bundle/dockerfiles/locks/onnxruntime-cpu.txt +73 -0
  342. acprof/_bundle/dockerfiles/locks/platform-cpu.artifacts.json +99 -0
  343. acprof/_bundle/dockerfiles/locks/platform-cpu.txt +27 -0
  344. acprof/_bundle/dockerfiles/locks/platform-cu124.artifacts.json +196 -0
  345. acprof/_bundle/dockerfiles/locks/platform-cu124.txt +55 -0
  346. acprof/_bundle/dockerfiles/locks/platform-cu128.artifacts.json +231 -0
  347. acprof/_bundle/dockerfiles/locks/platform-cu128.txt +65 -0
  348. acprof/_bundle/dockerfiles/locks/platform-python-cpu.artifacts.json +37 -0
  349. acprof/_bundle/dockerfiles/locks/platform-python-cpu.txt +9 -0
  350. acprof/_bundle/dockerfiles/locks/structured-cpu.artifacts.json +279 -0
  351. acprof/_bundle/dockerfiles/locks/structured-cpu.txt +79 -0
  352. acprof/_bundle/dockerfiles/locks/structured-cu124.artifacts.json +376 -0
  353. acprof/_bundle/dockerfiles/locks/structured-cu124.txt +107 -0
  354. acprof/_bundle/dockerfiles/locks/structured-cu128.artifacts.json +411 -0
  355. acprof/_bundle/dockerfiles/locks/structured-cu128.txt +117 -0
  356. acprof/_bundle/dockerfiles/locks/system-trixie-amd64.json +620 -0
  357. acprof/_bundle/dockerfiles/locks/timeseries-cpu.artifacts.json +314 -0
  358. acprof/_bundle/dockerfiles/locks/timeseries-cpu.txt +89 -0
  359. acprof/_bundle/dockerfiles/locks/timeseries-cu124.artifacts.json +411 -0
  360. acprof/_bundle/dockerfiles/locks/timeseries-cu124.txt +117 -0
  361. acprof/_bundle/dockerfiles/locks/timeseries-cu128.artifacts.json +446 -0
  362. acprof/_bundle/dockerfiles/locks/timeseries-cu128.txt +127 -0
  363. acprof/_bundle/dockerfiles/locks/transformers5104-cpu.artifacts.json +594 -0
  364. acprof/_bundle/dockerfiles/locks/transformers5104-cpu.txt +169 -0
  365. acprof/_bundle/dockerfiles/locks/transformers5104-cu124.artifacts.json +691 -0
  366. acprof/_bundle/dockerfiles/locks/transformers5104-cu124.txt +197 -0
  367. acprof/_bundle/dockerfiles/locks/transformers5104-cu128.artifacts.json +726 -0
  368. acprof/_bundle/dockerfiles/locks/transformers5104-cu128.txt +207 -0
  369. acprof/_bundle/dockerfiles/platform.Dockerfile +22 -0
  370. acprof/_bundle/dockerfiles/requirements/audio.in +5 -0
  371. acprof/_bundle/dockerfiles/requirements/custom-multimodal.in +2 -0
  372. acprof/_bundle/dockerfiles/requirements/cv.in +4 -0
  373. acprof/_bundle/dockerfiles/requirements/diffusion.in +6 -0
  374. acprof/_bundle/dockerfiles/requirements/moss-transformers5104.in +9 -0
  375. acprof/_bundle/dockerfiles/requirements/multimodal-transformers4576.in +3 -0
  376. acprof/_bundle/dockerfiles/requirements/nlp.in +7 -0
  377. acprof/_bundle/dockerfiles/requirements/onnxruntime.in +9 -0
  378. acprof/_bundle/dockerfiles/requirements/service.in +8 -0
  379. acprof/_bundle/dockerfiles/requirements/structured.in +4 -0
  380. acprof/_bundle/dockerfiles/requirements/timeseries.in +2 -0
  381. acprof/_bundle/dockerfiles/requirements/timm.in +1 -0
  382. acprof/_bundle/dockerfiles/requirements/transformers5104.in +4 -0
  383. acprof/_bundle/dockerfiles/runtime-final.Dockerfile +34 -0
  384. acprof/_bundle/dockerfiles/runtime-model.Dockerfile +19 -0
  385. acprof/_bundle/dockerfiles/runtime.Dockerfile +23 -0
  386. acprof/_bundle/examples/coverage/regression.json +17 -0
  387. acprof/_bundle/examples/hardware-validation.json +19 -0
  388. acprof/_bundle/examples/multimodal/ultravox.model.json +29 -0
  389. acprof/_bundle/examples/nlp/smoke.py +111 -0
  390. acprof/_bundle/examples/onnxruntime/fixtures.py +164 -0
  391. acprof/_bundle/examples/onnxruntime/iris.json +16 -0
  392. acprof/_bundle/examples/onnxruntime/iris.model.json +7 -0
  393. acprof/_bundle/examples/onnxruntime/real_models.py +155 -0
  394. acprof/_bundle/examples/onnxruntime/smoke.py +68 -0
  395. acprof/_bundle/examples/structured/chronos_smoke.py +56 -0
  396. acprof/_bundle/examples/structured/export_models.py +71 -0
  397. acprof/_bundle/examples/structured/smoke.py +71 -0
  398. acprof/_bundle/licenses/CC-BY-4.0.txt +156 -0
  399. acprof/analysis/__init__.py +1 -0
  400. acprof/analysis/audit.py +276 -0
  401. acprof/analysis/comparison.py +364 -0
  402. acprof/analysis/compatibility.py +223 -0
  403. acprof/analysis/conditions.py +185 -0
  404. acprof/analysis/independent_comparison.py +191 -0
  405. acprof/analysis/latency_model.py +1106 -0
  406. acprof/analysis/latency_report.py +577 -0
  407. acprof/analysis/model.py +276 -0
  408. acprof/analysis/precision.py +51 -0
  409. acprof/analysis/uncertainty.py +144 -0
  410. acprof/application/__init__.py +1 -0
  411. acprof/application/download.py +14 -0
  412. acprof/application/errors.py +5 -0
  413. acprof/application/notifications.py +302 -0
  414. acprof/application/preparation.py +333 -0
  415. acprof/application/resources.py +66 -0
  416. acprof/application/run.py +462 -0
  417. acprof/application/terminal_log.py +136 -0
  418. acprof/artifact_layout.py +261 -0
  419. acprof/artifacts.py +161 -0
  420. acprof/capabilities.py +404 -0
  421. acprof/cli/__init__.py +1 -0
  422. acprof/cli/audit.py +74 -0
  423. acprof/cli/auto.py +41 -0
  424. acprof/cli/backfill_compute.py +498 -0
  425. acprof/cli/compare.py +34 -0
  426. acprof/cli/coverage.py +70 -0
  427. acprof/cli/doctor.py +47 -0
  428. acprof/cli/inspect.py +101 -0
  429. acprof/cli/load.py +190 -0
  430. acprof/cli/main.py +64 -0
  431. acprof/cli/model_store.py +22 -0
  432. acprof/cli/plot.py +211 -0
  433. acprof/cli/posthoc.py +113 -0
  434. acprof/cli/probe.py +186 -0
  435. acprof/cli/report.py +35 -0
  436. acprof/cli/results.py +37 -0
  437. acprof/cli/run.py +54 -0
  438. acprof/cli/stats.py +94 -0
  439. acprof/cli/tui.py +65 -0
  440. acprof/config.py +177 -0
  441. acprof/container/__init__.py +1 -0
  442. acprof/container/compat/__init__.py +1 -0
  443. acprof/container/compat/transformers_dynamic.py +54 -0
  444. acprof/container/compat/transformers_model_types.json +1091 -0
  445. acprof/container/compute_profile_runner.py +392 -0
  446. acprof/container/download_model.py +165 -0
  447. acprof/container/execution.py +73 -0
  448. acprof/container/handlers/__init__.py +298 -0
  449. acprof/container/handlers/audio.py +743 -0
  450. acprof/container/handlers/custom_pipeline.py +74 -0
  451. acprof/container/handlers/cv.py +321 -0
  452. acprof/container/handlers/diffusion.py +728 -0
  453. acprof/container/handlers/moss.py +64 -0
  454. acprof/container/handlers/multimodal.py +609 -0
  455. acprof/container/handlers/nlp.py +747 -0
  456. acprof/container/handlers/onnx_tasks.py +231 -0
  457. acprof/container/handlers/onnxruntime.py +90 -0
  458. acprof/container/handlers/structured.py +185 -0
  459. acprof/container/handlers/timeseries.py +178 -0
  460. acprof/container/load_policy.py +81 -0
  461. acprof/container/loading_quality.py +48 -0
  462. acprof/container/local_pipeline.py +31 -0
  463. acprof/container/model_files.py +280 -0
  464. acprof/container/model_probe.py +80 -0
  465. acprof/container/onnx_session.py +150 -0
  466. acprof/container/runtime_manifest.py +150 -0
  467. acprof/container/runtime_validate.py +156 -0
  468. acprof/container/server.py +209 -0
  469. acprof/container/torch_execution.py +55 -0
  470. acprof/container/validation.py +172 -0
  471. acprof/cpu_affinity.py +35 -0
  472. acprof/dependency_locks.py +129 -0
  473. acprof/experiment.py +356 -0
  474. acprof/extensions/__init__.py +294 -0
  475. acprof/extensions/builtin/manifest.json +3591 -0
  476. acprof/extensions/onnxruntime/manifest.json +191 -0
  477. acprof/extensions/schema.py +238 -0
  478. acprof/extensions/transformers/4.57.6.json +1639 -0
  479. acprof/extensions/transformers/5.10.4.json +1812 -0
  480. acprof/failures.py +115 -0
  481. acprof/hardware_conditions.py +18 -0
  482. acprof/hf_download.py +143 -0
  483. acprof/hf_endpoints.py +62 -0
  484. acprof/hf_transport.py +238 -0
  485. acprof/host/__init__.py +1 -0
  486. acprof/host/automation.py +161 -0
  487. acprof/host/client.py +520 -0
  488. acprof/host/collection_history.py +77 -0
  489. acprof/host/collection_workflow.py +285 -0
  490. acprof/host/command.py +119 -0
  491. acprof/host/container_lifecycle.py +225 -0
  492. acprof/host/container_state.py +128 -0
  493. acprof/host/coverage_state.py +259 -0
  494. acprof/host/detect.py +669 -0
  495. acprof/host/docker_runtime.py +359 -0
  496. acprof/host/doctor.py +158 -0
  497. acprof/host/env_utils.py +233 -0
  498. acprof/host/execution_conditions.py +87 -0
  499. acprof/host/gpu_device.py +66 -0
  500. acprof/host/hardware_conditions.py +130 -0
  501. acprof/host/images/__init__.py +1 -0
  502. acprof/host/images/dependencies.py +169 -0
  503. acprof/host/images/environment.py +313 -0
  504. acprof/host/images/graph.py +143 -0
  505. acprof/host/images/identity.py +6 -0
  506. acprof/host/images/inventory.py +445 -0
  507. acprof/host/images/runtime.py +457 -0
  508. acprof/host/images/scan.py +154 -0
  509. acprof/host/input_plan.py +1056 -0
  510. acprof/host/interface_probe.py +141 -0
  511. acprof/host/largest_scale_probe.py +566 -0
  512. acprof/host/matrix_plan.py +98 -0
  513. acprof/host/measurement/__init__.py +1 -0
  514. acprof/host/measurement/boundary.py +162 -0
  515. acprof/host/measurement/capture.py +139 -0
  516. acprof/host/measurement/checkpoint.py +275 -0
  517. acprof/host/measurement/config.py +212 -0
  518. acprof/host/measurement/diagnostics.py +247 -0
  519. acprof/host/measurement/energy_validation.py +172 -0
  520. acprof/host/measurement/errors.py +25 -0
  521. acprof/host/measurement/execution.py +396 -0
  522. acprof/host/measurement/load.py +237 -0
  523. acprof/host/measurement/metrics.py +975 -0
  524. acprof/host/measurement/monitors.py +143 -0
  525. acprof/host/measurement/publication.py +171 -0
  526. acprof/host/measurement/requests.py +97 -0
  527. acprof/host/measurement/types.py +82 -0
  528. acprof/host/model_coverage.py +337 -0
  529. acprof/host/model_errors.py +116 -0
  530. acprof/host/model_inspection.py +107 -0
  531. acprof/host/model_schema.py +35 -0
  532. acprof/host/model_store.py +733 -0
  533. acprof/host/network_preflight.py +229 -0
  534. acprof/host/orchestrator.py +1133 -0
  535. acprof/host/permissions.py +117 -0
  536. acprof/host/platform_metadata.py +63 -0
  537. acprof/host/posthoc/__init__.py +12 -0
  538. acprof/host/posthoc/backfill.py +415 -0
  539. acprof/host/posthoc/context.py +400 -0
  540. acprof/host/posthoc/plans.py +597 -0
  541. acprof/host/posthoc/service.py +303 -0
  542. acprof/host/posthoc/storage.py +491 -0
  543. acprof/host/preflight.py +370 -0
  544. acprof/host/profiling/__init__.py +1 -0
  545. acprof/host/profiling/compute.py +436 -0
  546. acprof/host/profiling/compute_plan.py +261 -0
  547. acprof/host/profiling/execution.py +547 -0
  548. acprof/host/profiling/execution_plan.py +576 -0
  549. acprof/host/profiling/progress.py +83 -0
  550. acprof/host/profiling/support.py +252 -0
  551. acprof/host/profiling/tools/__init__.py +1 -0
  552. acprof/host/profiling/tools/advisor.py +164 -0
  553. acprof/host/profiling/tools/compute_parsers.py +409 -0
  554. acprof/host/profiling/tools/execution_environment.py +135 -0
  555. acprof/host/profiling/tools/execution_parsers.py +364 -0
  556. acprof/host/profiling/tools/massif.py +418 -0
  557. acprof/host/profiling/tools/ncu.py +696 -0
  558. acprof/host/profiling/tools/nsys.py +326 -0
  559. acprof/host/profiling/tools/tool_discovery.py +229 -0
  560. acprof/host/profiling/tools/torch.py +158 -0
  561. acprof/host/result_cleanup.py +65 -0
  562. acprof/host/run_state.py +639 -0
  563. acprof/host/runtime_settings.py +10 -0
  564. acprof/host/runtime_validation.py +302 -0
  565. acprof/host/source_bundle.py +96 -0
  566. acprof/host/startup_probe.py +95 -0
  567. acprof/host/static_metadata.py +936 -0
  568. acprof/host/task_support.py +121 -0
  569. acprof/installation.py +26 -0
  570. acprof/latency_slo.py +62 -0
  571. acprof/messages.py +26 -0
  572. acprof/metric_registry.py +315 -0
  573. acprof/model_candidates.py +297 -0
  574. acprof/model_contract.py +234 -0
  575. acprof/model_dependencies.py +93 -0
  576. acprof/model_dependency_domain.py +45 -0
  577. acprof/model_dependency_eval.py +438 -0
  578. acprof/model_dependency_flow.py +200 -0
  579. acprof/model_evidence.py +115 -0
  580. acprof/model_metadata_analysis.py +156 -0
  581. acprof/model_repository.py +149 -0
  582. acprof/model_resolution.py +129 -0
  583. acprof/model_review.py +155 -0
  584. acprof/model_source_analysis.py +299 -0
  585. acprof/model_spec.py +204 -0
  586. acprof/model_support.py +105 -0
  587. acprof/model_transforms.py +81 -0
  588. acprof/monitors/__init__.py +1 -0
  589. acprof/monitors/common.py +63 -0
  590. acprof/monitors/energy_cpu.py +651 -0
  591. acprof/monitors/energy_nvml.py +381 -0
  592. acprof/monitors/gpu_metrics.py +123 -0
  593. acprof/monitors/interfaces.py +74 -0
  594. acprof/monitors/perf_mips.py +617 -0
  595. acprof/monitors/rapl_topology.py +100 -0
  596. acprof/monitors/resource_metrics.py +472 -0
  597. acprof/monitors/resource_readers.py +435 -0
  598. acprof/monitors/resource_usage.py +450 -0
  599. acprof/monitors/sampling.py +79 -0
  600. acprof/network_policy.py +182 -0
  601. acprof/notifications.py +279 -0
  602. acprof/packet/__init__.py +1 -0
  603. acprof/packet/merge_packet_latency.py +369 -0
  604. acprof/packet/sniff_parse_pcap.py +240 -0
  605. acprof/pixel_metrics.py +103 -0
  606. acprof/platform.py +180 -0
  607. acprof/plotting/__init__.py +1 -0
  608. acprof/plotting/config.py +487 -0
  609. acprof/plotting/data.py +236 -0
  610. acprof/plotting/diagnostics.py +747 -0
  611. acprof/plotting/latency.py +638 -0
  612. acprof/plotting/metrics.py +648 -0
  613. acprof/plotting/plotly-LICENSE.txt +21 -0
  614. acprof/plotting/report.css +61 -0
  615. acprof/plotting/report.html +68 -0
  616. acprof/plotting/report.js +295 -0
  617. acprof/plotting/report.py +66 -0
  618. acprof/plotting/styles.py +111 -0
  619. acprof/plotting/view_model.js +145 -0
  620. acprof/precision.py +42 -0
  621. acprof/preparation_events.py +78 -0
  622. acprof/progress_events.py +105 -0
  623. acprof/quality.py +153 -0
  624. acprof/resource_budget.py +29 -0
  625. acprof/result_csv.py +263 -0
  626. acprof/result_layers.py +365 -0
  627. acprof/run_args.py +223 -0
  628. acprof/run_options.py +225 -0
  629. acprof/runtime_dependencies.py +195 -0
  630. acprof/runtime_profiles.py +258 -0
  631. acprof/runtime_settings.py +72 -0
  632. acprof/source_identity.py +68 -0
  633. acprof/telemetry.py +225 -0
  634. acprof/testing/__init__.py +1 -0
  635. acprof/testing/evidence.py +117 -0
  636. acprof/testing/plugin.py +126 -0
  637. acprof/testing/provenance.py +53 -0
  638. acprof/testing/sharding.py +14 -0
  639. acprof/tui/__init__.py +1 -0
  640. acprof/tui/app.py +934 -0
  641. acprof/tui/app_contracts.py +43 -0
  642. acprof/tui/catalog_controller.py +120 -0
  643. acprof/tui/commands.py +209 -0
  644. acprof/tui/configuration_controller.py +436 -0
  645. acprof/tui/diagnostics.py +340 -0
  646. acprof/tui/downloads.py +56 -0
  647. acprof/tui/environment.py +248 -0
  648. acprof/tui/experiment_catalog.py +279 -0
  649. acprof/tui/experiment_controller.py +132 -0
  650. acprof/tui/experiment_picker.py +273 -0
  651. acprof/tui/field_validation.py +62 -0
  652. acprof/tui/i18n.py +57 -0
  653. acprof/tui/image_controller.py +525 -0
  654. acprof/tui/images.py +737 -0
  655. acprof/tui/input.py +191 -0
  656. acprof/tui/localization_controller.py +110 -0
  657. acprof/tui/log.py +310 -0
  658. acprof/tui/model_candidates.py +278 -0
  659. acprof/tui/model_controller.py +111 -0
  660. acprof/tui/model_input.py +12 -0
  661. acprof/tui/model_store.py +166 -0
  662. acprof/tui/preflight_controller.py +271 -0
  663. acprof/tui/preparation.py +269 -0
  664. acprof/tui/presentation.py +46 -0
  665. acprof/tui/process.py +111 -0
  666. acprof/tui/process_controller.py +218 -0
  667. acprof/tui/profile_controller.py +109 -0
  668. acprof/tui/progress.py +195 -0
  669. acprof/tui/recovery.py +114 -0
  670. acprof/tui/recovery_controller.py +169 -0
  671. acprof/tui/rendering.py +75 -0
  672. acprof/tui/reports.py +303 -0
  673. acprof/tui/result_controller.py +279 -0
  674. acprof/tui/review_inputs.py +54 -0
  675. acprof/tui/run_form.py +125 -0
  676. acprof/tui/run_planning.py +97 -0
  677. acprof/tui/run_results.py +175 -0
  678. acprof/tui/scrollbar.py +65 -0
  679. acprof/tui/settings.py +203 -0
  680. acprof/tui/slash_controller.py +95 -0
  681. acprof/tui/stages.py +97 -0
  682. acprof/tui/storage.py +150 -0
  683. acprof/tui/table.py +213 -0
  684. acprof/tui/themes.py +112 -0
  685. acprof/tui/translation_catalog.py +1861 -0
  686. acprof/tui/tui.tcss +373 -0
  687. acprof/tui/views.py +706 -0
  688. acprof/window_records.py +165 -0
  689. acprof/workloads/__init__.py +222 -0
  690. acprof/workloads/audio.py +621 -0
  691. acprof/workloads/contract.py +116 -0
  692. acprof/workloads/cv.py +240 -0
  693. acprof/workloads/diffusion.py +410 -0
  694. acprof/workloads/multimodal.py +329 -0
  695. acprof/workloads/nlp.py +151 -0
  696. acprof/workloads/structured.py +151 -0
  697. acprof/workloads/timeseries.py +69 -0
  698. acprof-0.3.0.dist-info/METADATA +117 -0
  699. acprof-0.3.0.dist-info/RECORD +704 -0
  700. acprof-0.3.0.dist-info/WHEEL +4 -0
  701. acprof-0.3.0.dist-info/entry_points.txt +2 -0
  702. acprof-0.3.0.dist-info/licenses/LICENSE +202 -0
  703. acprof-0.3.0.dist-info/licenses/NOTICE +43 -0
  704. acprof-0.3.0.dist-info/licenses/licenses/CC-BY-4.0.txt +156 -0
@@ -0,0 +1,258 @@
1
+ """声明模型运行环境及适配器;主机端只读取元数据,不导入推理框架。"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import asdict, dataclass, field
6
+ from functools import cache
7
+ from pathlib import Path
8
+ from typing import Any
9
+
10
+ from acprof.dependency_locks import (
11
+ content_digest,
12
+ package_versions,
13
+ read_python_lock,
14
+ read_system_lock,
15
+ require_parent_subset,
16
+ system_lock_identity,
17
+ )
18
+ from acprof.extensions import CATALOG, select_extension
19
+ from acprof.extensions.schema import validate_precision_policy
20
+
21
+ PYTHON_BASE_IMAGE = CATALOG.platforms["python-cpu"]["python_base_image"]
22
+ @dataclass(frozen=True)
23
+ class PlatformSpec:
24
+ platform_id: str
25
+ # 保留旧位置参数与身份;新平台只需声明 Python、系统与基础安装工具。
26
+ torch_version: str | None = None
27
+ torch_index_url: str | None = None
28
+ requirements_lock: str = ""
29
+ python_base_image: str = PYTHON_BASE_IMAGE
30
+ python_version: str = CATALOG.platforms["python-cpu"]["python_version"]
31
+ architecture: str = "linux/amd64"
32
+ python_target: str = "x86_64-manylinux_2_28"
33
+ system_lock: str = "dockerfiles/locks/system-trixie-amd64.json"
34
+
35
+ def __post_init__(self) -> None:
36
+ if not self.requirements_lock:
37
+ raise ValueError("平台必须声明完整 requirements lock")
38
+ if bool(self.torch_version) != bool(self.torch_index_url):
39
+ raise ValueError("旧 Torch 平台必须同时声明 torch_version 和 torch_index_url")
40
+
41
+
42
+ @dataclass(frozen=True)
43
+ class RuntimeSpec:
44
+ """运行时及其分发包约束;不是另一个执行 adapter。"""
45
+ type: str
46
+ version: str
47
+ package: str = ""
48
+
49
+ def __post_init__(self) -> None:
50
+ if not self.type or not self.version:
51
+ raise ValueError("runtime 必须声明 type 和精确 version")
52
+
53
+
54
+ @dataclass(frozen=True)
55
+ class DependencyEnvironment:
56
+ environment_key: str
57
+ platform: PlatformSpec
58
+ requirements_lock: str
59
+ requirements_inputs: tuple[str, ...] = ()
60
+ runtime: RuntimeSpec | None = None
61
+
62
+ @property
63
+ def runtime_type(self) -> str:
64
+ return self.runtime.type if self.runtime else ("torch" if self.platform.torch_version else "")
65
+
66
+
67
+ @dataclass(frozen=True)
68
+ class RuntimeProfile:
69
+ profile_id: str
70
+ family: str
71
+ environment: DependencyEnvironment | None = None
72
+ adapter: str = "family-default"
73
+ precision_policy: dict[str, Any] = field(default_factory=lambda: {
74
+ "supported_dtypes": ["FP32", "FP16"], "preferred_dtype": "FP32",
75
+ "device_overrides": {"gpu": {"preferred_dtype": "FP16"}},
76
+ })
77
+ trust_remote_code: bool = False
78
+ task_types: tuple[str, ...] = ()
79
+ model_types: tuple[str, ...] = ()
80
+ backends: tuple[str, ...] = ("transformers_model", "transformers_pipeline")
81
+ runtime_line: str = "default"
82
+
83
+ def __post_init__(self) -> None:
84
+ if not isinstance(self.environment, DependencyEnvironment) or not self.environment.requirements_lock:
85
+ raise ValueError("逻辑 profile 必须引用完整 dependency environment lock;不支持未锁定环境")
86
+ validate_precision_policy(self.precision_policy)
87
+
88
+ def to_dict(self) -> dict[str, Any]:
89
+ return asdict(self)
90
+
91
+ def runtime_declarations(catalog) -> tuple[dict, dict, dict]:
92
+ """Materialize declared references through the existing locked runtime types."""
93
+ platforms = {key: PlatformSpec(**values) for key, values in catalog.platforms.items()}
94
+ raw_environments = dict(catalog.dependency_environments)
95
+ for extension in catalog.extensions.values():
96
+ if extension.dependency_environment:
97
+ previous = raw_environments.get(extension.environment)
98
+ if previous is not None and previous != extension.dependency_environment:
99
+ raise ValueError(f"conflicting dependency environment: {extension.environment}")
100
+ raw_environments[extension.environment] = extension.dependency_environment
101
+ environments = {}
102
+ for key, raw in raw_environments.items():
103
+ values = dict(raw)
104
+ values["platform"] = platforms[values["platform"]]
105
+ values["requirements_inputs"] = tuple(values.get("requirements_inputs", ()))
106
+ if values.get("runtime"):
107
+ values["runtime"] = RuntimeSpec(**values["runtime"])
108
+ environments[key] = DependencyEnvironment(environment_key=key, **values)
109
+ profiles = {}
110
+ for key, raw in catalog.runtime_profiles.items():
111
+ values = dict(raw)
112
+ values["environment"] = environments[values["environment"]]
113
+ for field_name in ("task_types", "model_types", "backends"):
114
+ if field_name in values:
115
+ values[field_name] = tuple(values[field_name])
116
+ profiles[key] = RuntimeProfile(**values)
117
+ for extension in catalog.extensions.values():
118
+ if not extension.profile:
119
+ continue
120
+ profile = RuntimeProfile(
121
+ extension.profile, extension.family, environments[extension.environment], extension.adapter,
122
+ task_types=extension.tasks, model_types=extension.model_types, backends=extension.backends,
123
+ **extension.profile_options,
124
+ )
125
+ if extension.profile in profiles and profiles[extension.profile] != profile:
126
+ raise ValueError(f"conflicting runtime profile: {extension.profile}")
127
+ profiles[extension.profile] = profile
128
+ return platforms, environments, profiles
129
+
130
+
131
+ PLATFORMS, ENVIRONMENTS, PROFILES = runtime_declarations(CATALOG)
132
+ DEFAULT_PROFILES = {
133
+ (profile.family, profile.environment.platform.platform_id): profile.profile_id
134
+ for profile in PROFILES.values() if profile.adapter == "family-default" and profile.runtime_line == "default"
135
+ }
136
+
137
+
138
+ @cache
139
+ def locked_transformers_version(environment: DependencyEnvironment, *, lock_path: Path | None = None) -> str | None:
140
+ """Read the Transformers pin from the host resource or explicitly staged image lock."""
141
+ from acprof.installation import resource_root
142
+ source = lock_path if lock_path is not None else resource_root() / environment.requirements_lock
143
+ return package_versions(read_python_lock(source)).get("transformers")
144
+
145
+
146
+ def _native_compatible(task_info: Any, profile: RuntimeProfile) -> bool | None:
147
+ from acprof.model_support import supports_transformers_task
148
+ if task_info.runtime_backend not in {"transformers_model", "transformers_pipeline"}:
149
+ return None
150
+ config = getattr(task_info, "model_config", {}) or {}
151
+ # Custom Auto classes are verified by the selected extension/container.
152
+ if config.get("auto_map") or config.get("custom_pipelines") or (getattr(task_info, "model_resolution", {}) or {}).get("interface_kind") == "custom_pipeline":
153
+ return None
154
+ version = locked_transformers_version(profile.environment)
155
+ if not version:
156
+ return None
157
+ return supports_transformers_task(version, task_info.pipeline_tag, str(config.get("model_type") or ""), config)
158
+
159
+
160
+ def profile_for_platform(profile: RuntimeProfile, platform: str) -> RuntimeProfile:
161
+ if profile.runtime_line == "default":
162
+ return PROFILES[DEFAULT_PROFILES[(profile.family, platform)]]
163
+ matches = [item for item in PROFILES.values() if item.family == profile.family
164
+ and item.adapter == profile.adapter and item.runtime_line == profile.runtime_line
165
+ and item.environment.platform.platform_id == platform]
166
+ if len(matches) != 1:
167
+ raise ValueError(f"No unique {platform} environment for {profile.profile_id}")
168
+ return matches[0]
169
+
170
+
171
+ def platform_identity(platform: PlatformSpec, project_dir) -> dict:
172
+ from pathlib import Path
173
+ root = Path(project_dir)
174
+ system = read_system_lock(root / platform.system_lock)
175
+ if system["base_image"] != platform.python_base_image or platform.architecture != "linux/" + system["architecture"]:
176
+ raise ValueError("平台与 system lock 的基础镜像或架构不符")
177
+ packages = read_python_lock(root / platform.requirements_lock)
178
+ if platform.torch_version and package_versions(packages).get("torch") != platform.torch_version:
179
+ raise ValueError("平台 Torch 版本与依赖 lock 不符")
180
+ identity = {"schema_version": 1, "python_base_image": platform.python_base_image,
181
+ "python_version": platform.python_version, "architecture": platform.architecture,
182
+ "python_target": platform.python_target,
183
+ "system": system_lock_identity(system), "packages": packages}
184
+ if platform.torch_version:
185
+ identity["torch_index_url"] = platform.torch_index_url
186
+ return identity
187
+
188
+
189
+ def environment_identity(environment: DependencyEnvironment, project_dir) -> dict:
190
+ from pathlib import Path
191
+ platform = platform_identity(environment.platform, project_dir)
192
+ packages = read_python_lock(Path(project_dir) / environment.requirements_lock)
193
+ require_parent_subset(platform["packages"], packages)
194
+ if environment.runtime is not None:
195
+ from acprof.dependency_locks import normalized_name
196
+ runtime = environment.runtime
197
+ package = normalized_name(runtime.package or runtime.type)
198
+ if package_versions(packages).get(package) != runtime.version:
199
+ raise ValueError(f"Runtime {runtime.type} 要求 {package}=={runtime.version},与依赖 lock 不符")
200
+ # 运行时角色不改变已锁定制品集合;同一完整环境可供不同执行器复用。
201
+ return {"schema_version": 1, "platform": platform, "packages": packages}
202
+
203
+
204
+ def environment_id(environment: DependencyEnvironment, project_dir) -> str:
205
+ return content_digest(environment_identity(environment, project_dir))
206
+
207
+
208
+ def select_runtime_profile(task_info: Any) -> RuntimeProfile:
209
+ extension = select_extension(task_info)
210
+ if extension.profile:
211
+ profile = PROFILES.get(extension.profile)
212
+ if profile is None:
213
+ raise ValueError(f"No registered runtime for extension {extension.extension_id!r}: {extension.profile}")
214
+ if (
215
+ task_info.task_family != profile.family
216
+ or (profile.task_types and task_info.pipeline_tag not in profile.task_types)
217
+ or task_info.runtime_backend not in profile.backends
218
+ or extension.adapter != profile.adapter
219
+ ):
220
+ raise ValueError(
221
+ f"Runtime {profile.profile_id!r} does not support "
222
+ f"{task_info.task_family}/{task_info.pipeline_tag}/{task_info.runtime_backend}"
223
+ )
224
+ explicit = getattr(task_info, "runtime_profile_id", "")
225
+ if explicit and explicit != profile.profile_id:
226
+ raise ValueError(f"Runtime {explicit!r} does not match extension {extension.extension_id!r}")
227
+ return profile
228
+ family = task_info.task_family
229
+ default = DEFAULT_PROFILES.get((family, "cu128"), "")
230
+ from acprof.model_spec import declared_multimodal_pipeline
231
+ custom_pipeline = declared_multimodal_pipeline(task_info)
232
+ if custom_pipeline:
233
+ default = "custom-multimodal-cu128"
234
+ selected = getattr(task_info, "runtime_profile_id", "") or default
235
+ profile = PROFILES.get(selected)
236
+ if profile is None or profile.family != family or profile.adapter != "family-default":
237
+ raise ValueError(f"No registered runtime for {family}/{selected}")
238
+ if custom_pipeline and profile.runtime_line != "custom-multimodal":
239
+ raise ValueError("Declared multimodal pipelines require a locked custom-multimodal runtime")
240
+ if _native_compatible(task_info, profile) is False:
241
+ if getattr(task_info, "runtime_profile_id", ""):
242
+ raise ValueError(f"Runtime {selected} does not register {task_info.pipeline_tag}/{task_info.model_config.get('model_type')}")
243
+ candidates = [item for item in PROFILES.values() if item.family == family
244
+ and item.runtime_line != "default" and item.adapter == "family-default"
245
+ and item.environment.platform.platform_id == profile.environment.platform.platform_id
246
+ and _native_compatible(task_info, item) is True]
247
+ if not candidates:
248
+ raise ValueError(f"No registered Transformers runtime for {task_info.pipeline_tag}/{task_info.model_config.get('model_type')}")
249
+ profile = candidates[0]
250
+ return profile
251
+
252
+
253
+ def default_model_adapter(model_id: str) -> str:
254
+ adapters = {extension.adapter for extension in CATALOG.extensions.values()
255
+ if model_id.lower() in {value.lower() for value in extension.model_ids}}
256
+ if len(adapters) > 1:
257
+ raise ValueError("Model has multiple backend adapters; select the runtime first and pass model_adapter explicitly")
258
+ return next(iter(adapters), "family-default")
@@ -0,0 +1,72 @@
1
+ """Small shared runtime settings; Docker quota and affinity remain separate."""
2
+ from __future__ import annotations
3
+
4
+ import math
5
+ import os
6
+
7
+ RUNTIME_ENV_NAMES = (
8
+ 'ACPROF_RUNTIME_THREADS', 'ACPROF_ONNX_INTRA_OP_THREADS',
9
+ 'ACPROF_ONNX_INTER_OP_THREADS', 'ACPROF_ONNX_PROVIDERS',
10
+ 'ACPROF_REQUEST_TIMEOUT_S', 'TORCH_NUM_THREADS',
11
+ )
12
+
13
+
14
+ def runtime_environment() -> dict[str, str]:
15
+ return {name: os.environ[name] for name in RUNTIME_ENV_NAMES if name in os.environ}
16
+
17
+
18
+ def runtime_docker_env_args() -> list[str]:
19
+ return [part for name, value in runtime_environment().items() for part in ('-e', f'{name}={value}')]
20
+
21
+
22
+ def _integer(name: str, default: int, *, minimum: int = 0) -> int:
23
+ raw = os.environ.get(name)
24
+ try:
25
+ value = default if raw is None else int(raw)
26
+ except ValueError as exc:
27
+ raise ValueError(f'{name} must be an integer >= {minimum}') from exc
28
+ if value < minimum:
29
+ raise ValueError(f'{name} must be an integer >= {minimum}')
30
+ return value
31
+
32
+
33
+ def runtime_threads(default: int = 0) -> int:
34
+ name = 'ACPROF_RUNTIME_THREADS' if 'ACPROF_RUNTIME_THREADS' in os.environ else 'TORCH_NUM_THREADS'
35
+ return _integer(name, default)
36
+
37
+
38
+ def request_timeout_s() -> float | None:
39
+ name = 'ACPROF_REQUEST_TIMEOUT_S'
40
+ raw = os.environ.get(name, '300')
41
+ if raw.strip().lower() == 'none':
42
+ return None
43
+ try:
44
+ value = float(raw)
45
+ except ValueError as exc:
46
+ raise ValueError(f'{name} must be finite and positive') from exc
47
+ if not math.isfinite(value) or value <= 0:
48
+ raise ValueError(f'{name} must be finite and positive')
49
+ return value
50
+
51
+
52
+ def onnx_runtime_parameters() -> dict:
53
+ intra_name = next((name for name in ('ACPROF_ONNX_INTRA_OP_THREADS', 'ACPROF_RUNTIME_THREADS',
54
+ 'TORCH_NUM_THREADS') if name in os.environ), None)
55
+ # Legacy zero meant one ORT thread; retain that default. Explicit ORT values must be positive.
56
+ intra = max(1, _integer(intra_name, 1, minimum=1 if intra_name == 'ACPROF_ONNX_INTRA_OP_THREADS' else 0)) if intra_name else 1
57
+ inter_name = 'ACPROF_ONNX_INTER_OP_THREADS'
58
+ inter = _integer(inter_name, 1, minimum=1)
59
+ raw_providers = os.environ.get('ACPROF_ONNX_PROVIDERS', 'CPUExecutionProvider')
60
+ providers = [name.strip() for name in raw_providers.split(',')]
61
+ if providers != ['CPUExecutionProvider']:
62
+ raise ValueError('unsupported ONNX providers: this CPU profile requires CPUExecutionProvider; fallback is disabled')
63
+ return {
64
+ 'requested': {'runtime': 'onnxruntime', 'device': 'cpu', 'providers': providers,
65
+ 'intra_op_threads': int(os.environ[intra_name]) if intra_name else None,
66
+ 'inter_op_threads': int(os.environ[inter_name]) if inter_name in os.environ else None,
67
+ 'allow_fallback': False},
68
+ 'effective': {'runtime': 'onnxruntime', 'device': 'cpu', 'providers': providers,
69
+ 'threads': intra, 'intra_op_threads': intra, 'inter_op_threads': inter},
70
+ 'source': {'intra_op_threads': intra_name or 'default',
71
+ 'inter_op_threads': inter_name if inter_name in os.environ else 'default'},
72
+ }
@@ -0,0 +1,68 @@
1
+ """Explicit source scopes shared by resume identity and the service build context."""
2
+ from __future__ import annotations
3
+
4
+ import hashlib
5
+ import shutil
6
+ from collections.abc import Iterable
7
+ from pathlib import Path
8
+
9
+ _SERVICE_DIRECTORIES = {"container", "extensions", "workloads"}
10
+ _PRESENTATION_DIRECTORIES = {"tui", "plotting", "analysis"}
11
+ # Internal source modules excluded from measurement identity, not launcher names.
12
+ _PRESENTATION_CLI_MODULES = {"tui", "plot", "stats", "audit", "compare"}
13
+
14
+
15
+ def _package_sources(root: Path) -> list[Path]:
16
+ package = root / "acprof"
17
+ return sorted(path for path in package.rglob("*") if path.is_file()
18
+ and path.suffix in {".py", ".json"}
19
+ and not {"_bundle", "__pycache__"}.intersection(path.relative_to(package).parts))
20
+
21
+
22
+ def measurement_sources(root: str | Path) -> list[Path]:
23
+ root = Path(root)
24
+ paths = []
25
+ for path in _package_sources(root):
26
+ parts = path.relative_to(root / "acprof").parts
27
+ if parts[0] in _PRESENTATION_DIRECTORIES:
28
+ continue
29
+ if parts[0] == "cli" and path.suffix == ".py" and path.stem in _PRESENTATION_CLI_MODULES:
30
+ continue
31
+ paths.append(path)
32
+ # The built-in audio fixture and its provenance affect generated inputs.
33
+ paths.extend(path for path in (root / "assets").rglob("*") if path.is_file())
34
+ return sorted(paths)
35
+
36
+
37
+ def service_sources(root: str | Path) -> list[Path]:
38
+ root = Path(root)
39
+ return [path for path in _package_sources(root)
40
+ if len(path.relative_to(root / "acprof").parts) == 1
41
+ or path.relative_to(root / "acprof").parts[0] in _SERVICE_DIRECTORIES]
42
+
43
+
44
+ def source_fingerprint(root: str | Path, paths: Iterable[Path], *, scope: str) -> str:
45
+ root = Path(root)
46
+ digest = hashlib.sha256(scope.encode())
47
+ for path in sorted(paths):
48
+ name = path.relative_to(root).as_posix().encode()
49
+ content = path.read_bytes()
50
+ digest.update(len(name).to_bytes(8, "big"))
51
+ digest.update(name)
52
+ digest.update(len(content).to_bytes(8, "big"))
53
+ digest.update(content)
54
+ return digest.hexdigest()
55
+
56
+
57
+ def service_context_files(root: str | Path) -> list[Path]:
58
+ root = Path(root)
59
+ return sorted([*service_sources(root), root / "dockerfiles/runtime-final.Dockerfile",
60
+ root / "LICENSE", root / "NOTICE", *sorted((root / "licenses").rglob("*.txt"))])
61
+
62
+
63
+ def stage_service_context(root: str | Path, destination: str | Path) -> None:
64
+ root, destination = Path(root), Path(destination)
65
+ for source in service_context_files(root):
66
+ target = destination / source.relative_to(root)
67
+ target.parent.mkdir(parents=True, exist_ok=True)
68
+ shutil.copyfile(source, target)
@@ -0,0 +1,225 @@
1
+ """Versioned raw window evidence and pure replay of existing metric reductions.
2
+
3
+ Capture/serialization are called after collector shutdown. The retention limit
4
+ bounds the persisted evidence, not the collectors' existing reduction buffers.
5
+ Old aggregate-only rows never acquire a synthetic raw-sample capability.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import hashlib
10
+ import json
11
+ import math
12
+ from collections.abc import Callable, Iterable, Sequence
13
+ from dataclasses import asdict, is_dataclass
14
+ from pathlib import Path
15
+ from typing import Any, TextIO
16
+
17
+ from acprof.artifacts import atomic_write, loads_finite_json
18
+
19
+ TELEMETRY_SCHEMA_VERSION = 1
20
+ REDUCTION_VERSION = "window-reduction-v1"
21
+
22
+
23
+ def finite_json(value: Any) -> Any:
24
+ if isinstance(value, float):
25
+ return value if math.isfinite(value) else None
26
+ if is_dataclass(value) and not isinstance(value, type):
27
+ return finite_json(asdict(value))
28
+ if isinstance(value, dict):
29
+ return {str(key): finite_json(item) for key, item in value.items()}
30
+ if isinstance(value, (tuple, list)):
31
+ return [finite_json(item) for item in value]
32
+ return value
33
+
34
+
35
+ def canonical_bytes(value: Any) -> bytes:
36
+ return json.dumps(finite_json(value), sort_keys=True, ensure_ascii=True,
37
+ separators=(",", ":"), allow_nan=False).encode("utf-8")
38
+
39
+
40
+ def capture_samples[T](samples: Sequence[T], limit: int,
41
+ encode: Callable[[T], Any] = finite_json) -> dict[str, Any]:
42
+ """Select at most limit samples without copying the full collector buffer."""
43
+ if isinstance(limit, bool) or not isinstance(limit, int) or limit < 2:
44
+ raise ValueError("raw_sample_limit must be an integer of at least 2")
45
+ count = len(samples)
46
+ indices: Iterable[int]
47
+ if count <= limit:
48
+ indices = range(count)
49
+ else:
50
+ # Preserve boundaries and deterministic coverage; omitted observations
51
+ # cannot be recovered and this subset is not an exact reduction input.
52
+ indices = (index * (count - 1) // (limit - 1) for index in range(limit))
53
+ selected = [encode(samples[index]) for index in indices]
54
+ return {
55
+ "samples": selected,
56
+ "retention": {
57
+ "limit": limit, "observed_samples": count, "retained_samples": len(selected),
58
+ "omitted_samples": count - len(selected), "complete": count <= limit,
59
+ "selection": "all" if count <= limit else "uniform_index_with_boundaries",
60
+ "scope": "persisted_evidence_only; in_memory_reduction_buffer_is_not_bounded",
61
+ },
62
+ }
63
+
64
+
65
+ def window_evidence(*, identity: dict[str, Any], context: dict[str, Any],
66
+ collectors: dict[str, Any]) -> dict[str, Any]:
67
+ return finite_json({
68
+ "schema_version": TELEMETRY_SCHEMA_VERSION,
69
+ "reduction_version": REDUCTION_VERSION,
70
+ "identity": identity, "context": context,
71
+ "clock": {
72
+ "name": "time.perf_counter", "unit": "seconds", "monotonic": True,
73
+ "scope": "one_host_process", "wall_clock_conversion": "unavailable",
74
+ "sample_timestamp_semantics": "logical_read_start; not exact hardware sample time",
75
+ },
76
+ "collectors": collectors,
77
+ })
78
+
79
+
80
+ def write_window_evidence(path: str | Path, evidence: dict[str, Any]) -> dict[str, Any]:
81
+ """Publish bytes atomically; repeated identical publication is idempotent."""
82
+ if type(evidence.get("schema_version")) is not int or evidence.get("schema_version") != TELEMETRY_SCHEMA_VERSION:
83
+ raise ValueError("unsupported telemetry schema")
84
+ destination = Path(path)
85
+ payload = canonical_bytes(evidence) + b"\n"
86
+ if destination.exists():
87
+ if destination.read_bytes() != payload:
88
+ raise ValueError(f"refusing to replace different window evidence: {destination}")
89
+ else:
90
+ def write(stream: TextIO) -> None:
91
+ stream.write(payload.decode("utf-8"))
92
+ atomic_write(destination, write)
93
+ return {
94
+ "path": str(destination), "sha256": hashlib.sha256(payload).hexdigest(),
95
+ "schema_version": TELEMETRY_SCHEMA_VERSION, "size_bytes": len(payload),
96
+ }
97
+
98
+
99
+ def read_window_evidence(path: str | Path, *, expected_sha256: str | None = None) -> dict[str, Any]:
100
+ payload = Path(path).read_bytes()
101
+ if expected_sha256 is not None and hashlib.sha256(payload).hexdigest() != expected_sha256:
102
+ raise ValueError("window telemetry hash mismatch")
103
+ evidence = loads_finite_json(payload.decode("utf-8"))
104
+ if (not isinstance(evidence, dict) or type(evidence.get("schema_version")) is not int
105
+ or evidence.get("schema_version") != TELEMETRY_SCHEMA_VERSION):
106
+ raise ValueError("unsupported telemetry schema")
107
+ return evidence
108
+
109
+
110
+ def raw_capability(evidence: dict[str, Any] | None) -> dict[str, Any]:
111
+ if evidence is None:
112
+ return {"status": "unavailable", "reason": "legacy_or_missing_raw_evidence", "can_recompute": False}
113
+ if type(evidence.get("schema_version")) is not int or evidence.get("schema_version") != TELEMETRY_SCHEMA_VERSION:
114
+ raise ValueError("unsupported telemetry schema")
115
+ collectors = evidence.get("collectors", {})
116
+ available = {name: item for name, item in collectors.items()
117
+ if isinstance(item, dict) and item.get("status") == "recorded"}
118
+ complete = bool(available) and all(item.get("retention", {}).get("complete") is True
119
+ for item in available.values())
120
+ return {"status": "complete" if complete else "incomplete" if available else "unavailable",
121
+ "can_recompute": complete, "collectors": sorted(available),
122
+ "scope": "recorded_workload_metrics_using_recorded_control_baseline",
123
+ "control_samples_complete": all(
124
+ not item.get("control") or item["control"].get("retention", {}).get("complete") is True
125
+ for item in available.values())}
126
+
127
+
128
+ def _number(value: Any) -> float:
129
+ return float("nan") if value is None else float(value)
130
+
131
+
132
+ def recompute_window(evidence: dict[str, Any]) -> dict[str, Any]:
133
+ """Replay recorded reductions without hardware, environment reads or I/O.
134
+
135
+ Missing collectors stay unavailable. A truncated collector is rejected rather
136
+ than producing plausible metrics from an incomplete series. GPU source choice
137
+ is the recorded, versioned choice, not a fresh hardware capability decision.
138
+ """
139
+ raw_capability(evidence)
140
+ if evidence.get("reduction_version") != REDUCTION_VERSION:
141
+ raise ValueError("unsupported telemetry reduction version")
142
+ output: dict[str, Any] = {}
143
+ for name, item in evidence.get("collectors", {}).items():
144
+ if not isinstance(item, dict) or item.get("status") != "recorded":
145
+ output[name] = {"status": "unavailable"}
146
+ continue
147
+ if item.get("retention", {}).get("complete") is not True:
148
+ raise ValueError(f"cannot exactly recompute truncated {name} evidence")
149
+ if name == "cpu":
150
+ output[name] = _recompute_cpu(item)
151
+ elif name == "gpu":
152
+ output[name] = _recompute_gpu(item)
153
+ elif name == "resource":
154
+ output[name] = _recompute_resource(item)
155
+ else:
156
+ output[name] = {"status": "unavailable", "reason": "no_raw_reducer"}
157
+ return finite_json(output)
158
+
159
+
160
+ def _recompute_cpu(item: dict[str, Any]) -> dict[str, Any]:
161
+ from acprof.monitors.energy_cpu import (
162
+ CPUSample,
163
+ RaplDomain,
164
+ reduce_cpu_samples,
165
+ reduce_dram_samples,
166
+ )
167
+ context = item["context"]
168
+ samples = [CPUSample(**{**sample, "host_active_s": _number(sample["host_active_s"])})
169
+ for sample in item["samples"]]
170
+ domains = [RaplDomain(**domain) for domain in context["domains"]]
171
+ result = reduce_cpu_samples(samples, _number(context["idle_power_w"]), domains,
172
+ min_power_interval_s=context["min_power_interval_s"])
173
+ result.dram = reduce_dram_samples(
174
+ samples, [RaplDomain(**domain) for domain in context["dram_domains"]],
175
+ _number(context["dram_idle_power_w"]), context["dram_status"],
176
+ context["dram_error"], min_power_interval_s=context["min_power_interval_s"],
177
+ )
178
+ return asdict(result)
179
+
180
+
181
+ def _recompute_gpu(item: dict[str, Any]) -> dict[str, Any]:
182
+ from acprof.monitors.gpu_metrics import apply_gpu_energy_counter, reduce_gpu_samples
183
+ context = item["context"]
184
+ samples = [(float(sample["timestamp"]), _number(sample["power_w"])) for sample in item["samples"]]
185
+ result = reduce_gpu_samples(samples, _number(context["idle_power_w"]))
186
+ result.counter_start_mj = context["counter_start_mj"]
187
+ result.counter_end_mj = context["counter_end_mj"]
188
+ result.measurement_duration_s = _number(context["measurement_duration_s"])
189
+ result.energy_fallback_reason = context["energy_fallback_reason"]
190
+ source = context["energy_source"]
191
+ if source == "nvml_total_energy":
192
+ apply_gpu_energy_counter(result)
193
+ elif source not in {"power_integration", "unavailable"}:
194
+ raise ValueError("unknown recorded GPU energy source")
195
+ if context.get("control_source_reselected"):
196
+ result.energy_eff_j = result.energy_total_j - result.idle_power_w * result.measurement_duration_s
197
+ result.avg_power_eff_w = result.avg_power_total_w - result.idle_power_w
198
+ result.peak_power_eff_w = result.peak_power_total_w - result.idle_power_w
199
+ return asdict(result)
200
+
201
+
202
+ def _recompute_resource(item: dict[str, Any]) -> dict[str, Any]:
203
+ from acprof.monitors import resource_metrics
204
+ context = item["context"]
205
+ samples = [resource_metrics.ResourceUsageSample(**sample) for sample in item["samples"]]
206
+ result = resource_metrics.reduce_resource_samples(
207
+ samples, _number(context["cpu_cores"]), _number(context["mem_limit_bytes"]),
208
+ min_cpu_interval_s=context["min_cpu_interval_s"],
209
+ )
210
+ if context["swap_limit_bytes"] is not None:
211
+ result.container_swap_limit_bytes = float(context["swap_limit_bytes"])
212
+ before, after = context["io_start"], context["io_end"]
213
+ if before is not None and after is not None:
214
+ for direction, index in (("read", 0), ("write", 1)):
215
+ setattr(result, f"container_io_{direction}_bytes", resource_metrics.counter_delta(
216
+ {direction: before[index]}, {direction: after[index]}, direction))
217
+ def counters(value: dict[str, Any]) -> resource_metrics.WindowCounterSnapshots:
218
+ return resource_metrics.WindowCounterSnapshots(**{
219
+ key: None if values is None else {name: _number(number) for name, number in values.items()}
220
+ for key, values in value.items()
221
+ })
222
+ resource_metrics.apply_window_counter_metrics(result, counters(context["counters_start"]),
223
+ counters(context["counters_end"]),
224
+ context["window_duration_s"])
225
+ return asdict(result)
@@ -0,0 +1 @@
1
+ """Optional development tooling; importing AC-Prof does not load pytest."""