Files
nvdriver/tools/check_original_live_init.py
morebrackets 90fadf7ccd tools: harden PT decoder, UVM 620 export check, and MMU/compat/alarm oracle checks
- tools/decode_original_pt_bounded.py: validate --max-lines/--max-errors
  >= 1, guard perf child teardown in try/finally, report missing perf
  cleanly, propagate non-zero perf exit codes when not stopped by a
  limit, and wrap in main().
- tools/check_uvm_620_exports.py: fail cleanly on missing module files
  or empty undefined nvUvmInterface* symbol set (preventing false green
  on stripped/wrong binaries), parse CLI via argparse, and wrap in main().
- tools/check_mmu_oracle.py and tools/timer-alarm-vectors.py: replace
  -O-elidable assert checks with explicit SystemExit errors and wrap in
  main().
- tools/check_compat_layout.py: resolve NVIDIA 580.178.04 include dirs
  via NV_RS_ANALYSIS_ROOT / NV_RS_KERNEL_SRC / OPEN_GPU_ROOT /
  /usr/src/nvidia-580.178.04 instead of hardcoding /home/geodd, replace
  -O-elidable asserts, and wrap in main().
- tools/check_original_live_init.py: close timestamped-record-dump.txt
  with a context manager and wrap in main().
- tests/offline/test_oracle_check_and_pt_decoder_tools.py: offline unit
  tests verified under python3 -O.
2026-12-02 04:22:04 -08:00

106 lines
4.4 KiB
Python

#!/usr/bin/env python3
"""Check two finite original-driver captures; this is not a Rust parity test."""
import argparse
import hashlib
import json
from pathlib import Path
def signature(d):
return [
(
e["gpu_ordinal"],
e["engine_ordinal"],
e["stage"],
e["callback"]["name"],
e["callback"]["offset"],
e["load_flags"],
)
for e in d["events"]
]
def main(argv=None):
p = argparse.ArgumentParser(description=__doc__)
p.add_argument("report_directory", type=Path)
p.add_argument("--labels", type=Path, required=True)
a = p.parse_args(argv)
root = a.report_directory
left = json.loads((root / "standalone-dispatch.json").read_text())
dispatch_path = root / "timestamped-dispatch.json"
dispatch_bytes = dispatch_path.read_bytes()
right = json.loads(dispatch_bytes)
checks = {
"both_runs_2056_samples": left["samples"] == right["samples"] == 2056,
"both_runs_eight_gpu_owners": left["gpu_count"] == right["gpu_count"] == 8,
"no_unparsed_samples": not left["rejected"] and not right["rejected"],
"same_per_gpu_sequences": left["all_gpu_sequences_identical"] and right["all_gpu_sequences_identical"],
"same_order_across_repeated_runs": signature(left) == signature(right),
"all_timestamped_groups_ordered": all(g["timestamp_ordered"] for g in right["gpu_groups"]),
"all_same_engine_sets": all(g["same_engine_set_across_locked_preload_load"] for g in right["gpu_groups"]),
"all_preload_before_load": all(g["all_preload_before_load"] for g in right["gpu_groups"]),
"all_optional_unlocked_before_locked": all(g["unlocked_before_matching_locked"] for g in right["gpu_groups"]),
}
record_keys = ("PERF_RECORD_LOST", "PERF_RECORD_THROTTLE", "PERF_RECORD_UNTHROTTLE")
counts = {k: 0 for k in record_keys}
with (root / "timestamped-record-dump.txt").open() as dump:
for line in dump:
for k in record_keys:
if k in line:
counts[k] += 1
checks["no_reported_lost_or_throttled_records"] = not any(counts.values())
labels = json.loads(a.labels.read_text())
# The generator records a source path relative to its checkout. Verify the
# uniquely identified artifact by content even when the bundle has moved.
recorded_hashes = [
digest for name, digest in labels["inputs"].items()
if Path(name).name == dispatch_path.name
]
checks["label_input_hash_matches"] = (
len(recorded_hashes) == 1
and recorded_hashes[0] == hashlib.sha256(dispatch_bytes).hexdigest()
)
checks["all_labeled_callbacks_match_samples"] = all(
(e := right["events"][c["sample"]])["callback"]["name"] == c["symbol"]
and e["callback_address"] == c["callback_address"]
and e["engine_ordinal"] == obj["engine_ordinal0"]
and e["engine_owner"] == obj["engine_owner"]
and e["gpu_owner"] == obj["gpu_owner"]
and e["stage"] == stage
for obj in labels["engines"]
for stage, c in obj["callbacks"].items()
)
bundle = json.loads((root / "final-rea-evidence-bundle.json").read_text())
ids = [
"ev_b1b9a9279aa151b6f51c93b6bee10b9949d4c6e0f4afcc14d61579d213210443",
"ev_1b2d3b2a0781ff192ac6f67dc3e065dafe95bcb8960d5a122583f4e3cbff8e46",
]
records = {e["evidence_id"]: e for e in bundle["records"]}
for i in ids:
n = records[i]["normalized_result"]
out = "".join(f["data"] for f in n["frames"])
checks["successful_cuda_workload_" + i] = (
n["exit"]["code"] == 0
and '"passed":true' in out
and '"verified_words":64' in out
and '"context_destroyed":true' in out
)
report = {
"passed": all(checks.values()),
"scope": (
"Finite original-driver observations and decoding only; not Rust parity. "
"Hardware breakpoint timings are not a performance baseline. "
"REA process-tree sampling limitations remain in retained Evidence."
),
"checks": checks,
"record_loss_diagnostics": counts,
"rea_capture_evidence": ids,
}
(root / "validation.json").write_text(json.dumps(report, indent=2) + "\n")
print(json.dumps(report, indent=2))
raise SystemExit(0 if report["passed"] else 1)
if __name__ == "__main__":
main()