Spaces:
Running
Running
| from __future__ import annotations | |
| import importlib | |
| import re | |
| import sys | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| README = (ROOT / "README.md").read_text() | |
| SRC = ROOT / "src" | |
| sys.path.insert(0, str(SRC)) | |
| inferscale = importlib.import_module("inferscale") | |
| __version__ = inferscale.__version__ | |
| design_space_search = inferscale.design_space_search | |
| run_simulation = inferscale.run_simulation | |
| errors: list[str] = [] | |
| match = re.search(r"^short_description:\s*(.+)$", README, re.MULTILINE) | |
| if not match: | |
| errors.append("README metadata is missing short_description") | |
| short = "" | |
| else: | |
| short = match.group(1).strip().strip('"\'') | |
| if len(short) > 60: | |
| errors.append(f"short_description is {len(short)} chars; HF limit is 60") | |
| if "sdk: static" not in README: | |
| errors.append("README metadata must use sdk: static") | |
| if __version__ != "0.3.0": | |
| errors.append(f"package version is {__version__}; expected 0.3.0") | |
| src_files = sorted((ROOT / "src" / "inferscale").glob("*.py")) | |
| web_files = sorted((ROOT / "py" / "inferscale").glob("*.py")) | |
| if [path.name for path in src_files] != [path.name for path in web_files]: | |
| errors.append("browser Python mirror is stale; run python scripts/sync_web_python.py") | |
| else: | |
| for src, web in zip(src_files, web_files, strict=True): | |
| if src.read_bytes() != web.read_bytes(): | |
| errors.append(f"browser mirror differs for {src.name}; run sync_web_python.py") | |
| worker_text = (ROOT / "worker.mjs").read_text() | |
| for src in src_files: | |
| if f'"{src.name}"' not in worker_text: | |
| errors.append(f"worker module list is missing {src.name}") | |
| for ui_file in (ROOT / "index.html", ROOT / "app.js"): | |
| try: | |
| ui_file.read_text().encode("ascii") | |
| except UnicodeEncodeError: | |
| errors.append(f"{ui_file.name} contains non-ASCII UI glyphs; use text labels for reliable rendering") | |
| index = (ROOT / "index.html").read_text() | |
| app = (ROOT / "app.js").read_text() | |
| if "<footer" in index.lower(): | |
| errors.append("v0.3 UI should not include the old product-style footer") | |
| if "Download PNG" not in index or ".chart-download" not in app: | |
| errors.append("chart PNG export controls are missing") | |
| if "Worst repetition" not in index or "Target" not in index: | |
| errors.append("capacity evidence columns are missing") | |
| smoke_cfg = { | |
| "model": "Qwen2.5-3B", | |
| "accelerator": "L4", | |
| "quantization": "int8", | |
| "duration_s": 4, | |
| "request_rate_rps": 1, | |
| "prompt_tokens_mean": 128, | |
| "output_tokens_mean": 8, | |
| } | |
| try: | |
| smoke = run_simulation(smoke_cfg) | |
| if smoke["summary"]["requests_completed"] <= 0: | |
| errors.append("simulation smoke test completed zero requests") | |
| if smoke["provenance"]["latency_profile_type"] != "analytical-reference": | |
| errors.append("profile provenance guard is missing") | |
| if smoke["diagnostics"].get("provenance") != "heuristic-simulator-diagnosis": | |
| errors.append("diagnosis provenance missing") | |
| if "prefix_cache_hit_rate" not in smoke["resource"]: | |
| errors.append("prefix-cache telemetry missing") | |
| except Exception as exc: # pragma: no cover | |
| errors.append(f"colocated smoke test raised: {exc}") | |
| try: | |
| pd = run_simulation(smoke_cfg | { | |
| "topology": "disaggregated_pd", | |
| "scheduler": "continuous_slo", | |
| "prefill_accelerator": "L4", | |
| "decode_accelerator": "L4", | |
| "interconnect_gbps": 50, | |
| }) | |
| if pd["provenance"].get("topology") != "disaggregated_pd": | |
| errors.append("P/D provenance missing") | |
| if pd["resource"].get("p95_transfer_ms", 0) <= 0: | |
| errors.append("P/D transfer telemetry missing") | |
| except Exception as exc: # pragma: no cover | |
| errors.append(f"P/D smoke test raised: {exc}") | |
| try: | |
| design = design_space_search(smoke_cfg | { | |
| "shared_prefix_tokens": 64, | |
| "prefix_reuse_fraction": 0.5, | |
| "prefill_accelerator": "L4", | |
| "decode_accelerator": "L4", | |
| }, include_disaggregated=False) | |
| if design["candidate_count"] != 10 or design["pareto_count"] < 1 or design["efficiency_pareto_count"] < 1: | |
| errors.append("design-space smoke test did not return both expected Pareto frontiers") | |
| except Exception as exc: # pragma: no cover | |
| errors.append(f"design-space smoke test raised: {exc}") | |
| if errors: | |
| print("InferScale release check: FAIL") | |
| for error in errors: | |
| print(f"- {error}") | |
| raise SystemExit(1) | |
| print("InferScale release check: PASS") | |
| print(f"Version: {__version__}") | |
| print(f"HF short_description: {len(short)}/60 characters") | |
| print(f"Python modules mirrored: {len(src_files)}") | |
| print(f"Colocated smoke requests: {smoke['summary']['requests_completed']}") | |
| print(f"P/D transfer p95: {pd['resource']['p95_transfer_ms']:.3f} ms") | |
| print( | |
| f"Design candidates: {design['candidate_count']} " | |
| f"({design['pareto_count']} performance Pareto, {design['efficiency_pareto_count']} efficiency Pareto)" | |
| ) | |
| print(f"Profile provenance: {smoke['provenance']['latency_profile_type']}") | |