File size: 1,297 Bytes
178f61f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Verify the clean strict teacher loader and record its reproducibility audit."""
from __future__ import annotations

import json
from pathlib import Path
import sys

ROOT = Path(r"E:\Gaze_estimation")
sys.path.insert(0, str(ROOT / ".codex_deps"))
sys.path.insert(0, str(ROOT))

from src.models.teacher_strict import audit_to_dict, load_teacher_model_strict


def main() -> None:
    checkpoint = ROOT / "checkpoints" / "resnet50.pt"
    _, first = load_teacher_model_strict(checkpoint, device="cpu")
    _, second = load_teacher_model_strict(checkpoint, device="cpu")
    if first.inference_sha256 != second.inference_sha256:
        raise RuntimeError("Fixed-input inference hash changed across two strict reloads")
    report = audit_to_dict(first)
    report["repeat_load_inference_hash_match"] = True
    report["gate_a_loader_pass"] = bool(
        first.checkpoint_tensor_count == 322
        and first.mapped_tensor_count == first.checkpoint_tensor_count
        and first.model_tensor_count == first.mapped_tensor_count + 1
    )
    output = ROOT / "artifacts" / "kd-teacher-trap-diagnostic" / "strict_teacher_loader_audit.json"
    output.write_text(json.dumps(report, indent=2) + "\n", encoding="utf-8")
    print(json.dumps(report, indent=2))


if __name__ == "__main__":
    main()