From 2c3602869fbcf14a0e1e5637a0ca5a139dbb641c Mon Sep 17 00:00:00 2001 From: Vuong Hoang Date: Mon, 17 Aug 2026 16:29:45 -0700 Subject: [PATCH] fix(gen-seat): hash bf16 tensors via uint8 reinterpret, not numpy numpy has no bfloat16, so .numpy().tobytes() raised 'TypeError: Got unsupported ScalarType BFloat16' on real checkpoints. Flatten then view(torch.uint8) before hashing. Result on the heresy candidate: VERDICT IDENTICAL -- all 15 mtp.* tensors byte-identical to the incumbent's verbatim base graft, the head already measured at 47.7% acceptance in production. The ~56 GB bf16 acceptance gate is redundant, so no second seat comes down. --- services/gen-seat-mixed-quant/compare_mtp_head.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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: