Audit all mobile and PC model pairings with archived evidence
This commit is contained in:
1 parent
1887d8294b
commit
ab2f2a3d65
48 files changed
+49116
-18
No files matched your search
+29
@@ -0,0 +1,29 @@
|
||||
"""Inspect CPU attention operator availability; this is not a model execution."""
|
||||
|
||||
import argparse
|
||||
import importlib.metadata
|
||||
import json
|
||||
import platform
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import torch
|
||||
from vllm.platforms import current_platform
|
||||
|
||||
current_platform.import_kernels()
|
||||
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument("--out", type=Path, required=True)
|
||||
a = p.parse_args()
|
||||
names = ("cpu_attn_reshape_and_cache", "cpu_attn_get_scheduler_metadata")
|
||||
record = {
|
||||
"platform": platform.platform(),
|
||||
"vllm": importlib.metadata.version("vllm"),
|
||||
"torch": torch.__version__,
|
||||
"extensions": {
|
||||
name: getattr(module, "__file__", None) for name, module in sys.modules.items() if name.startswith("vllm._C")
|
||||
},
|
||||
"cpu_attention_operators": {name: hasattr(torch.ops._C, name) for name in names},
|
||||
}
|
||||
a.out.write_text(json.dumps(record, indent=2) + "\n")
|
||||
print(record["cpu_attention_operators"])
|
||||
@@ -0,0 +1,80 @@
|
||||
"""Read-only local artifact/runtime preflight; never claims inference success."""
|
||||
|
||||
import argparse
|
||||
import importlib.metadata
|
||||
import json
|
||||
import platform
|
||||
import subprocess
|
||||
import sys
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument("--workspace", type=Path, required=True)
|
||||
p.add_argument("--out", type=Path, required=True)
|
||||
a = p.parse_args()
|
||||
record = {
|
||||
"timestamp": datetime.now(timezone.utc).isoformat(),
|
||||
"platform": platform.platform(),
|
||||
"python": sys.executable,
|
||||
"evidence": "preflight",
|
||||
"packages": {},
|
||||
"search_roots": [],
|
||||
"artifacts": [],
|
||||
}
|
||||
for name in ("vllm", "torch", "transformers", "onnxruntime", "onnxruntime-directml"):
|
||||
try:
|
||||
record["packages"][name] = importlib.metadata.version(name)
|
||||
except importlib.metadata.PackageNotFoundError:
|
||||
record["packages"][name] = None
|
||||
roots = [a.workspace / "models", Path.home() / ".cache/huggingface/hub"]
|
||||
if sys.platform == "win32":
|
||||
roots += [Path.home() / "w2/models"]
|
||||
else:
|
||||
roots += [Path("/mnt/c/Users/zhout/w2/models")]
|
||||
for root in roots:
|
||||
record["search_roots"].append({"path": str(root), "exists": root.is_dir()})
|
||||
if not root.is_dir():
|
||||
continue
|
||||
for item in root.iterdir():
|
||||
if not item.is_dir() or not any(x in item.name.lower() for x in ("spark", "qwen3", "minicpm", "internvla")):
|
||||
continue
|
||||
configs = list(item.glob("config.json")) + list(item.glob("snapshots/*/config.json"))
|
||||
for config in configs:
|
||||
try:
|
||||
data = json.loads(config.read_text(encoding="utf-8"))
|
||||
weights = list(config.parent.glob("*.safetensors"))
|
||||
record["artifacts"].append(
|
||||
{
|
||||
"directory": str(config.parent),
|
||||
"name": item.name,
|
||||
"model_type": data.get("model_type"),
|
||||
"architectures": data.get("architectures"),
|
||||
"weight_shards": len(weights),
|
||||
"weight_bytes": sum(f.stat().st_size for f in weights),
|
||||
}
|
||||
)
|
||||
except OSError as error:
|
||||
record["artifacts"].append({"directory": str(config.parent), "error": str(error)})
|
||||
try:
|
||||
from vllm.platforms import current_platform
|
||||
|
||||
record["vllm_platform"] = current_platform.device_type
|
||||
from vllm_omni.config.pipeline_registry import resolve_pipeline_config
|
||||
|
||||
record["registered_pipelines"] = {
|
||||
kind: resolve_pipeline_config(kind) is not None for kind in ("spark2_5", "qwen3_tts", "qwen3_5", "minicpmo_4_5")
|
||||
}
|
||||
except Exception as error:
|
||||
record["runtime_import_error"] = repr(error)
|
||||
for command in (
|
||||
["nvidia-smi", "--query-gpu=name,memory.total,memory.free", "--format=csv,noheader"],
|
||||
["adb", "devices", "-l"],
|
||||
):
|
||||
try:
|
||||
result = subprocess.run(command, capture_output=True, text=True, timeout=20)
|
||||
record[command[0]] = {"returncode": result.returncode, "stdout": result.stdout, "stderr": result.stderr}
|
||||
except (OSError, subprocess.TimeoutExpired) as error:
|
||||
record[command[0]] = {"error": str(error)}
|
||||
a.out.write_text(json.dumps(record, indent=2) + "\n", encoding="utf-8")
|
||||
print(f"Inventoried {len(record['artifacts'])} artifact directories; report: {a.out}")
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
"""Explicit AI Hub test facility; never imported by the local Omni runtime.
|
||||
|
||||
Pass an API token on stdin or use an already configured SDK profile. Secrets
|
||||
are never written to results. Inventory is read-only; profile/infer commands
|
||||
submit device jobs only for an explicitly supplied existing model ID.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import importlib.metadata
|
||||
import json
|
||||
import sys
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
import qai_hub as hub
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(__doc__)
|
||||
parser.add_argument("command", choices=("inventory", "profile", "infer", "collect"))
|
||||
parser.add_argument("--token-stdin", action="store_true")
|
||||
parser.add_argument("--out", type=Path, required=True)
|
||||
parser.add_argument("--model")
|
||||
parser.add_argument("--device", default="Samsung Galaxy S25")
|
||||
parser.add_argument("--options", default="--compute_unit npu")
|
||||
parser.add_argument("--inputs", type=Path)
|
||||
parser.add_argument("--reference-job", help="Reuse a prior inference job's exact dataset")
|
||||
parser.add_argument("--job")
|
||||
args = parser.parse_args()
|
||||
client = hub.Client(hub.ClientConfig(api_token=sys.stdin.readline().strip())) if args.token_stdin else hub.Client()
|
||||
record = {
|
||||
"timestamp_utc": datetime.now(timezone.utc).isoformat(),
|
||||
"qai_hub_version": importlib.metadata.version("qai-hub"),
|
||||
"facility": "Qualcomm AI Hub Workbench",
|
||||
"command": args.command,
|
||||
}
|
||||
if args.command == "inventory":
|
||||
devices = client.get_devices()
|
||||
record["devices"] = [{"name": d.name, "os": d.os, "attributes": d.attributes} for d in devices]
|
||||
jobs = client.get_job_summaries(limit=100)
|
||||
record["recent_jobs"] = [
|
||||
{
|
||||
"job_id": j.job_id,
|
||||
"name": j.name,
|
||||
"date": str(j.date),
|
||||
"status": j.status.code,
|
||||
"type": str(j.job_type),
|
||||
"device": j.device_name,
|
||||
"url": j.url,
|
||||
}
|
||||
for j in jobs
|
||||
]
|
||||
models = client.get_models(limit=100)
|
||||
record["models"] = [{"model_id": m.model_id, "name": m.name} for m in models]
|
||||
print(f"Connected: {len(devices)} device entries, {len(jobs)} recent jobs, {len(models)} models")
|
||||
elif args.command in ("profile", "infer"):
|
||||
if not args.model:
|
||||
parser.error("--model is required")
|
||||
kwargs = dict(
|
||||
model=client.get_model(args.model),
|
||||
device=hub.Device(args.device),
|
||||
name=f"omni-boundary-validation-{args.command}",
|
||||
options=args.options,
|
||||
)
|
||||
if args.command == "infer":
|
||||
import numpy as np
|
||||
|
||||
if bool(args.inputs) == bool(args.reference_job):
|
||||
parser.error("provide exactly one of --inputs or --reference-job")
|
||||
if args.reference_job:
|
||||
reference = client.get_job(args.reference_job)
|
||||
if not isinstance(reference, hub.InferenceJob):
|
||||
parser.error("reference must be an inference job")
|
||||
kwargs["inputs"] = reference.inputs
|
||||
record["reference_job"] = reference.job_id
|
||||
record["input_dataset_id"] = reference.inputs.dataset_id
|
||||
else:
|
||||
with np.load(args.inputs, allow_pickle=False) as data:
|
||||
kwargs["inputs"] = {name: [data[name]] for name in data.files}
|
||||
job = client.submit_inference_job(**kwargs)
|
||||
else:
|
||||
job = client.submit_profile_job(**kwargs)
|
||||
record.update(
|
||||
job_id=job.job_id, url=job.url, model_id=args.model, requested_device=args.device, options=args.options
|
||||
)
|
||||
print(f"Submitted {args.command}: {job.job_id}")
|
||||
else:
|
||||
if not args.job:
|
||||
parser.error("--job is required")
|
||||
job = client.get_job(args.job)
|
||||
status = job.get_status()
|
||||
record.update(
|
||||
job_id=job.job_id,
|
||||
url=job.url,
|
||||
status=status.code,
|
||||
status_message=status.message,
|
||||
options=job.options,
|
||||
hub_version=job.hub_version,
|
||||
)
|
||||
if hasattr(job, "device"):
|
||||
record["device"] = {"name": job.device.name, "os": job.device.os, "attributes": job.device.attributes}
|
||||
if hasattr(job, "model"):
|
||||
record["model_id"] = job.model.model_id
|
||||
if isinstance(job, hub.ProfileJob):
|
||||
record["shapes"] = job.shapes
|
||||
if isinstance(job, hub.InferenceJob):
|
||||
record["input_dataset_id"] = job.inputs.dataset_id
|
||||
if status.success:
|
||||
if isinstance(job, hub.ProfileJob):
|
||||
record["profile"] = job.download_profile()
|
||||
elif isinstance(job, hub.InferenceJob):
|
||||
import numpy as np
|
||||
|
||||
outputs = job.download_output_data()
|
||||
output_path = args.out.with_suffix(".npz")
|
||||
np.savez(
|
||||
output_path,
|
||||
**{f"{key}__{i}": value for key, values in outputs.items() for i, value in enumerate(values)},
|
||||
)
|
||||
record["outputs"] = output_path.name
|
||||
elif isinstance(job, hub.CompileJob):
|
||||
target = job.get_target_model()
|
||||
record["target_model_id"] = target.model_id if target else None
|
||||
print(f"Job {job.job_id}: {status.code}")
|
||||
args.out.parent.mkdir(parents=True, exist_ok=True)
|
||||
args.out.write_text(json.dumps(record, indent=2, default=str) + "\n", encoding="utf-8")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,67 @@
|
||||
"""Bounded, real-checkpoint public Omni startup/text probe (no model substitution)."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
import time
|
||||
import traceback
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument("--model", required=True)
|
||||
p.add_argument("--out", type=Path, required=True)
|
||||
a = p.parse_args()
|
||||
os.environ.setdefault("VLLM_USE_FLASHINFER_SAMPLER", "0")
|
||||
os.environ.setdefault("VLLM_WSL2_ENABLE_PIN_MEMORY", "1")
|
||||
from vllm_omni.windows.aio import install_selector_policy
|
||||
|
||||
install_selector_policy()
|
||||
from vllm import SamplingParams
|
||||
|
||||
from vllm_omni.entrypoints.omni import Omni
|
||||
|
||||
config = dict(
|
||||
model=a.model,
|
||||
language_model_only=True,
|
||||
max_model_len=512,
|
||||
max_num_seqs=1,
|
||||
max_num_batched_tokens=128,
|
||||
enforce_eager=True,
|
||||
gpu_memory_utilization=0.80,
|
||||
cpu_offload_gb=2,
|
||||
dtype="bfloat16",
|
||||
stage_init_timeout=120,
|
||||
)
|
||||
record = {
|
||||
"platform": platform.platform(),
|
||||
"config": config,
|
||||
"status": "starting",
|
||||
"scope": "public Omni, short text only; explicit 2 GiB native offload",
|
||||
"start": time.time(),
|
||||
}
|
||||
engine = None
|
||||
try:
|
||||
engine = Omni(**config)
|
||||
outputs = engine.generate(
|
||||
"Explain local inference in one sentence.", SamplingParams(temperature=0, max_tokens=16)
|
||||
)
|
||||
record["outputs"] = [str(output) for output in outputs]
|
||||
if not outputs:
|
||||
raise RuntimeError("No output")
|
||||
record["status"] = "completed"
|
||||
except Exception as error:
|
||||
record.update(status="failed", error=repr(error), traceback=traceback.format_exc())
|
||||
traceback.print_exc()
|
||||
finally:
|
||||
if engine is not None:
|
||||
engine.close()
|
||||
record["end"] = time.time()
|
||||
a.out.write_text(json.dumps(record, indent=2) + "\n", encoding="utf-8")
|
||||
print(record["status"], flush=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,69 @@
|
||||
"""Real-weight two-frame CPU TTS smoke probe, not full speech qualification."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
import traceback
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument("--model", required=True)
|
||||
p.add_argument("--out", type=Path, required=True)
|
||||
a = p.parse_args()
|
||||
os.environ.setdefault("VLLM_WORKER_MULTIPROC_METHOD", "spawn")
|
||||
record = {"model": a.model, "scope": "two codec frames only; no speech-quality claim", "start": time.time()}
|
||||
engine = None
|
||||
try:
|
||||
import torch
|
||||
from transformers import AutoTokenizer
|
||||
from vllm.platforms import current_platform
|
||||
|
||||
from vllm_omni.entrypoints.omni import Omni
|
||||
from vllm_omni.model_executor.models.qwen3_tts.configuration_qwen3_tts import Qwen3TTSConfig
|
||||
from vllm_omni.model_executor.models.qwen3_tts.prompt_embeds_builder import Qwen3TTSPromptEmbedsBuilder
|
||||
|
||||
assert current_platform.device_type == "cpu", "CPU probe must not silently use CUDA"
|
||||
config = Qwen3TTSConfig.from_pretrained(a.model)
|
||||
tok = AutoTokenizer.from_pretrained(a.model)
|
||||
info = {
|
||||
"task_type": ["CustomVoice"],
|
||||
"text": ["A short test."],
|
||||
"language": ["English"],
|
||||
"speaker": ["Vivian"],
|
||||
"max_new_tokens": [2],
|
||||
}
|
||||
length = Qwen3TTSPromptEmbedsBuilder.estimate_prompt_len_from_additional_information(
|
||||
additional_information=info,
|
||||
task_type="CustomVoice",
|
||||
tokenize_prompt=lambda x: tok(x, padding=False)["input_ids"],
|
||||
codec_language_id=config.talker_config.codec_language_id,
|
||||
spk_is_dialect=config.talker_config.spk_is_dialect,
|
||||
)
|
||||
engine = Omni(model=a.model, stage_init_timeout=120, parallel_stage_init=False)
|
||||
params = engine.default_sampling_params_list
|
||||
params[0].max_tokens = 2
|
||||
outputs = engine.generate({"prompt_token_ids": [0] * length, "additional_information": info}, params)
|
||||
chunks = []
|
||||
for output in outputs:
|
||||
if output.final_output_type == "audio":
|
||||
audio = output.outputs[0].multimodal_output.get("audio")
|
||||
chunks.extend(audio if isinstance(audio, list) else [audio])
|
||||
values = torch.cat([x.float().cpu().reshape(-1) for x in chunks if x is not None])
|
||||
assert values.numel() > 0 and torch.isfinite(values).all() and torch.any(values != 0)
|
||||
record.update(status="completed", samples=values.numel(), finite=True, nonzero=True)
|
||||
except Exception as error:
|
||||
record.update(status="failed", error=repr(error), traceback=traceback.format_exc())
|
||||
traceback.print_exc()
|
||||
finally:
|
||||
if engine is not None:
|
||||
engine.close()
|
||||
record["end"] = time.time()
|
||||
a.out.write_text(json.dumps(record, indent=2) + "\n")
|
||||
print(record["status"], flush=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
"""Same compiled artifact and dataset repeatability, not FP checkpoint quality."""
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
|
||||
root = Path(__file__).resolve().parent
|
||||
rows = []
|
||||
for model in ("tts", "minicpm"):
|
||||
reference = json.loads((root / f"{model}-s25-reference.json").read_text())
|
||||
current = json.loads((root / f"{model}-s25-repeat.json").read_text())
|
||||
assert current["status"] == "SUCCESS"
|
||||
assert current["model_id"] == reference["model_id"]
|
||||
assert current["input_dataset_id"] == reference["input_dataset_id"]
|
||||
with np.load(root / reference["outputs"]) as a, np.load(root / current["outputs"]) as b:
|
||||
assert set(a.files) == set(b.files)
|
||||
outputs = []
|
||||
for name in a.files:
|
||||
assert a[name].shape == b[name].shape
|
||||
outputs.append(
|
||||
{
|
||||
"name": name,
|
||||
"shape": list(b[name].shape),
|
||||
"finite": bool(np.isfinite(b[name]).all()),
|
||||
"exact": bool(np.array_equal(a[name], b[name])),
|
||||
"max_abs_difference": float(np.max(np.abs(a[name].astype(float) - b[name].astype(float)))),
|
||||
}
|
||||
)
|
||||
rows.append(
|
||||
{
|
||||
"model": model,
|
||||
"job": current["job_id"],
|
||||
"reference_job": reference["job_id"],
|
||||
"model_id": current["model_id"],
|
||||
"input_dataset_id": current["input_dataset_id"],
|
||||
"scope": "same compiled component repeatability only",
|
||||
"outputs": outputs,
|
||||
}
|
||||
)
|
||||
assert all(output["finite"] for row in rows for output in row["outputs"])
|
||||
(root / "hub-repeatability.json").write_text(json.dumps(rows, indent=2) + "\n")
|
||||
print([(row["model"], len(row["outputs"]), all(o["exact"] for o in row["outputs"])) for row in rows])
|
||||
Reference in new issue
Block a user