Profile additional Qualcomm model components

This commit is contained in:
tzhouam committed 2026-09-24 09:31:53 +08:00
1 parent 5d81c3678b
commit 698f8c13d9
21 files changed
+35175 -41

No files matched your search

@@ -6,6 +6,8 @@ from __future__ import annotations
import argparse
import hashlib
import json
import math
from collections import Counter
from pathlib import Path
import numpy as np
@@ -61,6 +63,7 @@ def main() -> None:
parser.add_argument("--output-report", type=Path, required=True)
parser.add_argument("--expected-compile-options", default=COMPILE_OPTIONS)
parser.add_argument("--expected-run-options", default="--compute_unit npu")
parser.add_argument("--profile-report", type=Path)
args = parser.parse_args()
compiled = json.loads(args.compile_report.read_text(encoding="utf-8"))
@@ -143,10 +146,39 @@ def main() -> None:
"limits": [
"The historical source export does not attest an exact checkpoint revision.",
"The fixture is synthetic and has no token-to-audio quality tolerance.",
"Requested compute unit is not actual placement without a device profile.",
"No predictor, vocoder, persistent cache loop or complete TTS stream was tested.",
],
}
if args.profile_report is not None:
profiled = json.loads(args.profile_report.read_text(encoding="utf-8"))
if (profiled.get("status") != "SUCCESS"
or profiled.get("model_id") != compiled["target_model_id"]
or profiled.get("device") != inferred["device"]
or profiled.get("options") != args.expected_run_options):
raise ValueError("profile did not execute the same target, device and route")
summary = profiled["profile"]["execution_summary"]
samples = summary["all_inference_times"]
if not samples or any(not isinstance(value, int) or value <= 0 for value in samples):
raise ValueError("profile has no valid inference samples")
units = Counter(row.get("compute_unit") for row in profiled["profile"]["execution_detail"])
if not units:
raise ValueError("profile has no compute-unit detail")
ordered = sorted(samples)
report["profile"] = {
"job_id": profiled["job_id"],
"sample_count": len(samples),
"sample_min_us": ordered[0],
"nearest_rank_p50_us": ordered[math.ceil(0.50 * len(samples)) - 1],
"nearest_rank_p95_us": ordered[math.ceil(0.95 * len(samples)) - 1],
"reported_estimated_inference_time_us": summary["estimated_inference_time"],
"reported_peak_memory_bytes": summary["estimated_inference_peak_memory"],
"reported_first_load_time_us": summary["first_load_time"],
"reported_first_load_peak_memory_bytes": summary["first_load_peak_memory"],
"compute_unit_row_counts": dict(units),
}
report["status"] = "component_inference_numeric_and_placement_measured"
else:
report["limits"].append("Requested compute unit is not actual placement without a device profile.")
args.output_report.write_text(json.dumps(report, indent=2) + "\n", encoding="utf-8")
print(json.dumps({
"status": report["status"],
@@ -29,6 +29,7 @@ def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
for name in ("model-dir", "cosmos-dir", "processor-dir", "fixture", "device-output", "audit-report", "output"):
parser.add_argument(f"--{name}", type=Path, required=True)
parser.add_argument("--device-name", default="Samsung Galaxy S25")
args = parser.parse_args()
os.environ["INTERNVLA_A1_COSMOS_DIR"] = str(args.cosmos_dir.resolve(strict=True))
@@ -48,10 +49,13 @@ def main() -> None:
if sha256(checkpoint) != CHECKPOINT_SHA256 or sha256(args.fixture) != FIXTURE_SHA256:
raise ValueError("checkpoint or encoder fixture differs from pinned source")
audit = json.loads(args.audit_report.read_text(encoding="utf-8"))
if (audit.get("status") != "component_inference_numeric_measured"
or audit.get("device", {}).get("name") != "Samsung Galaxy S25"
if (audit.get("status") not in {
"component_inference_numeric_measured",
"component_inference_numeric_and_placement_measured",
}
or audit.get("device", {}).get("name") != args.device_name
or audit.get("files", {}).get("device_output", {}).get("sha256") != sha256(args.device_output)):
raise ValueError("hosted latent lacks audited S25 provenance")
raise ValueError(f"hosted latent lacks audited {args.device_name} provenance")
with np.load(args.fixture, allow_pickle=False) as fixture:
source_latent = np.asarray(fixture["pattern_reference"])
with np.load(args.device_output, allow_pickle=False) as output:
@@ -130,8 +134,9 @@ def main() -> None:
hosted = hosted_actions.astype(np.float64).ravel()
delta = source - hosted
report = {
"scope": "S25 hosted Cosmos latent injected into local CPU InternVLA policy with synthetic state/noise; no device-local policy or robot-task result",
"scope": f"{args.device_name} hosted Cosmos latent injected into local CPU InternVLA policy with synthetic state/noise; no device-local policy or robot-task result",
"status": "synthetic_action_sensitivity_measured",
"hosted_device_name": args.device_name,
"policy_checkpoint_sha256": CHECKPOINT_SHA256,
"fixture_sha256": FIXTURE_SHA256,
"hosted_output_sha256": sha256(args.device_output),