mirror of
https://github.com/QuixiAI/nvdriver.git
synced 2026-12-06 14:38:47 +00:00
30 lines
3.4 KiB
Python
30 lines
3.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Check two finite original-driver captures; this is not a Rust parity test."""
|
|
import argparse,json,hashlib
|
|
from pathlib import Path
|
|
p=argparse.ArgumentParser();p.add_argument('report_directory',type=Path);p.add_argument('--labels',type=Path,required=True);a=p.parse_args();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)
|
|
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']]
|
|
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'])}
|
|
counts={k:sum(k in line for line in (root/'timestamped-record-dump.txt').open())for k in ['PERF_RECORD_LOST','PERF_RECORD_THROTTLE','PERF_RECORD_UNTHROTTLE']};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)
|