diff --git a/services/gen-seat-mixed-quant/compare_mtp_head.py b/services/gen-seat-mixed-quant/compare_mtp_head.py index 788e6a4..0107b51 100644 --- a/services/gen-seat-mixed-quant/compare_mtp_head.py +++ b/services/gen-seat-mixed-quant/compare_mtp_head.py @@ -74,8 +74,16 @@ def load_mtp(model_dir: Path) -> dict: def digest(tensor) -> str: """SHA-256 over the raw tensor bytes. Dtype-sensitive by design — a head - stored at a different precision is not the same head for our purposes.""" - return hashlib.sha256(tensor.contiguous().view(-1).numpy().tobytes()).hexdigest() + stored at a different precision is not the same head for our purposes. + + Goes through a uint8 reinterpret rather than `.numpy()`: numpy has no + bfloat16, and these checkpoints are bf16, so the direct route raises + `TypeError: Got unsupported ScalarType BFloat16`. + """ + import torch + + flat = tensor.contiguous().flatten() + return hashlib.sha256(flat.view(torch.uint8).numpy().tobytes()).hexdigest() def main() -> int: