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.
- acprof/__init__.py +3 -0
- acprof/__main__.py +5 -0
- acprof/_bundle/.dockerignore +20 -0
- acprof/_bundle/LICENSE +202 -0
- acprof/_bundle/NOTICE +43 -0
- acprof/_bundle/acprof/__init__.py +3 -0
- acprof/_bundle/acprof/__main__.py +5 -0
- acprof/_bundle/acprof/analysis/__init__.py +1 -0
- acprof/_bundle/acprof/analysis/audit.py +276 -0
- acprof/_bundle/acprof/analysis/comparison.py +364 -0
- acprof/_bundle/acprof/analysis/compatibility.py +223 -0
- acprof/_bundle/acprof/analysis/conditions.py +185 -0
- acprof/_bundle/acprof/analysis/independent_comparison.py +191 -0
- acprof/_bundle/acprof/analysis/latency_model.py +1106 -0
- acprof/_bundle/acprof/analysis/latency_report.py +577 -0
- acprof/_bundle/acprof/analysis/model.py +276 -0
- acprof/_bundle/acprof/analysis/precision.py +51 -0
- acprof/_bundle/acprof/analysis/uncertainty.py +144 -0
- acprof/_bundle/acprof/application/__init__.py +1 -0
- acprof/_bundle/acprof/application/download.py +14 -0
- acprof/_bundle/acprof/application/errors.py +5 -0
- acprof/_bundle/acprof/application/notifications.py +302 -0
- acprof/_bundle/acprof/application/preparation.py +333 -0
- acprof/_bundle/acprof/application/resources.py +66 -0
- acprof/_bundle/acprof/application/run.py +462 -0
- acprof/_bundle/acprof/application/terminal_log.py +136 -0
- acprof/_bundle/acprof/artifact_layout.py +261 -0
- acprof/_bundle/acprof/artifacts.py +161 -0
- acprof/_bundle/acprof/capabilities.py +404 -0
- acprof/_bundle/acprof/cli/__init__.py +1 -0
- acprof/_bundle/acprof/cli/audit.py +74 -0
- acprof/_bundle/acprof/cli/auto.py +41 -0
- acprof/_bundle/acprof/cli/backfill_compute.py +498 -0
- acprof/_bundle/acprof/cli/compare.py +34 -0
- acprof/_bundle/acprof/cli/coverage.py +70 -0
- acprof/_bundle/acprof/cli/doctor.py +47 -0
- acprof/_bundle/acprof/cli/inspect.py +101 -0
- acprof/_bundle/acprof/cli/load.py +190 -0
- acprof/_bundle/acprof/cli/main.py +64 -0
- acprof/_bundle/acprof/cli/model_store.py +22 -0
- acprof/_bundle/acprof/cli/plot.py +211 -0
- acprof/_bundle/acprof/cli/posthoc.py +113 -0
- acprof/_bundle/acprof/cli/probe.py +186 -0
- acprof/_bundle/acprof/cli/report.py +35 -0
- acprof/_bundle/acprof/cli/results.py +37 -0
- acprof/_bundle/acprof/cli/run.py +54 -0
- acprof/_bundle/acprof/cli/stats.py +94 -0
- acprof/_bundle/acprof/cli/tui.py +65 -0
- acprof/_bundle/acprof/config.py +177 -0
- acprof/_bundle/acprof/container/__init__.py +1 -0
- acprof/_bundle/acprof/container/compat/__init__.py +1 -0
- acprof/_bundle/acprof/container/compat/transformers_dynamic.py +54 -0
- acprof/_bundle/acprof/container/compat/transformers_model_types.json +1091 -0
- acprof/_bundle/acprof/container/compute_profile_runner.py +392 -0
- acprof/_bundle/acprof/container/download_model.py +165 -0
- acprof/_bundle/acprof/container/execution.py +73 -0
- acprof/_bundle/acprof/container/handlers/__init__.py +298 -0
- acprof/_bundle/acprof/container/handlers/audio.py +743 -0
- acprof/_bundle/acprof/container/handlers/custom_pipeline.py +74 -0
- acprof/_bundle/acprof/container/handlers/cv.py +321 -0
- acprof/_bundle/acprof/container/handlers/diffusion.py +728 -0
- acprof/_bundle/acprof/container/handlers/moss.py +64 -0
- acprof/_bundle/acprof/container/handlers/multimodal.py +609 -0
- acprof/_bundle/acprof/container/handlers/nlp.py +747 -0
- acprof/_bundle/acprof/container/handlers/onnx_tasks.py +231 -0
- acprof/_bundle/acprof/container/handlers/onnxruntime.py +90 -0
- acprof/_bundle/acprof/container/handlers/structured.py +185 -0
- acprof/_bundle/acprof/container/handlers/timeseries.py +178 -0
- acprof/_bundle/acprof/container/load_policy.py +81 -0
- acprof/_bundle/acprof/container/loading_quality.py +48 -0
- acprof/_bundle/acprof/container/local_pipeline.py +31 -0
- acprof/_bundle/acprof/container/model_files.py +280 -0
- acprof/_bundle/acprof/container/model_probe.py +80 -0
- acprof/_bundle/acprof/container/onnx_session.py +150 -0
- acprof/_bundle/acprof/container/runtime_manifest.py +150 -0
- acprof/_bundle/acprof/container/runtime_validate.py +156 -0
- acprof/_bundle/acprof/container/server.py +209 -0
- acprof/_bundle/acprof/container/torch_execution.py +55 -0
- acprof/_bundle/acprof/container/validation.py +172 -0
- acprof/_bundle/acprof/cpu_affinity.py +35 -0
- acprof/_bundle/acprof/dependency_locks.py +129 -0
- acprof/_bundle/acprof/experiment.py +356 -0
- acprof/_bundle/acprof/extensions/__init__.py +294 -0
- acprof/_bundle/acprof/extensions/builtin/manifest.json +3591 -0
- acprof/_bundle/acprof/extensions/onnxruntime/manifest.json +191 -0
- acprof/_bundle/acprof/extensions/schema.py +238 -0
- acprof/_bundle/acprof/extensions/transformers/4.57.6.json +1639 -0
- acprof/_bundle/acprof/extensions/transformers/5.10.4.json +1812 -0
- acprof/_bundle/acprof/failures.py +115 -0
- acprof/_bundle/acprof/hardware_conditions.py +18 -0
- acprof/_bundle/acprof/hf_download.py +143 -0
- acprof/_bundle/acprof/hf_endpoints.py +62 -0
- acprof/_bundle/acprof/hf_transport.py +238 -0
- acprof/_bundle/acprof/host/__init__.py +1 -0
- acprof/_bundle/acprof/host/automation.py +161 -0
- acprof/_bundle/acprof/host/client.py +520 -0
- acprof/_bundle/acprof/host/collection_history.py +77 -0
- acprof/_bundle/acprof/host/collection_workflow.py +285 -0
- acprof/_bundle/acprof/host/command.py +119 -0
- acprof/_bundle/acprof/host/container_lifecycle.py +225 -0
- acprof/_bundle/acprof/host/container_state.py +128 -0
- acprof/_bundle/acprof/host/coverage_state.py +259 -0
- acprof/_bundle/acprof/host/detect.py +669 -0
- acprof/_bundle/acprof/host/docker_runtime.py +359 -0
- acprof/_bundle/acprof/host/doctor.py +158 -0
- acprof/_bundle/acprof/host/env_utils.py +233 -0
- acprof/_bundle/acprof/host/execution_conditions.py +87 -0
- acprof/_bundle/acprof/host/gpu_device.py +66 -0
- acprof/_bundle/acprof/host/hardware_conditions.py +130 -0
- acprof/_bundle/acprof/host/images/__init__.py +1 -0
- acprof/_bundle/acprof/host/images/dependencies.py +169 -0
- acprof/_bundle/acprof/host/images/environment.py +313 -0
- acprof/_bundle/acprof/host/images/graph.py +143 -0
- acprof/_bundle/acprof/host/images/identity.py +6 -0
- acprof/_bundle/acprof/host/images/inventory.py +445 -0
- acprof/_bundle/acprof/host/images/runtime.py +457 -0
- acprof/_bundle/acprof/host/images/scan.py +154 -0
- acprof/_bundle/acprof/host/input_plan.py +1056 -0
- acprof/_bundle/acprof/host/interface_probe.py +141 -0
- acprof/_bundle/acprof/host/largest_scale_probe.py +566 -0
- acprof/_bundle/acprof/host/matrix_plan.py +98 -0
- acprof/_bundle/acprof/host/measurement/__init__.py +1 -0
- acprof/_bundle/acprof/host/measurement/boundary.py +162 -0
- acprof/_bundle/acprof/host/measurement/capture.py +139 -0
- acprof/_bundle/acprof/host/measurement/checkpoint.py +275 -0
- acprof/_bundle/acprof/host/measurement/config.py +212 -0
- acprof/_bundle/acprof/host/measurement/diagnostics.py +247 -0
- acprof/_bundle/acprof/host/measurement/energy_validation.py +172 -0
- acprof/_bundle/acprof/host/measurement/errors.py +25 -0
- acprof/_bundle/acprof/host/measurement/execution.py +396 -0
- acprof/_bundle/acprof/host/measurement/load.py +237 -0
- acprof/_bundle/acprof/host/measurement/metrics.py +975 -0
- acprof/_bundle/acprof/host/measurement/monitors.py +143 -0
- acprof/_bundle/acprof/host/measurement/publication.py +171 -0
- acprof/_bundle/acprof/host/measurement/requests.py +97 -0
- acprof/_bundle/acprof/host/measurement/types.py +82 -0
- acprof/_bundle/acprof/host/model_coverage.py +337 -0
- acprof/_bundle/acprof/host/model_errors.py +116 -0
- acprof/_bundle/acprof/host/model_inspection.py +107 -0
- acprof/_bundle/acprof/host/model_schema.py +35 -0
- acprof/_bundle/acprof/host/model_store.py +733 -0
- acprof/_bundle/acprof/host/network_preflight.py +229 -0
- acprof/_bundle/acprof/host/orchestrator.py +1133 -0
- acprof/_bundle/acprof/host/permissions.py +117 -0
- acprof/_bundle/acprof/host/platform_metadata.py +63 -0
- acprof/_bundle/acprof/host/posthoc/__init__.py +12 -0
- acprof/_bundle/acprof/host/posthoc/backfill.py +415 -0
- acprof/_bundle/acprof/host/posthoc/context.py +400 -0
- acprof/_bundle/acprof/host/posthoc/plans.py +597 -0
- acprof/_bundle/acprof/host/posthoc/service.py +303 -0
- acprof/_bundle/acprof/host/posthoc/storage.py +491 -0
- acprof/_bundle/acprof/host/preflight.py +370 -0
- acprof/_bundle/acprof/host/profiling/__init__.py +1 -0
- acprof/_bundle/acprof/host/profiling/compute.py +436 -0
- acprof/_bundle/acprof/host/profiling/compute_plan.py +261 -0
- acprof/_bundle/acprof/host/profiling/execution.py +547 -0
- acprof/_bundle/acprof/host/profiling/execution_plan.py +576 -0
- acprof/_bundle/acprof/host/profiling/progress.py +83 -0
- acprof/_bundle/acprof/host/profiling/support.py +252 -0
- acprof/_bundle/acprof/host/profiling/tools/__init__.py +1 -0
- acprof/_bundle/acprof/host/profiling/tools/advisor.py +164 -0
- acprof/_bundle/acprof/host/profiling/tools/compute_parsers.py +409 -0
- acprof/_bundle/acprof/host/profiling/tools/execution_environment.py +135 -0
- acprof/_bundle/acprof/host/profiling/tools/execution_parsers.py +364 -0
- acprof/_bundle/acprof/host/profiling/tools/massif.py +418 -0
- acprof/_bundle/acprof/host/profiling/tools/ncu.py +696 -0
- acprof/_bundle/acprof/host/profiling/tools/nsys.py +326 -0
- acprof/_bundle/acprof/host/profiling/tools/tool_discovery.py +229 -0
- acprof/_bundle/acprof/host/profiling/tools/torch.py +158 -0
- acprof/_bundle/acprof/host/result_cleanup.py +65 -0
- acprof/_bundle/acprof/host/run_state.py +639 -0
- acprof/_bundle/acprof/host/runtime_settings.py +10 -0
- acprof/_bundle/acprof/host/runtime_validation.py +302 -0
- acprof/_bundle/acprof/host/source_bundle.py +96 -0
- acprof/_bundle/acprof/host/startup_probe.py +95 -0
- acprof/_bundle/acprof/host/static_metadata.py +936 -0
- acprof/_bundle/acprof/host/task_support.py +121 -0
- acprof/_bundle/acprof/installation.py +26 -0
- acprof/_bundle/acprof/latency_slo.py +62 -0
- acprof/_bundle/acprof/messages.py +26 -0
- acprof/_bundle/acprof/metric_registry.py +315 -0
- acprof/_bundle/acprof/model_candidates.py +297 -0
- acprof/_bundle/acprof/model_contract.py +234 -0
- acprof/_bundle/acprof/model_dependencies.py +93 -0
- acprof/_bundle/acprof/model_dependency_domain.py +45 -0
- acprof/_bundle/acprof/model_dependency_eval.py +438 -0
- acprof/_bundle/acprof/model_dependency_flow.py +200 -0
- acprof/_bundle/acprof/model_evidence.py +115 -0
- acprof/_bundle/acprof/model_metadata_analysis.py +156 -0
- acprof/_bundle/acprof/model_repository.py +149 -0
- acprof/_bundle/acprof/model_resolution.py +129 -0
- acprof/_bundle/acprof/model_review.py +155 -0
- acprof/_bundle/acprof/model_source_analysis.py +299 -0
- acprof/_bundle/acprof/model_spec.py +204 -0
- acprof/_bundle/acprof/model_support.py +105 -0
- acprof/_bundle/acprof/model_transforms.py +81 -0
- acprof/_bundle/acprof/monitors/__init__.py +1 -0
- acprof/_bundle/acprof/monitors/common.py +63 -0
- acprof/_bundle/acprof/monitors/energy_cpu.py +651 -0
- acprof/_bundle/acprof/monitors/energy_nvml.py +381 -0
- acprof/_bundle/acprof/monitors/gpu_metrics.py +123 -0
- acprof/_bundle/acprof/monitors/interfaces.py +74 -0
- acprof/_bundle/acprof/monitors/perf_mips.py +617 -0
- acprof/_bundle/acprof/monitors/rapl_topology.py +100 -0
- acprof/_bundle/acprof/monitors/resource_metrics.py +472 -0
- acprof/_bundle/acprof/monitors/resource_readers.py +435 -0
- acprof/_bundle/acprof/monitors/resource_usage.py +450 -0
- acprof/_bundle/acprof/monitors/sampling.py +79 -0
- acprof/_bundle/acprof/network_policy.py +182 -0
- acprof/_bundle/acprof/notifications.py +279 -0
- acprof/_bundle/acprof/packet/__init__.py +1 -0
- acprof/_bundle/acprof/packet/merge_packet_latency.py +369 -0
- acprof/_bundle/acprof/packet/sniff_parse_pcap.py +240 -0
- acprof/_bundle/acprof/pixel_metrics.py +103 -0
- acprof/_bundle/acprof/platform.py +180 -0
- acprof/_bundle/acprof/plotting/__init__.py +1 -0
- acprof/_bundle/acprof/plotting/config.py +487 -0
- acprof/_bundle/acprof/plotting/data.py +236 -0
- acprof/_bundle/acprof/plotting/diagnostics.py +747 -0
- acprof/_bundle/acprof/plotting/latency.py +638 -0
- acprof/_bundle/acprof/plotting/metrics.py +648 -0
- acprof/_bundle/acprof/plotting/plotly-LICENSE.txt +21 -0
- acprof/_bundle/acprof/plotting/report.py +66 -0
- acprof/_bundle/acprof/plotting/styles.py +111 -0
- acprof/_bundle/acprof/precision.py +42 -0
- acprof/_bundle/acprof/preparation_events.py +78 -0
- acprof/_bundle/acprof/progress_events.py +105 -0
- acprof/_bundle/acprof/quality.py +153 -0
- acprof/_bundle/acprof/resource_budget.py +29 -0
- acprof/_bundle/acprof/result_csv.py +263 -0
- acprof/_bundle/acprof/result_layers.py +365 -0
- acprof/_bundle/acprof/run_args.py +223 -0
- acprof/_bundle/acprof/run_options.py +225 -0
- acprof/_bundle/acprof/runtime_dependencies.py +195 -0
- acprof/_bundle/acprof/runtime_profiles.py +258 -0
- acprof/_bundle/acprof/runtime_settings.py +72 -0
- acprof/_bundle/acprof/source_identity.py +68 -0
- acprof/_bundle/acprof/telemetry.py +225 -0
- acprof/_bundle/acprof/testing/__init__.py +1 -0
- acprof/_bundle/acprof/testing/evidence.py +117 -0
- acprof/_bundle/acprof/testing/plugin.py +126 -0
- acprof/_bundle/acprof/testing/provenance.py +53 -0
- acprof/_bundle/acprof/testing/sharding.py +14 -0
- acprof/_bundle/acprof/tui/__init__.py +1 -0
- acprof/_bundle/acprof/tui/app.py +934 -0
- acprof/_bundle/acprof/tui/app_contracts.py +43 -0
- acprof/_bundle/acprof/tui/catalog_controller.py +120 -0
- acprof/_bundle/acprof/tui/commands.py +209 -0
- acprof/_bundle/acprof/tui/configuration_controller.py +436 -0
- acprof/_bundle/acprof/tui/diagnostics.py +340 -0
- acprof/_bundle/acprof/tui/downloads.py +56 -0
- acprof/_bundle/acprof/tui/environment.py +248 -0
- acprof/_bundle/acprof/tui/experiment_catalog.py +279 -0
- acprof/_bundle/acprof/tui/experiment_controller.py +132 -0
- acprof/_bundle/acprof/tui/experiment_picker.py +273 -0
- acprof/_bundle/acprof/tui/field_validation.py +62 -0
- acprof/_bundle/acprof/tui/i18n.py +57 -0
- acprof/_bundle/acprof/tui/image_controller.py +525 -0
- acprof/_bundle/acprof/tui/images.py +737 -0
- acprof/_bundle/acprof/tui/input.py +191 -0
- acprof/_bundle/acprof/tui/localization_controller.py +110 -0
- acprof/_bundle/acprof/tui/log.py +310 -0
- acprof/_bundle/acprof/tui/model_candidates.py +278 -0
- acprof/_bundle/acprof/tui/model_controller.py +111 -0
- acprof/_bundle/acprof/tui/model_input.py +12 -0
- acprof/_bundle/acprof/tui/model_store.py +166 -0
- acprof/_bundle/acprof/tui/preflight_controller.py +271 -0
- acprof/_bundle/acprof/tui/preparation.py +269 -0
- acprof/_bundle/acprof/tui/presentation.py +46 -0
- acprof/_bundle/acprof/tui/process.py +111 -0
- acprof/_bundle/acprof/tui/process_controller.py +218 -0
- acprof/_bundle/acprof/tui/profile_controller.py +109 -0
- acprof/_bundle/acprof/tui/progress.py +195 -0
- acprof/_bundle/acprof/tui/recovery.py +114 -0
- acprof/_bundle/acprof/tui/recovery_controller.py +169 -0
- acprof/_bundle/acprof/tui/rendering.py +75 -0
- acprof/_bundle/acprof/tui/reports.py +303 -0
- acprof/_bundle/acprof/tui/result_controller.py +279 -0
- acprof/_bundle/acprof/tui/review_inputs.py +54 -0
- acprof/_bundle/acprof/tui/run_form.py +125 -0
- acprof/_bundle/acprof/tui/run_planning.py +97 -0
- acprof/_bundle/acprof/tui/run_results.py +175 -0
- acprof/_bundle/acprof/tui/scrollbar.py +65 -0
- acprof/_bundle/acprof/tui/settings.py +203 -0
- acprof/_bundle/acprof/tui/slash_controller.py +95 -0
- acprof/_bundle/acprof/tui/stages.py +97 -0
- acprof/_bundle/acprof/tui/storage.py +150 -0
- acprof/_bundle/acprof/tui/table.py +213 -0
- acprof/_bundle/acprof/tui/themes.py +112 -0
- acprof/_bundle/acprof/tui/translation_catalog.py +1861 -0
- acprof/_bundle/acprof/tui/tui.tcss +373 -0
- acprof/_bundle/acprof/tui/views.py +706 -0
- acprof/_bundle/acprof/window_records.py +165 -0
- acprof/_bundle/acprof/workloads/__init__.py +222 -0
- acprof/_bundle/acprof/workloads/audio.py +621 -0
- acprof/_bundle/acprof/workloads/contract.py +116 -0
- acprof/_bundle/acprof/workloads/cv.py +240 -0
- acprof/_bundle/acprof/workloads/diffusion.py +410 -0
- acprof/_bundle/acprof/workloads/multimodal.py +329 -0
- acprof/_bundle/acprof/workloads/nlp.py +151 -0
- acprof/_bundle/acprof/workloads/structured.py +151 -0
- acprof/_bundle/acprof/workloads/timeseries.py +69 -0
- acprof/_bundle/assets/audio/librispeech-clean-test-en-30s/audio.wav +0 -0
- acprof/_bundle/assets/audio/librispeech-clean-test-en-30s/source.json +81 -0
- acprof/_bundle/dockerfiles/environment_tools.py +314 -0
- acprof/_bundle/dockerfiles/locks/audio-cpu.artifacts.json +503 -0
- acprof/_bundle/dockerfiles/locks/audio-cpu.txt +143 -0
- acprof/_bundle/dockerfiles/locks/audio-cu124.artifacts.json +600 -0
- acprof/_bundle/dockerfiles/locks/audio-cu124.txt +171 -0
- acprof/_bundle/dockerfiles/locks/audio-cu128.artifacts.json +544 -0
- acprof/_bundle/dockerfiles/locks/audio-cu128.txt +155 -0
- acprof/_bundle/dockerfiles/locks/custom-multimodal-cpu.artifacts.json +510 -0
- acprof/_bundle/dockerfiles/locks/custom-multimodal-cpu.txt +145 -0
- acprof/_bundle/dockerfiles/locks/custom-multimodal-cu124.artifacts.json +607 -0
- acprof/_bundle/dockerfiles/locks/custom-multimodal-cu124.txt +173 -0
- acprof/_bundle/dockerfiles/locks/custom-multimodal-cu128.artifacts.json +642 -0
- acprof/_bundle/dockerfiles/locks/custom-multimodal-cu128.txt +183 -0
- acprof/_bundle/dockerfiles/locks/cv-cpu.artifacts.json +279 -0
- acprof/_bundle/dockerfiles/locks/cv-cpu.txt +79 -0
- acprof/_bundle/dockerfiles/locks/cv-cu124.artifacts.json +376 -0
- acprof/_bundle/dockerfiles/locks/cv-cu124.txt +107 -0
- acprof/_bundle/dockerfiles/locks/cv-cu128.artifacts.json +411 -0
- acprof/_bundle/dockerfiles/locks/cv-cu128.txt +117 -0
- acprof/_bundle/dockerfiles/locks/diffusion-cpu.artifacts.json +335 -0
- acprof/_bundle/dockerfiles/locks/diffusion-cpu.txt +95 -0
- acprof/_bundle/dockerfiles/locks/diffusion-cu124.artifacts.json +432 -0
- acprof/_bundle/dockerfiles/locks/diffusion-cu124.txt +123 -0
- acprof/_bundle/dockerfiles/locks/diffusion-cu128.artifacts.json +467 -0
- acprof/_bundle/dockerfiles/locks/diffusion-cu128.txt +133 -0
- acprof/_bundle/dockerfiles/locks/moss-transformers5104.artifacts.json +621 -0
- acprof/_bundle/dockerfiles/locks/moss-transformers5104.txt +177 -0
- acprof/_bundle/dockerfiles/locks/multimodal-transformers4576.artifacts.json +635 -0
- acprof/_bundle/dockerfiles/locks/multimodal-transformers4576.txt +181 -0
- acprof/_bundle/dockerfiles/locks/nlp-cpu.artifacts.json +363 -0
- acprof/_bundle/dockerfiles/locks/nlp-cpu.txt +103 -0
- acprof/_bundle/dockerfiles/locks/nlp-cu124.artifacts.json +460 -0
- acprof/_bundle/dockerfiles/locks/nlp-cu124.txt +131 -0
- acprof/_bundle/dockerfiles/locks/nlp-cu128.artifacts.json +495 -0
- acprof/_bundle/dockerfiles/locks/nlp-cu128.txt +141 -0
- acprof/_bundle/dockerfiles/locks/onnxruntime-cpu.artifacts.json +261 -0
- acprof/_bundle/dockerfiles/locks/onnxruntime-cpu.txt +73 -0
- acprof/_bundle/dockerfiles/locks/platform-cpu.artifacts.json +99 -0
- acprof/_bundle/dockerfiles/locks/platform-cpu.txt +27 -0
- acprof/_bundle/dockerfiles/locks/platform-cu124.artifacts.json +196 -0
- acprof/_bundle/dockerfiles/locks/platform-cu124.txt +55 -0
- acprof/_bundle/dockerfiles/locks/platform-cu128.artifacts.json +231 -0
- acprof/_bundle/dockerfiles/locks/platform-cu128.txt +65 -0
- acprof/_bundle/dockerfiles/locks/platform-python-cpu.artifacts.json +37 -0
- acprof/_bundle/dockerfiles/locks/platform-python-cpu.txt +9 -0
- acprof/_bundle/dockerfiles/locks/structured-cpu.artifacts.json +279 -0
- acprof/_bundle/dockerfiles/locks/structured-cpu.txt +79 -0
- acprof/_bundle/dockerfiles/locks/structured-cu124.artifacts.json +376 -0
- acprof/_bundle/dockerfiles/locks/structured-cu124.txt +107 -0
- acprof/_bundle/dockerfiles/locks/structured-cu128.artifacts.json +411 -0
- acprof/_bundle/dockerfiles/locks/structured-cu128.txt +117 -0
- acprof/_bundle/dockerfiles/locks/system-trixie-amd64.json +620 -0
- acprof/_bundle/dockerfiles/locks/timeseries-cpu.artifacts.json +314 -0
- acprof/_bundle/dockerfiles/locks/timeseries-cpu.txt +89 -0
- acprof/_bundle/dockerfiles/locks/timeseries-cu124.artifacts.json +411 -0
- acprof/_bundle/dockerfiles/locks/timeseries-cu124.txt +117 -0
- acprof/_bundle/dockerfiles/locks/timeseries-cu128.artifacts.json +446 -0
- acprof/_bundle/dockerfiles/locks/timeseries-cu128.txt +127 -0
- acprof/_bundle/dockerfiles/locks/transformers5104-cpu.artifacts.json +594 -0
- acprof/_bundle/dockerfiles/locks/transformers5104-cpu.txt +169 -0
- acprof/_bundle/dockerfiles/locks/transformers5104-cu124.artifacts.json +691 -0
- acprof/_bundle/dockerfiles/locks/transformers5104-cu124.txt +197 -0
- acprof/_bundle/dockerfiles/locks/transformers5104-cu128.artifacts.json +726 -0
- acprof/_bundle/dockerfiles/locks/transformers5104-cu128.txt +207 -0
- acprof/_bundle/dockerfiles/platform.Dockerfile +22 -0
- acprof/_bundle/dockerfiles/requirements/audio.in +5 -0
- acprof/_bundle/dockerfiles/requirements/custom-multimodal.in +2 -0
- acprof/_bundle/dockerfiles/requirements/cv.in +4 -0
- acprof/_bundle/dockerfiles/requirements/diffusion.in +6 -0
- acprof/_bundle/dockerfiles/requirements/moss-transformers5104.in +9 -0
- acprof/_bundle/dockerfiles/requirements/multimodal-transformers4576.in +3 -0
- acprof/_bundle/dockerfiles/requirements/nlp.in +7 -0
- acprof/_bundle/dockerfiles/requirements/onnxruntime.in +9 -0
- acprof/_bundle/dockerfiles/requirements/service.in +8 -0
- acprof/_bundle/dockerfiles/requirements/structured.in +4 -0
- acprof/_bundle/dockerfiles/requirements/timeseries.in +2 -0
- acprof/_bundle/dockerfiles/requirements/timm.in +1 -0
- acprof/_bundle/dockerfiles/requirements/transformers5104.in +4 -0
- acprof/_bundle/dockerfiles/runtime-final.Dockerfile +34 -0
- acprof/_bundle/dockerfiles/runtime-model.Dockerfile +19 -0
- acprof/_bundle/dockerfiles/runtime.Dockerfile +23 -0
- acprof/_bundle/examples/coverage/regression.json +17 -0
- acprof/_bundle/examples/hardware-validation.json +19 -0
- acprof/_bundle/examples/multimodal/ultravox.model.json +29 -0
- acprof/_bundle/examples/nlp/smoke.py +111 -0
- acprof/_bundle/examples/onnxruntime/fixtures.py +164 -0
- acprof/_bundle/examples/onnxruntime/iris.json +16 -0
- acprof/_bundle/examples/onnxruntime/iris.model.json +7 -0
- acprof/_bundle/examples/onnxruntime/real_models.py +155 -0
- acprof/_bundle/examples/onnxruntime/smoke.py +68 -0
- acprof/_bundle/examples/structured/chronos_smoke.py +56 -0
- acprof/_bundle/examples/structured/export_models.py +71 -0
- acprof/_bundle/examples/structured/smoke.py +71 -0
- acprof/_bundle/licenses/CC-BY-4.0.txt +156 -0
- acprof/analysis/__init__.py +1 -0
- acprof/analysis/audit.py +276 -0
- acprof/analysis/comparison.py +364 -0
- acprof/analysis/compatibility.py +223 -0
- acprof/analysis/conditions.py +185 -0
- acprof/analysis/independent_comparison.py +191 -0
- acprof/analysis/latency_model.py +1106 -0
- acprof/analysis/latency_report.py +577 -0
- acprof/analysis/model.py +276 -0
- acprof/analysis/precision.py +51 -0
- acprof/analysis/uncertainty.py +144 -0
- acprof/application/__init__.py +1 -0
- acprof/application/download.py +14 -0
- acprof/application/errors.py +5 -0
- acprof/application/notifications.py +302 -0
- acprof/application/preparation.py +333 -0
- acprof/application/resources.py +66 -0
- acprof/application/run.py +462 -0
- acprof/application/terminal_log.py +136 -0
- acprof/artifact_layout.py +261 -0
- acprof/artifacts.py +161 -0
- acprof/capabilities.py +404 -0
- acprof/cli/__init__.py +1 -0
- acprof/cli/audit.py +74 -0
- acprof/cli/auto.py +41 -0
- acprof/cli/backfill_compute.py +498 -0
- acprof/cli/compare.py +34 -0
- acprof/cli/coverage.py +70 -0
- acprof/cli/doctor.py +47 -0
- acprof/cli/inspect.py +101 -0
- acprof/cli/load.py +190 -0
- acprof/cli/main.py +64 -0
- acprof/cli/model_store.py +22 -0
- acprof/cli/plot.py +211 -0
- acprof/cli/posthoc.py +113 -0
- acprof/cli/probe.py +186 -0
- acprof/cli/report.py +35 -0
- acprof/cli/results.py +37 -0
- acprof/cli/run.py +54 -0
- acprof/cli/stats.py +94 -0
- acprof/cli/tui.py +65 -0
- acprof/config.py +177 -0
- acprof/container/__init__.py +1 -0
- acprof/container/compat/__init__.py +1 -0
- acprof/container/compat/transformers_dynamic.py +54 -0
- acprof/container/compat/transformers_model_types.json +1091 -0
- acprof/container/compute_profile_runner.py +392 -0
- acprof/container/download_model.py +165 -0
- acprof/container/execution.py +73 -0
- acprof/container/handlers/__init__.py +298 -0
- acprof/container/handlers/audio.py +743 -0
- acprof/container/handlers/custom_pipeline.py +74 -0
- acprof/container/handlers/cv.py +321 -0
- acprof/container/handlers/diffusion.py +728 -0
- acprof/container/handlers/moss.py +64 -0
- acprof/container/handlers/multimodal.py +609 -0
- acprof/container/handlers/nlp.py +747 -0
- acprof/container/handlers/onnx_tasks.py +231 -0
- acprof/container/handlers/onnxruntime.py +90 -0
- acprof/container/handlers/structured.py +185 -0
- acprof/container/handlers/timeseries.py +178 -0
- acprof/container/load_policy.py +81 -0
- acprof/container/loading_quality.py +48 -0
- acprof/container/local_pipeline.py +31 -0
- acprof/container/model_files.py +280 -0
- acprof/container/model_probe.py +80 -0
- acprof/container/onnx_session.py +150 -0
- acprof/container/runtime_manifest.py +150 -0
- acprof/container/runtime_validate.py +156 -0
- acprof/container/server.py +209 -0
- acprof/container/torch_execution.py +55 -0
- acprof/container/validation.py +172 -0
- acprof/cpu_affinity.py +35 -0
- acprof/dependency_locks.py +129 -0
- acprof/experiment.py +356 -0
- acprof/extensions/__init__.py +294 -0
- acprof/extensions/builtin/manifest.json +3591 -0
- acprof/extensions/onnxruntime/manifest.json +191 -0
- acprof/extensions/schema.py +238 -0
- acprof/extensions/transformers/4.57.6.json +1639 -0
- acprof/extensions/transformers/5.10.4.json +1812 -0
- acprof/failures.py +115 -0
- acprof/hardware_conditions.py +18 -0
- acprof/hf_download.py +143 -0
- acprof/hf_endpoints.py +62 -0
- acprof/hf_transport.py +238 -0
- acprof/host/__init__.py +1 -0
- acprof/host/automation.py +161 -0
- acprof/host/client.py +520 -0
- acprof/host/collection_history.py +77 -0
- acprof/host/collection_workflow.py +285 -0
- acprof/host/command.py +119 -0
- acprof/host/container_lifecycle.py +225 -0
- acprof/host/container_state.py +128 -0
- acprof/host/coverage_state.py +259 -0
- acprof/host/detect.py +669 -0
- acprof/host/docker_runtime.py +359 -0
- acprof/host/doctor.py +158 -0
- acprof/host/env_utils.py +233 -0
- acprof/host/execution_conditions.py +87 -0
- acprof/host/gpu_device.py +66 -0
- acprof/host/hardware_conditions.py +130 -0
- acprof/host/images/__init__.py +1 -0
- acprof/host/images/dependencies.py +169 -0
- acprof/host/images/environment.py +313 -0
- acprof/host/images/graph.py +143 -0
- acprof/host/images/identity.py +6 -0
- acprof/host/images/inventory.py +445 -0
- acprof/host/images/runtime.py +457 -0
- acprof/host/images/scan.py +154 -0
- acprof/host/input_plan.py +1056 -0
- acprof/host/interface_probe.py +141 -0
- acprof/host/largest_scale_probe.py +566 -0
- acprof/host/matrix_plan.py +98 -0
- acprof/host/measurement/__init__.py +1 -0
- acprof/host/measurement/boundary.py +162 -0
- acprof/host/measurement/capture.py +139 -0
- acprof/host/measurement/checkpoint.py +275 -0
- acprof/host/measurement/config.py +212 -0
- acprof/host/measurement/diagnostics.py +247 -0
- acprof/host/measurement/energy_validation.py +172 -0
- acprof/host/measurement/errors.py +25 -0
- acprof/host/measurement/execution.py +396 -0
- acprof/host/measurement/load.py +237 -0
- acprof/host/measurement/metrics.py +975 -0
- acprof/host/measurement/monitors.py +143 -0
- acprof/host/measurement/publication.py +171 -0
- acprof/host/measurement/requests.py +97 -0
- acprof/host/measurement/types.py +82 -0
- acprof/host/model_coverage.py +337 -0
- acprof/host/model_errors.py +116 -0
- acprof/host/model_inspection.py +107 -0
- acprof/host/model_schema.py +35 -0
- acprof/host/model_store.py +733 -0
- acprof/host/network_preflight.py +229 -0
- acprof/host/orchestrator.py +1133 -0
- acprof/host/permissions.py +117 -0
- acprof/host/platform_metadata.py +63 -0
- acprof/host/posthoc/__init__.py +12 -0
- acprof/host/posthoc/backfill.py +415 -0
- acprof/host/posthoc/context.py +400 -0
- acprof/host/posthoc/plans.py +597 -0
- acprof/host/posthoc/service.py +303 -0
- acprof/host/posthoc/storage.py +491 -0
- acprof/host/preflight.py +370 -0
- acprof/host/profiling/__init__.py +1 -0
- acprof/host/profiling/compute.py +436 -0
- acprof/host/profiling/compute_plan.py +261 -0
- acprof/host/profiling/execution.py +547 -0
- acprof/host/profiling/execution_plan.py +576 -0
- acprof/host/profiling/progress.py +83 -0
- acprof/host/profiling/support.py +252 -0
- acprof/host/profiling/tools/__init__.py +1 -0
- acprof/host/profiling/tools/advisor.py +164 -0
- acprof/host/profiling/tools/compute_parsers.py +409 -0
- acprof/host/profiling/tools/execution_environment.py +135 -0
- acprof/host/profiling/tools/execution_parsers.py +364 -0
- acprof/host/profiling/tools/massif.py +418 -0
- acprof/host/profiling/tools/ncu.py +696 -0
- acprof/host/profiling/tools/nsys.py +326 -0
- acprof/host/profiling/tools/tool_discovery.py +229 -0
- acprof/host/profiling/tools/torch.py +158 -0
- acprof/host/result_cleanup.py +65 -0
- acprof/host/run_state.py +639 -0
- acprof/host/runtime_settings.py +10 -0
- acprof/host/runtime_validation.py +302 -0
- acprof/host/source_bundle.py +96 -0
- acprof/host/startup_probe.py +95 -0
- acprof/host/static_metadata.py +936 -0
- acprof/host/task_support.py +121 -0
- acprof/installation.py +26 -0
- acprof/latency_slo.py +62 -0
- acprof/messages.py +26 -0
- acprof/metric_registry.py +315 -0
- acprof/model_candidates.py +297 -0
- acprof/model_contract.py +234 -0
- acprof/model_dependencies.py +93 -0
- acprof/model_dependency_domain.py +45 -0
- acprof/model_dependency_eval.py +438 -0
- acprof/model_dependency_flow.py +200 -0
- acprof/model_evidence.py +115 -0
- acprof/model_metadata_analysis.py +156 -0
- acprof/model_repository.py +149 -0
- acprof/model_resolution.py +129 -0
- acprof/model_review.py +155 -0
- acprof/model_source_analysis.py +299 -0
- acprof/model_spec.py +204 -0
- acprof/model_support.py +105 -0
- acprof/model_transforms.py +81 -0
- acprof/monitors/__init__.py +1 -0
- acprof/monitors/common.py +63 -0
- acprof/monitors/energy_cpu.py +651 -0
- acprof/monitors/energy_nvml.py +381 -0
- acprof/monitors/gpu_metrics.py +123 -0
- acprof/monitors/interfaces.py +74 -0
- acprof/monitors/perf_mips.py +617 -0
- acprof/monitors/rapl_topology.py +100 -0
- acprof/monitors/resource_metrics.py +472 -0
- acprof/monitors/resource_readers.py +435 -0
- acprof/monitors/resource_usage.py +450 -0
- acprof/monitors/sampling.py +79 -0
- acprof/network_policy.py +182 -0
- acprof/notifications.py +279 -0
- acprof/packet/__init__.py +1 -0
- acprof/packet/merge_packet_latency.py +369 -0
- acprof/packet/sniff_parse_pcap.py +240 -0
- acprof/pixel_metrics.py +103 -0
- acprof/platform.py +180 -0
- acprof/plotting/__init__.py +1 -0
- acprof/plotting/config.py +487 -0
- acprof/plotting/data.py +236 -0
- acprof/plotting/diagnostics.py +747 -0
- acprof/plotting/latency.py +638 -0
- acprof/plotting/metrics.py +648 -0
- acprof/plotting/plotly-LICENSE.txt +21 -0
- acprof/plotting/report.css +61 -0
- acprof/plotting/report.html +68 -0
- acprof/plotting/report.js +295 -0
- acprof/plotting/report.py +66 -0
- acprof/plotting/styles.py +111 -0
- acprof/plotting/view_model.js +145 -0
- acprof/precision.py +42 -0
- acprof/preparation_events.py +78 -0
- acprof/progress_events.py +105 -0
- acprof/quality.py +153 -0
- acprof/resource_budget.py +29 -0
- acprof/result_csv.py +263 -0
- acprof/result_layers.py +365 -0
- acprof/run_args.py +223 -0
- acprof/run_options.py +225 -0
- acprof/runtime_dependencies.py +195 -0
- acprof/runtime_profiles.py +258 -0
- acprof/runtime_settings.py +72 -0
- acprof/source_identity.py +68 -0
- acprof/telemetry.py +225 -0
- acprof/testing/__init__.py +1 -0
- acprof/testing/evidence.py +117 -0
- acprof/testing/plugin.py +126 -0
- acprof/testing/provenance.py +53 -0
- acprof/testing/sharding.py +14 -0
- acprof/tui/__init__.py +1 -0
- acprof/tui/app.py +934 -0
- acprof/tui/app_contracts.py +43 -0
- acprof/tui/catalog_controller.py +120 -0
- acprof/tui/commands.py +209 -0
- acprof/tui/configuration_controller.py +436 -0
- acprof/tui/diagnostics.py +340 -0
- acprof/tui/downloads.py +56 -0
- acprof/tui/environment.py +248 -0
- acprof/tui/experiment_catalog.py +279 -0
- acprof/tui/experiment_controller.py +132 -0
- acprof/tui/experiment_picker.py +273 -0
- acprof/tui/field_validation.py +62 -0
- acprof/tui/i18n.py +57 -0
- acprof/tui/image_controller.py +525 -0
- acprof/tui/images.py +737 -0
- acprof/tui/input.py +191 -0
- acprof/tui/localization_controller.py +110 -0
- acprof/tui/log.py +310 -0
- acprof/tui/model_candidates.py +278 -0
- acprof/tui/model_controller.py +111 -0
- acprof/tui/model_input.py +12 -0
- acprof/tui/model_store.py +166 -0
- acprof/tui/preflight_controller.py +271 -0
- acprof/tui/preparation.py +269 -0
- acprof/tui/presentation.py +46 -0
- acprof/tui/process.py +111 -0
- acprof/tui/process_controller.py +218 -0
- acprof/tui/profile_controller.py +109 -0
- acprof/tui/progress.py +195 -0
- acprof/tui/recovery.py +114 -0
- acprof/tui/recovery_controller.py +169 -0
- acprof/tui/rendering.py +75 -0
- acprof/tui/reports.py +303 -0
- acprof/tui/result_controller.py +279 -0
- acprof/tui/review_inputs.py +54 -0
- acprof/tui/run_form.py +125 -0
- acprof/tui/run_planning.py +97 -0
- acprof/tui/run_results.py +175 -0
- acprof/tui/scrollbar.py +65 -0
- acprof/tui/settings.py +203 -0
- acprof/tui/slash_controller.py +95 -0
- acprof/tui/stages.py +97 -0
- acprof/tui/storage.py +150 -0
- acprof/tui/table.py +213 -0
- acprof/tui/themes.py +112 -0
- acprof/tui/translation_catalog.py +1861 -0
- acprof/tui/tui.tcss +373 -0
- acprof/tui/views.py +706 -0
- acprof/window_records.py +165 -0
- acprof/workloads/__init__.py +222 -0
- acprof/workloads/audio.py +621 -0
- acprof/workloads/contract.py +116 -0
- acprof/workloads/cv.py +240 -0
- acprof/workloads/diffusion.py +410 -0
- acprof/workloads/multimodal.py +329 -0
- acprof/workloads/nlp.py +151 -0
- acprof/workloads/structured.py +151 -0
- acprof/workloads/timeseries.py +69 -0
- acprof-0.3.0.dist-info/METADATA +117 -0
- acprof-0.3.0.dist-info/RECORD +704 -0
- acprof-0.3.0.dist-info/WHEEL +4 -0
- acprof-0.3.0.dist-info/entry_points.txt +2 -0
- acprof-0.3.0.dist-info/licenses/LICENSE +202 -0
- acprof-0.3.0.dist-info/licenses/NOTICE +43 -0
- 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."""
|