Download scripts/dsv41.py from nvidia/aisimulate-fpm-dataset: direct link, hf CLI and curl.
- Browser
- Download file 10.9 kB
-
https://huggingface.co/datasets/nvidia/aisimulate-fpm-dataset/resolve/main/scripts/dsv41.py
- Command line
-
hf download hf://datasets/nvidia/aisimulate-fpm-dataset/scripts/dsv41.py
-
curl -L -o dsv41.py https://huggingface.co/datasets/nvidia/aisimulate-fpm-dataset/resolve/main/scripts/dsv41.py
10.9 kB
| """Public AISimulate DSV4.1 schema-7 import policy; source bytes are immutable. | |
| This policy migrates committed calibration artifacts, not evaluation metrics. | |
| Historical backend placeholders and rejected GB200 data are never serving inputs. | |
| """ | |
| from __future__ import annotations | |
| import hashlib | |
| import json | |
| import math | |
| import re | |
| from pathlib import Path | |
| import pyarrow.parquet as pq | |
| CAMPAIGNS = {"dsv41-pr158", "dsv41-pr232", "dsv41-pr304"} | |
| REVIEWED_SOURCES = { | |
| 'b9f5380c1f69e80a69d3aca5f2bd2a6e9e744657b5d0836d8cac686786b9727f': {'source_pr': 304, 'row_count': 145, 'source_revision': 'f29a1bae99ef0c3552cf4de928883d756c4e9d2e', 'source_kind': 'source_qualified_native_calibration'}, | |
| '259ea01df76545ec8b859a1f8d7c624a9d93685bfffabc616fe527597fa53c78': {'source_pr': 304, 'row_count': 145, 'source_revision': 'a9c0c2b4fc65a890538288dded258521f3cb4a8e', 'source_kind': 'source_qualified_native_calibration'}, | |
| '4cac84a8d0b8521e5f6f04c7b973a57f0c983883a49b43630aca733019fabb86': {'source_pr': 304, 'row_count': 145, 'source_revision': 'a9c0c2b4fc65a890538288dded258521f3cb4a8e', 'source_kind': 'source_qualified_native_calibration'}, | |
| '8011fa4ba71df885fac48e7a62671830f759ca267219f7f93f57f6b339a4aa62': {'source_pr': 304, 'row_count': 145, 'source_revision': 'a9c0c2b4fc65a890538288dded258521f3cb4a8e', 'source_kind': 'source_qualified_native_calibration'}, | |
| "294b801d3c7dd5d66fb216b8ad8f6804767bb75585319718f2ebfab8aec32457": { | |
| "source_pr": 304, | |
| "row_count": 145, | |
| "source_revision": "31bf73d5f676dc1bebbe6c05277ca3f367c98162", | |
| "source_kind": "source_qualified_native_calibration", | |
| }, | |
| "ab7ab62caa70cfd748969c5b7e200d7d5a73ca6a3a40e84c8ac5b3c7313d38b8": { | |
| "source_pr": 304, | |
| "row_count": 145, | |
| "source_revision": "31bf73d5f676dc1bebbe6c05277ca3f367c98162", | |
| "source_kind": "source_qualified_native_calibration", | |
| }, | |
| "2edc7f78efe54b58009151f77591d2ed2dd42246f0e8a228ddebe5df1b6a816e": { | |
| "source_pr": 158, | |
| "row_count": 126, | |
| "source_revision": "dd1fa97add17d3d74f580f4c3e0566c1b5f11827", | |
| }, | |
| "70f62dfd0f620cd233c9637712cb614a3fbab8d4fa3a544ebdb8b4b3c56b586b": { | |
| "source_pr": 158, | |
| "row_count": 124, | |
| "source_revision": "dd1fa97add17d3d74f580f4c3e0566c1b5f11827", | |
| }, | |
| "e313079b4c5d03fc0081e27a46984673b85389a02ad0bd1b780c218bf30f2213": { | |
| "source_pr": 158, | |
| "row_count": 18, | |
| "source_revision": "dd1fa97add17d3d74f580f4c3e0566c1b5f11827", | |
| }, | |
| "1ba1736776ee06679d63a4d888d6548ee94892e45277e1443fcbc308078aa65a": { | |
| "source_pr": 158, | |
| "row_count": 142, | |
| "source_revision": "dd1fa97add17d3d74f580f4c3e0566c1b5f11827", | |
| }, | |
| "468d8911b938235fde963ff8565945b738c47f9de8f98e03f5077974a1bf1df9": { | |
| "source_pr": 158, | |
| "row_count": 124, | |
| "source_revision": "dd1fa97add17d3d74f580f4c3e0566c1b5f11827", | |
| }, | |
| "9eb3693501f0b43f7b682706601b1b15682fa91ce8926175cd0d9a77736b0e07": { | |
| "source_pr": 158, | |
| "row_count": 18, | |
| "source_revision": "dd1fa97add17d3d74f580f4c3e0566c1b5f11827", | |
| }, | |
| "0da08ce08b15c91f9f4bb27d61a7a648d1b0042256b3afdfd8963350600f643a": { | |
| "source_pr": 158, | |
| "row_count": 142, | |
| "source_revision": "dd1fa97add17d3d74f580f4c3e0566c1b5f11827", | |
| }, | |
| "04cfeb721554f382430c531ba4148332489021dbad8bb580642eb81f02f60ad1": { | |
| "source_pr": 232, | |
| "row_count": 145, | |
| "source_revision": "399f93cb875953719204c5ddf47804fea1fed835", | |
| }, | |
| "1524b2202775693754e9e58090f229ca6de4fa3a2a0142e00080cc6a06f4324e": { | |
| "source_pr": 232, | |
| "row_count": 145, | |
| "source_revision": "399f93cb875953719204c5ddf47804fea1fed835", | |
| }, | |
| "50f209adffd6ffcabe95791e72966bade01f02e4f6201e0144d6390dd1fca73e": { | |
| "source_pr": 232, | |
| "row_count": 145, | |
| "source_revision": "399f93cb875953719204c5ddf47804fea1fed835", | |
| }, | |
| "a1380ae8182fb4f0be3244e3c4fadd3e2f33ce78d3237031936480bc70fa6f3b": { | |
| "source_pr": 232, | |
| "row_count": 145, | |
| "source_revision": "399f93cb875953719204c5ddf47804fea1fed835", | |
| }, | |
| "573d51b338e56ca2502a8ebeac993848fe1ace595d2e5c8891539e863340e926": { | |
| "source_pr": 232, | |
| "row_count": 145, | |
| "source_revision": "399f93cb875953719204c5ddf47804fea1fed835", | |
| }, | |
| "972900036ad285306b691aae0e05064a594c21747a3115f9fc16a8549614ed86": { | |
| "source_pr": 232, | |
| "row_count": 145, | |
| "source_revision": "399f93cb875953719204c5ddf47804fea1fed835", | |
| }, | |
| } | |
| POLICY = "aisimulate-dsv41-byte-preserving-v1" | |
| IDENTITY_FIELDS = ( | |
| "model_path system backend backend_version weight_quantization gemm_quant_mode moe_quant_mode fmha_quant_mode fmha_resolution comm_quant_mode kv_cache_dtype parallel_strategy tp moe_tp pp dp moe_ep cp moe_backend attention_backend enable_wideep enable_eplb model_config_sha256 execution_profile engram_residency input_modality" | |
| ).split() | |
| def read(path): | |
| return json.loads(Path(path).read_text()) | |
| def sha(path): | |
| return hashlib.sha256(Path(path).read_bytes()).hexdigest() | |
| def require(ok, message): | |
| if not ok: | |
| raise ValueError(message) | |
| def identity(path): | |
| rows = pq.read_table(path).to_pylist() | |
| require(bool(rows), "Empty DSV41 table") | |
| result = {k: rows[0][k] for k in IDENTITY_FIELDS} | |
| require( | |
| all(all(row[k] == v for k, v in result.items()) for row in rows), | |
| "Mixed DSV41 execution identity", | |
| ) | |
| require( | |
| result["model_path"] == "deepseek-ai/DeepSeek-V4.1-Flash", "Unexpected model" | |
| ) | |
| require( | |
| result["execution_profile"] in ("full", "decoder_bounded"), | |
| "Unknown execution profile", | |
| ) | |
| require( | |
| all(math.isfinite(r["latency_ms"]) and r["latency_ms"] > 0 for r in rows), | |
| "Invalid observed latency", | |
| ) | |
| return result | |
| def producer_identity(originals): | |
| # A Git archive revision and predictor/reader revision are not producer | |
| # evidence. Preserve installed-package identities without inventing a SHA. | |
| values = [item.get("aic_revision", item.get("producer_provenance", {}).get("aic_revision")) | |
| for item in originals] | |
| revisions = sorted({value for value in values if isinstance(value, str) and value}) | |
| commits = {value for value in revisions if re.fullmatch(r"[0-9a-f]{40}", value)} | |
| if len(revisions) > 1: | |
| commit, status = None, "mixed" | |
| elif len(commits) == 1 and all(values): | |
| commit, status = next(iter(commits)), "recorded" | |
| else: | |
| commit, status = None, "unknown" | |
| return { | |
| "aisim_commit": commit, "aisim_commit_status": status, | |
| "producer_revisions": revisions, | |
| "producer_identity_missing": any(not value for value in values), | |
| } | |
| def recorded_model_revision(original): | |
| collection = original.get("collection_provenance", {}) | |
| publication = original.get("private_publication_provenance", {}) | |
| runtime_pair = publication.get("runtime_pair", {}) | |
| runtimes = [collection.get("runtime", {}), | |
| runtime_pair.get("calibration_runtime_identity", {}), | |
| runtime_pair.get("heldout_runtime_identity", {})] | |
| revisions = {runtime["model_revision"] for runtime in runtimes | |
| if runtime.get("model_revision")} | |
| if len(revisions) > 1: | |
| raise ValueError("Conflicting recorded model checkpoint revisions") | |
| return next(iter(revisions), None) | |
| def validate_snapshot(root, manifest): | |
| require( | |
| bool(manifest["fpm"]) and all(entry["sha256"] in REVIEWED_SOURCES for entry in manifest["fpm"]), | |
| "Unknown DSV41 campaign", | |
| ) | |
| paths = set() | |
| metadata = [] | |
| for entry in manifest["fpm"]: | |
| meta = read(root / entry["metadata_path"]) | |
| metadata.append(meta) | |
| require(manifest["model_revision"] == recorded_model_revision(meta), | |
| "Recorded model revision discarded or changed") | |
| require(meta.get("import_policy") == POLICY, "Missing DSV41 import policy") | |
| for f in meta["supporting_files"]: | |
| p = root / f["path"] | |
| require(p.resolve().is_relative_to(root.resolve()), "Escaping path") | |
| require(sha(p) == f["sha256"], "Supporting file digest mismatch") | |
| paths.add(f["path"]) | |
| producer = producer_identity(metadata) | |
| for field in ("aisim_commit", "aisim_commit_status"): | |
| require(manifest[field] == producer[field], "Producer identity mismatch: " + field) | |
| for field in ("producer_revisions", "producer_identity_missing"): | |
| require(manifest["provenance"].get(field) == producer[field], | |
| "Producer provenance mismatch: " + field) | |
| return paths | |
| def validate_catalog_record(root, record): | |
| path = root / record["path"] | |
| source = REVIEWED_SOURCES.get(record["sha256"]) | |
| require( | |
| source is not None | |
| and record["source_revision"] == source["source_revision"] | |
| and record["row_count"] == source["row_count"], | |
| "Unreviewed DSV41 source hash/revision/count", | |
| ) | |
| if source["source_pr"] == 304: | |
| require(record.get("source_kind") == source["source_kind"], | |
| "Native collection must retain its source-artifact identity") | |
| require(record.get("source_revision_kind") == "hf_source_artifact_commit", | |
| "Source artifact must retain its distinct HF commit identity") | |
| meta = read(root / record["metadata_path"]) | |
| ids = identity(path) | |
| require( | |
| record["schema_version"] == 7 | |
| and record["schema_name"] == "aic_fpm_forward_perf", | |
| "Invalid schema7", | |
| ) | |
| require( | |
| meta.get("configuration_selector") == ids, "Schema7 execution identity mismatch" | |
| ) | |
| require(meta.get("import_policy") == POLICY, "Unreviewed DSV41 import") | |
| require(record["source_sha256"] == sha(path), "Changed source calibration bytes") | |
| for field, key in [ | |
| ("model_id", "model_path"), | |
| ("framework", "backend"), | |
| ("framework_version", "backend_version"), | |
| ("system", "system"), | |
| ("tp", "tp"), | |
| ]: | |
| require(record[field] == ids[key], "Catalog identity mismatch: " + field) | |
| if source["source_pr"] == 158: | |
| require( | |
| record["snapshot_status"] == "historical" | |
| and record["role"] == "comparator", | |
| "Archive promoted to serving", | |
| ) | |
| require( | |
| meta["admission"] | |
| in ("quarantined", "development_validation", "historical_component"), | |
| "Archive admission invalid", | |
| ) | |
| else: | |
| require( | |
| ids["backend_version"].startswith("dev-") | |
| and meta["admission"] == "serving", | |
| "Serving data missing dev identity", | |
| ) | |
| require( | |
| meta.get("independent_evaluation_truth") is False, "Calibration cannot be truth" | |
| ) | |
| return 7 | |